ls - list directory contents
ls [options] [file]...
Options you will use
-l- Long listing: type+permissions, link count, owner, group, size, mtime, name.
-a, --all- Do not ignore entries starting with a dot (includes . and ..).
-A- Like -a but omit . and ..
-h, --human-readable- With -l, print sizes as 1K, 234M, 2G.
-R, --recursive- List subdirectories recursively.
-i, --inode- Print the inode number of each file.
-d, --directory- List the directory itself, not its contents. Essential with -l on a dir.
-t- Sort by modification time, newest first.
-S- Sort by file size, largest first.
-r, --reverse- Reverse the sort order.
-1- One entry per line.
-F, --classify- Append an indicator: / dir, * executable, @ symlink.
--color=auto- Colourise the output when stdout is a terminal (aliased by default on Ubuntu).
--time-style STYLE- How -l shows times: full-iso, long-iso, iso, or +FORMAT like +%F.
-n, --numeric-uid-gid- Like -l, but show numeric user and group IDs instead of names.
-Z, --context- Show the SELinux / AppArmor security context of each file.
Examples
$ ls -lathe everyday listing, hidden files included
$ ls -ld /srv/vaultpermissions OF the directory instead of what is in it
$ ls -liinode numbers - two names with the same inode are hard links
$ ls -lhS /var/logbiggest files in /var/log first
Gotchas
- The first column of ls -l: d=directory l=symlink -=regular file; then user/group/other rwx. An s in place of x is setuid/setgid, a t on other is the sticky bit.
Taught in
Try ls in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.