← Back to list

Day 5: More about the Linux Shell

Today, I learnt about the shell in-depth. The shell is where the user interacts with the entire system.

Edeki Charles · 2026-04-05 23:52 · 1 claps · 2.7 min read
#linux #data-engineering #linux-shell
Open on Medium ↗
Wiki topics: 🔧 · Data Engineering 🔓 · Open Source

Day 5: More about the Linux Shell

Today, I learnt about the shell in-depth. The shell is where the user interacts with the entire system.

Environment and Shell Variables

Each time a shell is started it creates an environment that contains variables that define the system behaviour. These environment variables are variables that are defined for the current shell and are inherited by any child shells or processes. Think of them as public settings meant for every program you run during that session. Linux environment variables are used by applications to get information about the environment.

On the other hand, shell variables are contained exclusively within the shell in which they were set or defined. They are often used to keep track of ephemeral data, like the current working directory. Unlike environment variables, shell variables are not automatically passed to child processes unless explicitly exported.

$STUFF=hellllooooo  # creating a shell variable.
echo $STUFF
hellllooooo
export STUFF # this turns STUFF into an environment variable

Converting STUFF into an environment variable makes it visible to programs or scripts.

Another way to think of it is to picture your shell as an office, and a shell variable as a note on your own desk where only you can see it. export pins that note to the office noticeboard so that everyone who walks in (every program you launch) can read it.

Input and Output

Within the shell, the output from a command can be sent as an input to a file. For example,

head cpuinfo > cpu_file

As we know, the head command outputs the first 10 lines of a file to the standard output, but the > sign redirects that into the file named cpu_file. Note that if this file exists, it will first erase the original file, then fill it afresh with the result fro, the command. But if the file does not exist, it creates it. To avoid erasing existing files, the use of >> is employed. This appends the output from the command into the file, therefore preserving both the original content and the new one.

Standard Error (stderr)

Standard Error is an additional stream output for diagnostic and debugging.

ls /ffff > output_file
ls: cannot access '/ffff': No such file or directory

The command above creates a new file called ‘output_file’ but it is empty. This is because the directory ‘/ffff’ does not exist. But we get a standard error that spells this out already.

This error can be redirected into a file instead of having it logged directly on the standard output. Below is an example of how that can be done.

ls /ffff > output_file 2> err_file

2 is the stream ID for standard error, 1 is for standard output. Meaning if you replace 2 with 1, the error message will be shown directly on the standard output as it does by default.

Lastly, error messages in Linux, unlike other OS, usually tell you exactly what went wrong. As we see in the error message above, they usually use the format: program_name: file_name: error message

Do not mistake warnings for error messages though. Warning messages mostly contain the word ‘warning’.

Some common errors in Linux include: No such file or directory,

  • No such file or directory: This is when you try to access a file or directory that doesn’t exist.
  • File exists: When you attempt to create a file that already exists.
  • Not a directory, Is a directory: when you try to use a file as a directory or a directory as a file.
  • Permission denied: This appears when you try to perform an operation on a file or directory that you are not authorised to access.

This is a summary of all I learnt from my day 5.

Unto the next, see you on Day 6.

Follow along my 30-day Linux journey. If you’re learning too, feel free to drop a comment.


메타데이터
post_id
02b67329eae4
slug
day-5-more-about-the-linux-shell-02b67329eae4
url
https://medium.com/@charlesedeki093/day-5-more-about-the-linux-shell-02b67329eae4
canonical_url
https://medium.com/@charlesedeki093/day-5-more-about-the-linux-shell-02b67329eae4
author_url
https://medium.com/@charlesedeki093
status
ok
fetched_at
2026-07-29 23:11:35