What other flags can be used with `ls`?

QuestionsQuestions8 SkillsProDec, 19 2025
0111

Aside from the flags covered in the lab (-l, -a, and -R), ls has many other powerful options. Here are some of the most commonly used ones:

1. -h (Human-Readable)

When used with -l, it displays file sizes in a readable format (e.g., K for Kilobytes, M for Megabytes, G for Gigabytes) instead of just bytes.

ls -lh

2. -t (Sort by Time)

This sorts the list based on the last modification time, with the newest files appearing first. This is very helpful when looking for a file you just edited.

ls -lt

3. -S (Sort by Size)

This sorts the output by file size, showing the largest files at the top.

ls -lS

4. -F (Classify)

Adds a symbol to the end of each entry to identify its type:

  • / for directories
  • * for executable files
  • @ for symbolic links
ls -F

5. -1 (Single Column)

Forces the list to display in a single vertical column. This is often used when redirecting output to other commands or scripts.

ls -1

6. --color

Most modern systems (like the one you are using) enable this by default, but it's the flag that tells the terminal to color-code files (blue for directories, green for executables, etc.).

Pro-tip: You can combine many of these! For example, ls -lth will give you a detailed list, sorted by time, with human-readable file sizes.

To see the complete list of dozens of flags, you can always type man ls in your terminal!

0 Comments

no data
Be the first to share your comment!