List directory contents with optional detail and sorting.
low risk
ls reads directory entries and displays them. With -l it shows permissions, ownership, size, and timestamps. -a reveals hidden dotfiles. Pipe to grep or awk for filtering. Colors are controlled by LS_COLORS.
| Flag | Meaning |
|---|---|
-l | Long format: permissions, links, owner, size, date |
-a --all | Show hidden files (starting with .) |
-h --human-readable | Print sizes as K, M, G instead of bytes |
-t | Sort by modification time, newest first |
-R --recursive | List subdirectories recursively |
-S | Sort by file size, largest first |
ls -lah /var/logShow all files including hidden with human-readable sizes in /var/log · explain & risk-check →ls -lt /tmp | head -20Show the 20 most recently modified files in /tmp · explain & risk-check →ls -lS /usr/bin | tail -10Show the 10 smallest binaries in /usr/bin · explain & risk-check →Use `ls --color=always | less -R` to get colorized output inside less without losing terminal color codes.
Reference text is hand-written and may be incomplete — check man ls for your version. Test destructive commands on a non-production system first.