Skip to content

Lesson 7: Running the list directory command with switches

Time to learn another useful command-line option. If you add the letter 'l' to the ls command, it will give you a longer output compared to the default:

[learner learning_linux]$ ls -l /home
total 4
drwxr-xr-x 6 learner learner 4096 Dec  2 08:31 learner

For each file and directory, we now see more information including file ownership and modification times. The 'd' at the start of each line indicates that these are directories whereas, a dash indicates it is a file. There are many, many different options for the ls command; Try out the following (against any directory of your choice) to see how the output changes:

ls -l
ls -R
ls -l -t -r
ls -lh

Note

The last example above combined multiple options but only use one dash. This is a very common way of specifying multiple command-line options. To view all options available, read the manual page using the man command.