ls List directory contents
Shows what is in a folder. With no arguments it lists the current directory, one name at a time. Add flags to see sizes, hidden files, dates and who owns what.
Synopsis
ls [OPTION]... [FILE]...
Common options
| Option or form | What it does |
|---|---|
-l | Long format: permissions, link count, owner, group, size and modification time |
-a | Include hidden files (names starting with a dot), plus the . and .. entries |
-A | Like -a, but leaves out the . and .. entries |
-h | Human-readable sizes such as 4.2K or 1.3G. Use it together with -l |
-t | Sort by modification time, newest first |
-S | Sort by size, largest first |
-r | Reverse the sort order |
-R | List sub-folders recursively |
-d | List a folder itself instead of its contents |
Examples
ls -la
ls -lhS
ls -lt
ls -d */
docs/
photos/
ls -R docs
ls photos/*.jpg
photos/a.jpg
photos/b.jpg
Notes
- Hidden files are not a security feature. A leading dot only hides a name from a plain ls. Use -a to see them, and -A to see them without the . and .. entries.
- When ls writes to a terminal it prints in columns. When its output goes into a pipe or a file it prints one name per line, which is what scripts see.
- Colours need a flag: ls -G on macOS and BSD, ls --color=auto on GNU/Linux.
- -h only changes anything alongside -l (or -s). On its own it does nothing visible.
- Don't parse ls output in scripts. Names can contain spaces and newlines. Use a shell glob such as *.txt or the find command instead.
See also
Last reviewed 2026-10-07.