ls
ls is a shell command for listing files – including special files such as directories. Originally developed for Unix and later codified by POSIX and Single UNIX Specification.[1]
- GNU Coreutils [EN] @ Fedora Package
- GNU Coreutils [EN] @ Homebrew Formula
Documentation
- ls [EN] @ GNU Coreutils Manual
Syntax
ls [PARAMETER ...] [FILE/DIRECTORY ...]
Parameters
- General
- The following parameters can be used with all version of ls:
- NOTE:The BSD version only supports the short form (e.g. -a) of these parameters!
- -1
- List one file per line.
- -a, --all
- Do not ignore entries starting with .
- -A, --almost-all
- Like -a but do not list implied . and ..
- --color[=WHEN]
- Colorize the output. WHEN defaults to always or can be never or auto.
- -F, --classify
- Append indicator (one of */=>@|) to entries:
- * for executables
- / for directories
- = for sockets
- > for doors
- @ for links
- | for fifos
- -h, --human-readable
- Print with -l sizes in human readable format (e.g. 1K, 234M, 2G).
- -i, --inode
- Print the index number of each file.
- -l
- Use a long listing format.
- -r, --reverse
- Reverse order while sorting.
- -R, --recursive
- List subdirectories recursively.
- -s, --size
- Print size of each file, in blocks.
- -S
- Sort by file size.
- -t
- Sort by modification time.
- BSD
- The following parameters can be used with the BSD version of ls:
- -D FORMAT
- When printing in the long (-l) format, use FORMAT to format the date and time output. The argument format is a string used by strftime.
- -G
- Enable colorized output.
Examples
- List all subdirectories and files of a directory
ls -laFh
- List only subdirectories of a directory
ls -la | grep '^d'
- Define aliases for directory listing
if type -P 'eza' >'/dev/null' 2>&1; then # eza
alias ls="eza --classify --time-style='long-iso'"
alias ll='ls --git --group --header --long'
alias l='ll --all --all'
else
if ls --context >'/dev/null' 2>&1; then # GNU ls version
alias ls="ls --classify --color --time-style='long-iso'"
if type -P 'dircolors' >'/dev/null' 2>&1; then
eval "$(dircolors -b)"
fi
else # other ls versions
alias ls="ls -D '%F %T' -F -G"
fi
alias ll='ls -h -l'
alias l='ll -a'
fi
alias lr='l -R'
alias lt="l -r -s 'time'"
References
- ↑ Wikipedia contributors. "ls." Wikipedia. https://en.wikipedia.org/wiki/Ls (accessed 18.08.2025)