Back to course

14. Advanced `ls`: Using Options and Flags (`-l`, `-a`)

Linux Basics: From Zero to CLI Hero

Enhancing Output with Options

Almost every Linux command can be modified using options (also called flags or switches). Options are preceded by a hyphen (-).

The Long List Format (-l)

This is perhaps the most useful ls option. It provides detailed information about each item, including permissions, ownership, size, and creation date.

bash $ ls -l total 8 drwxr-xr-x 2 user user 4096 Nov 7 14:30 Desktop -rw-r--r-- 1 user user 1024 Nov 7 14:35 my_file.txt

Showing Hidden Files (-a)

In Linux, files or directories starting with a dot (.) are hidden. These are typically configuration files. The -a (all) option reveals them.

bash $ ls -a . .. .bashrc Desktop Documents

Combining Options

You can combine options into a single string. To see all files, including hidden ones, in the long format, use -la:

bash $ ls -la