Back to course

15. Viewing Sizes and Directory Depth (`-h`, `-R`)

Linux Basics: From Zero to CLI Hero

More Useful ls Options

Human Readable Sizes (-h)

When using -l, file sizes are shown in bytes, which can be hard to read. -h converts the sizes into human-readable units (KB, MB, GB).

bash $ ls -lh -rw-r--r-- 1 user user 1.0K Nov 7 14:35 my_file.txt

Recursive Listing (-R)

To view the contents of subdirectories within the current directory, use the -R (recursive) option.

bash $ ls -R Documents

Documents: MyReport.pdf Projects

Documents/Projects: Budget.xlsx

This can generate a lot of output, so use it carefully in large directories.