ls -l in the shell

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

Adrian Felipe Vides Jimenez
3 min readNov 26, 2020

Previously I’ve already talk about the command <ls> here. So before start reading this article I recommend you to check that other first.

Now let’s get started. First we need to define:

¿What is a shell?

  • Is a command interpreter in operating system such as Unix or Linux
  • It is a program that executes other programs
  • It provides an interface to the system so the user can run different commands or utilities/tools with some input data.

In fact there are several kinds of shell’s, such as Bourne shell, Bash, Zsh, etc… and you can choose the one that fixes you the most.

¿What does the shell do?

  • Wait for the user to type a command
  • Parse the command and saved into a string, then split that string by every argument (called tokens).
  • Then check if those are aliases, built-ins or executables (binaries). In this case the command ls is located in the /bin/ directory into the PATH (which is an enviromment variable and looks like this: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games ) As you can see in the PATH are different absolute paths separated by colons; therefore ls will just look for the /bin directory
  • Executes the matched command or print an error if the input typed is not valid

Now that we have an overview of what shell does, let’s move onto our other question, what happens with ls -l

ls. Listing Files

The command ls is used in Linux to list files, but now we are adding a flag -l… What this flag do is that shows us a long list, with details of the files in the current directory:

As you can see the command displays the files in the current directory, and it shows details of every file. And here is what do that information means:

¡Now you know what happens behind scenes when you type a command. so keep reading and practicing more!

--

--

Adrian Felipe Vides Jimenez

I'm a Software Developer passionate by programming, videogames and music. Nowadays studying at Holberton School