What happens when you type ls -l in the shell?

Sergio Steben Arias Quintero
2 min readApr 17, 2020

We will explain it step by step to understand it better:

what is the shell?

Shell is a command interpreter, which consists of the traditional user interface of Unix-based operating systems.

The language interpreted by the shell (for example the commands, options, arguments, special parameters, expansions, substitutions, operators and other things) is read by lines of text ending with the character “\ n” (new line or enter), it is analyzed and processed.

Where are they read from?

The standard input known as STDIN (default keyboard). In other words interactive mode

In our example the line read contain the text “ls -l \ n”

How does the shell generally work?

The lines are divided into different elements: words and operators. The elements are separated by spaces, tabs and operators.
The command to execute and the arguments to pass are detected

In our example, the detected command is “ls” and the arguments “-l”

Check if you find the command by specifying (program or function) in any of the directories where the executable programs are located.

In our example find it in “/ bin”

With access call system checks whether the calling process can access the file

The exec() family of functions replace the current process image with a new process imag

--

--