What does ls do?
ls lists the files and folders inside a directory. With -l it shows permissions, owner, size and date; with -a it also shows hidden files (names starting with a dot).
ls [options] [path…]
Most useful options
| Option | What it does |
|---|---|
| -l | long format: permissions, owner, size, date |
| -a | show hidden files too |
| -h | human-readable sizes (K, M, G) |
| -R | list sub-folders recursively |
| -t | sort by modification time |
| -S | sort by size |
ls examples
In security work
After getting access to a machine, ls -la in home folders reveals hidden files like .bash_history and .ssh keys.
Questions about ls
How do I see hidden files in Linux?
Use ls -a (or ls -la for details). Hidden files are simply files whose names start with a dot.
What does drwxr-xr-x mean?
d = directory; rwx = the owner can read, write and enter it; r-x = the group and others can read and enter it but not change it.