How to List Files and Directories in Linux (ls)

ls lists the contents of a directory.

Published September 29, 2026

ls lists the files and directories in a folder. Add flags for long format (-l), hidden files (-a), human-readable sizes (-h) and sorting by time (-t).

How it works

Without arguments it lists the current directory. The long format shows permissions, owner, size and modification date.

Combine flags such as ls -lah for the view most people use daily.

Try it

ls -lah
drwxr-xr-x 5 ada dev 4.0K Nov 12 .
-rw-r--r-- 1 ada dev 1.2K Nov 12 app.js

Practical examples

Long format with hidden files

ls -la

Newest first

ls -lt

Recursive

ls -R src

Only directories

ls -d */

Common mistakes

  • Forgetting -a hides dotfiles.
  • Parsing ls output in scripts (use find or globs).
  • Misreading permission columns.

Key takeaways

  • -l long, -a all, -h human sizes.
  • -t sorts by time.
  • Do not parse ls output in scripts.

FAQ

How do I sort by size?

ls -lS.

Colour output?

ls --color=auto.

More Linux articles