ls: list files and directories

Updated November 2026

ls lists the contents of a directory. It is usually the first command people type on a new system, and its long format shows permissions, owners, sizes and dates at a glance.

ls [options] [file or directory ...]

Common options

OptionMeaning
-lLong format: permissions, links, owner, group, size, date, name
-aInclude hidden files (names starting with .)
-ALike -a but without . and ..
-hSizes in K, M, G (with -l)
-tSort by modification time, newest first
-SSort by size, largest first
-rReverse the sort order
-RList subdirectories recursively
-dList a directory itself, not its contents
-iShow inode numbers
-1One name per line

Examples

ls                      # names in the current directory
ls -l /etc              # long listing of /etc
ls -la                  # include hidden files such as .bashrc
ls -lh                  # human-readable sizes
ls -ltr                 # oldest first, newest at the bottom: handy for log directories
ls -lS | head           # largest files first
ls -ld /tmp             # details of the directory itself
ls -l *.conf            # only files ending in .conf
ls -1 | wc -l           # count entries

Reading the long format

-rw-r--r--  1 anna staff  4820 Nov  2 09:14 report.txt
drwxr-x---  3 anna staff  4096 Oct 30 17:02 projects
lrwxrwxrwx  1 root root     11 Sep  5  2025 vi -> /usr/bin/vim

Useful extras

ls -l --time-style=long-iso       # full dates: 2026-11-02 09:14 (GNU)
ls -lu                            # show access time instead of modification time
ls --color=auto                   # colours (GNU, FreeBSD and recent macOS; older macOS: ls -G)
ls -lZ                            # SELinux contexts (Linux)

Portability notes

The basic options work everywhere. Long options such as --time-style are GNU extensions. FreeBSD and macOS accept --color or -G for colour and -T for full timestamps; OpenBSD's ls has no colour option. Do not parse the output of ls in scripts; file names can contain spaces and newlines. Use wildcards or find instead.