đ NAME
ls - list directory contents
đ Quick Reference
| Use Case | Command | Description |
| List all files (including hidden) | ls -a | Show entries starting with . đ |
| Long format (permissions, owner, size) | ls -l | Detailed listing đ |
| Human-readable sizes | ls -lh | Show sizes like 1K, 234M đ |
| List all files, long format | ls -la | All files, detailed đđ |
| Sort by modification time, newest first | ls -lt | Newest files at top đ |
| Reverse order | ls -ltr | Oldest first, newest last đ |
| Recursive listing | ls -R | Include subdirectories đđ |
| One file per line | ls -1 | Simple list, no columns 1ī¸âŖ |
| Classify files with indicators | ls -F | Append */=>@| to entries đˇī¸ |
| Sort by file size | ls -S | Largest first âŦī¸ |
| Sort by extension | ls -X | Group by extension đ |
| Show inode numbers | ls -i | Print index number of each file đĸ |
| List directories only, not contents | ls -d */ | Show directories themselves đ |
đ SYNOPSIS
ls [OPTION]... [FILE]...
đ DESCRIPTION
List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
đ§ OPTIONS
- -a, --all â do not ignore entries starting with . đ (show hidden files)
- -A, --almost-all â do not list implied . and .. đđĢ (exclude . and ..)
- --author â with -l, print the author of each file âī¸
- -b, --escape â print C-style escapes for nongraphic characters đ
- --block-size=SIZE â with -l, scale sizes by SIZE when printing them; e.g., '--block-size=M'; see SIZE format below đ
- -B, --ignore-backups â do not list implied entries ending with ~ đ (ignore backup files)
- -c â with -lt: sort by, and show, ctime (time of last modification of file status information); with -l: show ctime and sort by name; otherwise: sort by ctime, newest first âąī¸
- -C â list entries by columns đī¸
- --color[=WHEN] â colorize the output; WHEN can be 'always' (default if omitted), 'auto', or 'never'; more info below đ¨
- -d, --directory â list directories themselves, not their contents đ
- -D, --dired â generate output designed for Emacs' dired mode đĨī¸
- -f â do not sort, enable -aU, disable -ls --color đ
- -F, --classify â append indicator (one of */=>@|) to entries đˇī¸
- --file-type â likewise, except do not append '*' đˇī¸
- --format=WORD â across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C đ
- --full-time â like -l --time-style=full-iso đ
- -g â like -l, but do not list owner đ¤đĢ
- --group-directories-first â group directories before files; can be augmented with a --sort option, but any use of --sort=none (-U) disables grouping đâŦī¸
- -G, --no-group â in a long listing, don't print group names đĨđĢ
- -h, --human-readable â with -l and -s, print sizes like 1K 234M 2G etc. đ
- --si â likewise, but use powers of 1000 not 1024 đ
- -H, --dereference-command-line â follow symbolic links listed on the command line đ
- --dereference-command-line-symlink-to-dir â follow each command line symbolic link that points to a directory đđ
- --hide=PATTERN â do not list implied entries matching shell PATTERN (overridden by -a or -A) đ
- --hyperlink[=WHEN] â hyperlink file names; WHEN can be 'always' (default if omitted), 'auto', or 'never' đ
- --indicator-style=WORD â append indicator with style WORD to entry names: none (default), slash (-p), file-type (--file-type), classify (-F) đˇī¸
- -i, --inode â print the index number of each file đĸ
- -I, --ignore=PATTERN â do not list implied entries matching shell PATTERN đ
- -k, --kibibytes â default to 1024-byte blocks for disk usage; used only with -s and per directory totals đ
- -l â use a long listing format đ
- -L, --dereference â when showing file information for a symbolic link, show information for the file the link references rather than for the link itself đ
- -m â fill width with a comma separated list of entries đŦ
- -n, --numeric-uid-gid â like -l, but list numeric user and group IDs đĸ
- -N, --literal â print entry names without quoting đ
- -o â like -l, but do not list group information đĨđĢ
- -p, --indicator-style=slash â append / indicator to directories đ/
- -q, --hide-control-chars â print ? instead of nongraphic characters â
- --show-control-chars â show nongraphic characters as-is (the default, unless program is 'ls' and output is a terminal) đ
- -Q, --quote-name â enclose entry names in double quotes đŦ
- --quoting-style=WORD â use quoting style WORD for entry names: literal, locale, shell, shell-always, shell-escape, shell-escape-always, c, escape (overrides QUOTING_STYLE environment variable) đŦ
- -r, --reverse â reverse order while sorting đ
- -R, --recursive â list subdirectories recursively đđ
- -s, --size â print the allocated size of each file, in blocks đ
- -S â sort by file size, largest first âŦī¸
- --sort=WORD â sort by WORD instead of name: none (-U), size (-S), time (-t), version (-v), extension (-X) đĸ
- --time=WORD â change the default of using modification times; access time (-u): atime, access, use; change time (-c): ctime, status; birth time: birth, creation; with -l, WORD determines which time to show; with --sort=time, sort by WORD (newest first) đ
- --time-style=TIME_STYLE â time/date format with -l; see TIME_STYLE below đ
- -t â sort by time, newest first; see --time đ
- -T, --tabsize=COLS â assume tab stops at each COLS instead of 8 đ
- -u â with -lt: sort by, and show, access time; with -l: show access time and sort by name; otherwise: sort by access time, newest first đī¸
- -U â do not sort; list entries in directory order âĄ
- -v â natural sort of (version) numbers within text đĸ
- -w, --width=COLS â set output width to COLS. 0 means no limit đ
- -x â list entries by lines instead of by columns âī¸
- -X â sort alphabetically by entry extension đ
- -Z, --context â print any security context of each file đĄī¸
- -1 â list one file per line. Avoid '\n' with -q or -b 1ī¸âŖ
- --help â display this help and exit â
- --version â output version information and exit đˇī¸
đž SIZE argument
The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
đ TIME_STYLE
The TIME_STYLE argument can be full-iso, long-iso, iso, locale, or +FORMAT. FORMAT is interpreted like in date(1). If FORMAT is FORMAT1<newline>FORMAT2, then FORMAT1 applies to non-recent files and FORMAT2 to recent files. TIME_STYLE prefixed with 'posix-' takes effect only outside the POSIX locale. Also the TIME_STYLE environment variable sets the default style to use.
đ¨ Color output
Using color to distinguish file types is disabled both by default and with --color=never. With --color=auto, ls emits color codes only when standard output is connected to a terminal. The LS_COLORS environment variable can change the settings. Use the dircolors command to set it.
đĒ Exit Codes
0 â Success â
(everything OK)
1 â Minor problems (e.g., cannot access subdirectory) â ī¸
2 â Serious trouble (e.g., cannot access command-line argument) â
đ¤ AUTHOR
Written by Richard M. Stallman and David MacKenzie.
đ REPORTING BUGS
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
ÂŠī¸ COPYRIGHT
Copyright Š 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
đ SEE ALSO
Full documentation <https://www.gnu.org/software/coreutils/ls>
or available locally via: info '(coreutils) ls invocation'