What happen when you type ls -l in the shell
To understand the bash commands in shell first we need to know what is a shell?
What is a shell?
The shell is a program that takes commands from the keyboard and gives them to the operating system to perform. In the old days, it was the only user interface available on a Unix-like system such as Linux. Nowadays, we have graphical user interfaces (GUIs) in addition to command line interfaces (CLIs) such as the shell.
On most Linux systems a program called bash (which stands for Bourne Again SHell, an enhanced version of the original Unix shell program, sh, written by Steve Bourne) acts as the shell program. Besides bash, there are other shell programs that can be installed in a Linux system. These include: ksh, tcsh and zsh.
So we already know what is a shell, now we have to understand what is a terminal, and how it works.
It’s a program called a terminal emulator. This is a program that opens a window and lets you interact with the shell. There are a bunch of different terminal emulators you can use. Most Linux distributions supply several, such as: gnome-terminal, konsole, xterm, rxvt, kvt, nxterm, and eterm. Even when we have some different terminals all of them give you access to a shell session. You will probably develop a preference for one, based on the different bells and whistles each one provides.
How to navigate in the shell?
As we see with the shell we can do everything in the computer now we are going to see what happen when you type ls with an argument specially -l in the shell.
The ls command displays information about files including directories. ls is considered as a fundamental command. It has many options. By default, the output of the ls command is sorted alphabetically.
With this command we can see all the files that we stored in a directory, but also we can get all the information about this files, we can pick which extension we want to see, and a lot of more things. The ls command is one of the most important commands in linux.
This are some the mandatory arguments
-a, — alldo not ignore entries starting with .-A, — almost-alldo not list implied . and ..— authorwith -l, print the author of each file-b, — escapeprint C-style escapes for nongraphic characters— block-size=SIZEscale sizes by SIZE before printing them. E.g.,‘ — block-size=M’ prints sizes in units of 1,048,576 bytes. SeeSIZE format below.-B, — ignore-backupsdo not list implied entries ending with ~-c with -lt: sort by, and show, ctime (time of last modification offile status information) with -l: show ctime and sort by nameotherwise: sort by ctime, newest first-C list entries by columns
But now we are going to explain step by step what happen when you talk
When you type just ls you will see the list of the files in order and nothing else. But when you type
ls-l you will see the list of the files in long format with all the information. Something like this.
Here we have all the information for all the files that are in the directory and we can read it in this way.
If you want to understand more about the bash commands in your terminal click here
Or here, you will find more information about how to use the ls command.