The ls command
List the files and folders in a directory. Lists the contents of each directory you name, or the current directory when you name none. Names that start with a dot are hidden unless you ask for them with -a or -A. In the terminal, folders are shown in blue and programs you can run in green.
Usage
ls [OPTION]... [FILE]...
Options
| -a, --all | show every entry, including hidden ones and the . (this folder) and .. (parent folder) entries |
|---|---|
| -A, --almost-all | show hidden entries, but not . and .. |
| -l | long format: permissions, links, owner, group, size, date and name, one per line |
| -h, --human-readable | with -l, show sizes as 1.5K or 2.0M instead of bytes |
| -t | sort by modification time, newest first |
| -S | sort by size, largest first |
| -r, --reverse | reverse the sort order |
| -R, --recursive | list folders inside folders, all the way down |
| -d, --directory | list a folder itself, not what is inside it |
| -F, --classify | add / after folders and * after programs |
| -1 | one name per line |
Examples
lsWhat is in the current folderls -laEverything, hidden files too, with detailsls -lh /var/logThe log folder with readable sizesls *.txtOnly the names that end in .txt
Learn it step by step
Related commands
learner@sandbox: ~bash (practice)
Note: Try ls here: your home directory has sample files. Press Try beside an example, or type your own.
Enter runs · Tab completes names · ↑ ↓ step through history · Ctrl+L clears · type help for every command
A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.