|Original author(s)||coreutils: Richard Stallman and David MacKenzie|
|Developer(s)||Various open-source and commercial developers|
|Operating system||Multics, Unix, Unix-like, Plan 9, Inferno, MSX-DOS|
Plan 9: MIT License
ls is a command to list computer files and directories in Unix and Unix-like operating systems. It is specified by POSIX and the Single UNIX Specification.
It is available in the EFI shell., as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities. or as part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2.
The numerical computing environments MATLAB and GNU Octave include an
function with similar functionality.
In other environments, such as DOS, OS/2, and Microsoft Windows, similar functionality is provided by the
As with most utilities the different implementations have different options. Check the documentation provided with the command for correct usage and options.
ls utility appeared in the first version of AT&T UNIX, the name inherited from a similar command in Multics also named 'ls', short for the word "list".
ls is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the Single Unix Specification.
ls [options] [file… | directory …]
Unix and Unix-like operating systems maintain the idea of a working directory. When invoked without arguments,
ls lists the files in the working directory. If a directory is specified, the files in that directory are listed. The arguments may contain a multiple files and directories.
Names starting with "." are hidden. The directory "." refers to the working directory and ".." refers to its parent directory. These are not shown by default. With
-a (all) hidden files are shown. Using
-A (All including "." and ".." ). File names specified explicitly (for example "
.secret*" ) are always listed.
ls displays names only. Multiple options may be combined.
Common options include:
-llong format, displaying Unix file types, permissions, number of hard links, owner, group, size, last-modified date-time and name. If the modified date is older than 6 months the time is replaced with the year. Some implementations add additional flags to permissions.
-houtput sizes in human readable format. (e.g., 1K, 234M, 2G, etc.) This option is not part of the POSIX standard, although implemented in several systems, e.g., GNU coreutils in 1997, FreeBSD 4.5 in 2002, and Solaris 9 in 2002.
Additional options controlling how items are displayed include:
-RRecursively list items in subdirectories and subdirectories …
-tsort the list by modification time. (default is alphabetically)
-usort the list by last access time.
-csort the list by last attribute (status) change time.
-rreverse the order, for example most recent time last.
--full-timeto show times with seconds and milliseconds instead of down to the minute.
-1one entry per line.
-mStream format; list items across the page, separated by commas.
-ginclude group but not owner
-oinclude owner but not group (when combined with
-gboth group and owner are suppressed)
-dshows information about a directory or symbolic link, rather than the contents of a directory or the link's target.
-Fappend a "/" to directory names and a "*" to executable files.
It is may be possible to highlight different types of items with different colors. This is an area where implementations differ:
--coloroption; checks the Unix file type, the file permissions and the file extension and uses its own database to control colors maintained using dircolors.
-Goption; checks only the Unix file type and file permissions. and uses the termcap database
When the option to use color to indicate item types is selected, the output might look like:
The following example demonstrates the output of the command:
$ ls -l drwxr--r-- 1 fjones editors 4096 Mar 2 12:52 drafts -rw-r--r-- 3 fjones editors 30405 Mar 2 12:52 edition-32 -r-xr-xr-x 1 fjones bookkeepers 8460 Jan 16 2022 edit.sh
The above example shows the "d" )(directory) or "-" (file) indicator, Unix file permission notation, number of Hard_links (1 or 3). In the working directory the owner
fjones has a directory named
drafts, a regular file named
edition-32, and an old executable named