ls -la

Everything behind the ls -la * .c command.

Sebastian Molina Henao

--

Before we start, you should know the shell, which is where we will put our command, so we will give a brief review of this:

The shell is a command interpreter that provides a user interface for accessing operating system services. The shell interprets certain commands that provide a function to the user to do certain specific processes.

very simple, welcome to the shell!

shell

A shell works with an infinite loop, where it will be waiting for a command to be entered to proceed with the execution, this evaluates whether the command entered is valid or not, being negative this statement skips an error in the standard output, if it is positive it processes the execution and executes the command process entered.

the shell when the exit command is detected, closes the execution process with an output of 127; another way to close this process is with the ctrl + D key combination.

“ls ”

We will start by giving a quick definition of what “ls” is; is a basic command that lists the contents of directories alphabetically. Generally, the commands can receive more options if we look for more specific results, to add other options to any command, in this case “ls” we simply need to write the command followed by the minus sign “-” and the specific option we need, these options can be find in the man of each command, we can access this by typing man followed by the command, for example in this case it would be “man ls” and there we find the options that we can use together with our desired command, the following is to learn about wildcards, in this case “*” which are parameters that we can also pass to our commands and will be interpreted by the shell, this “*” is used to search for a specified file in the current directory, in this case by putting “* .c” that it will find all the files that match that instruction, now after all this is clear, we can understand what the command “ls” -la * .c does “
First there is ls that together with the option “l” which is to list with long format and “a” so as not to ignore those files that start with “.” and ending with the wildcard that will only list the files that match * .c, as a result we will obtain a detailed list of all the .c files that are in our current directory with date, creation, execution permissions, user and owner.

Basic shell tour.

But that’s not all, that’s just a small part of what happens when entering this command or any other

When the user enters the command “ls -la * .c”, this is stored in a memory space to enter the infinite loop, it is read word by word, checking the options and wildcards, if it is valid, the shell starts a search in the path, which is where all the directories with executable files are found, if it does not find the executable file, it will show us an error message and it will be ready to repeat this with each command entered.

flowchart

And all this is a very basic review on how the shell works as a command interpreter and everything behind it, explained in a very simple way and omitting things that are too technical.

AUTHORS

David Cera Restrepo.

Sebastian Molina Henao.

--

--