It’s amazing everything that happens when you press ls -l. Let’s start by knowing the result of this operation, type in your Linux Terminal ls -l and press the enter key, you should see something like this:
If you have used the ls command, you will know that its function is to list the elements of a directory. Enter the ls command in your terminal and you will see what happens:
As you can see the elements of the current directory are listed without descriptions. If what I need is to list these elements with their associated information, I can do it by combining the ls command with the -l option, which would result in: ls -l.
If you perform this operation, you will see important information on the screen such as: the file name, modification time, file size, group to which it belongs, owner and file permissions, described as follows:
Beyond what this command can show you, it is important that you know how this process starts. In shell, each command to execute comes from a basic scheme that is defined as follows
$ Command name Options Arguments
Typing ls -l looks like this:
$ Ncommand Options Arguments
$ ls -l
Knowing that the command line uses this scheme, we can detail what happens when you type ls -l and press the enter key:
- The first thing that shell does is check that the character validation is really associated with one of the stored programs.
- If this is correct, it looks for the ls executable in the paths specified by the PATH environment variable, which in this case would be / bin / ls.
- Finally the execution of this program leads to a list of files and directories of the file system.
Now every time you press this command you will know that many things happen in just seconds before printing the result.