As mentioned in the basic command list, the ls command is used to display the list of files and directories in our current location.

Let us now look at some options that we can use with the ls command and how they work.

In order to understand the type of elements that are displayed on the screen by the command, we can also use the -F option.

Typing ls -F will give us results similar to these:


The -F option adds a symbol next to the element to indicate its type:

* for executable elements
/ to indicate directories
@ to indicate a symlink

in the examples shown we have woff.html which is a symlink (with the @ symbol) and the elements indicated by / are directories.

An important use of ls is made by adding the -l option like this:

ls -l

and we get a result like this:


We note that the command returns various information; let us take the Animals directory as a reference and analyze the string preceding it:

  • drwxrwxr-x – are the permissions of the element (see the lesson on user/group permissions to learn more), the initial “d” specifies that this element is a directory, in case of a file we would have the symbol “-” or the letter “l” in case of links;
  • 4 – the number of links associated with the element (see the lesson on links);
  • mint – the user name that owns the element;
  • mint – the group name of the element (can be the same as the user name sometimes);
  • 120 – the size on disk of the element;
  • Jul 18 13:40 – the date and time the element was created;
  • Animals – the name of the element;

Instead, to show items according to the order in which they were created, we can use the commands ls -t (sort by modification time) or ls -r (reverse order while sorting).

We can use the -a option to display hidden elements as well. In order to make the result more readable we can concatenate the -a option with the -l option like this (we specify that the majority of all options can be concatenated depending on one’s usage needs):

ls -la


Lastly, we mention that with the -R option it is possible to display a recursive list of the files and directories tree starting from our current location. For example, I write:

ls -R

and this is the output screen


GO TO PREVIOUS LESSON ⬅                                                                                                                                     ➡  GO TO NEXT LESSON