The ls command in Linux


Many people who have used Windows or Mac OS all their lives don’t know how powerful and simple the terminal of a GNU/LINUX distribution is to use because in these operating systems the use of the terminal is reduced and if you are a user who uses the pc for internet browsing then it is likely that you have never used an interpreter commands in the terminal.

Nowadays, most GNU/LINUX distributions have evolved to such an extent that it is possible that a user with little knowledge of general computing can develop without having to use a terminal.

System administrators are usually very skilled at using the terminal since the execution of their commands allows us to perform commands to the system and with it we can do practically anything in an amazing time and efficiency; from opening a file, such as copying it, moving it or even showing all the contents of files in a folder; but if you are not a system administrator or have simply never used the terminal in any GNU/LINUX distribution, do not worry today in this article we will explain the use of a simple but very useful command: the ls command.

ls command basic usage

The ls command is one of the most important and basic commands in the world of unix systems, it serves to display files within a directory. The screen output will be shown in the terminal and according to the options used you can modify the way it is shown.

The most basic way to use the ls command is to simply invoke it in the terminal itself:


And then it will list all the files and folders that are inside the home folder. To display another folder, simply leave a space and place the path to the folder to be displayed. For example, I will show the entire contents of the Dir.

          ls /home/angelo/Dir

Using ls

That is the most basic way to use the command but we can also invoke the command along with the –help option to show all the help available on it.

ls help
ls help

Of course, we see the image with the help available for the command and we may feel overwhelmed by the amount of information provided, but basically what is shown are the options that are added to the command to extend its functionality. Some of the most important options are:





Do not ignore entries starting with .


Do not list implied . And ..


List directories themselves, not their contents


print the index number of each file


Use a long listing format. Displays information such as permissions and owner of the folder or file.


reverse order while sorting


List subdirectories recursively. Displays the contents of the directory subfolders.


print the allocated size of each file, in blocks


sort by file size, largest first


sort by modification time, newest first


do not sort; list entries in directory order


sort alphabetically by entry extension


Some examples of using the ls command with its options

As stated at the beginning of this article, the ls command is one of the simplest commands to learn and we just have to add the needed option to the command.

Example 1:

List all files and folders, including hidden files.

         ls -a PATH

In this case:

         ls -a /

To display all files in the root directory

ls -a

Example 2:

Show complete information about files and folders with option –l

           ls -l /home/angelo/

ls with option -l

Example 3:

Show files and folders in a reverse order

To do this we use the option -r

           ls -r /home/angelo/

ls with option-r

Show only the directories

In this case we will use the option -d and the asterisk before the symbol /

           ls -d */

ls with option -d

Using the previous command it shows us only the directories or folders from where the prompt is located

Example 5:

Sort by file size

With the option -S we can sort the directories by size.

         ls -S /home/angelo/

ls with option -S



As a conclusion we can say that, far from being complex and reserved for extraordinary people and some computer skills, the terminal tool is a powerful tool that through its commands we can simply execute commands to the operating system with much greater speed and efficiency.

The ls command used to list the files is one of the most essential and simple commands to learn; its different options allow, among other things, ordering and defining the way in which it lists the files.


Please enter your comment!
Please enter your name here