A deeper dive into the shell

A laptop displays code in a terminal. Next to the laptop, three plants sit before a window.
Photo by Safar Safarov on Unsplash

What happens when you type a command like ls -l into the shell?

When you open a terminal on your computer, it will begin to run the shell program. A shell is a program that interprets and executes commands from the standard input or from a file. If you’re using a Linux-type system, your default will be a bash shell. However, there are several different shells available, and you can even create your own!

On top, a chart separates ls -l ‘\n’ into separate spaces. Below, the same chart is printed with ‘\0’ in place of ‘\n’
On top, a chart separates ls -l ‘\n’ into separate spaces. Below, the same chart is printed with ‘\0’ in place of ‘\n’
Above, a chart shows “ls ‘\0’”. Below, a chart shows “-l ‘\0’”
Above, a chart shows “ls ‘\0’”. Below, a chart shows “-l ‘\0’”
$ ls -lYour path is [PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]Path token is [/usr/local/sbin]Path token is [/usr/local/bin]Path token is [/usr/sbin]Path token is [/usr/bin]Path token is [/sbin]Path token is [/bin]Path token is [/usr/games]Path token is [/usr/local/games]
A chart shows “ls -l ‘\0’” separated by characters.
A chart shows “ls -l ‘\0’” separated by characters.
A terminal displays the output of ls -l, which is the long version of a list of files in the current directory.
A terminal displays the output of ls -l, which is the long version of a list of files in the current directory.

Software engineering student and lover of mountains.