When invoked with no path argument, ls lists the files of the working directory. Otherwise, it includes each specified file and each file of a specified directory.
Common options include:
The following example shows the long form output:
Each output line includes a file type letter ('-' for file, 'd' for directory), 9 letters representing permissions, the number of hard links, owning user, owning group, size, modification date, name. In the working directory, the owner fjones has a directory named drafts, a regular file named edition-32, and an executable named edit.sh which is "old", i.e. modified more than 6 months ago as indicated by the display of the year.
Some implementations support color output to indicate metadata. GNU ls provides the --color option13 which enables using a database to control colors maintained using dircolors. FreeBSD ls provides the -G option which enables using the termcap database14 The following example shows possible color output:
"Native Win32 ports of some GNU utilities". unxutils.sourceforge.net. http://unxutils.sourceforge.net/ ↩
"EFI Shells and Scripting". Intel. Archived from the original on September 27, 2013. Retrieved 2013-09-25. https://web.archive.org/web/20130927203229/http://software.intel.com/en-us/articles/efi-shells-and-scripting/ ↩
"MSX-DOS2 Tools User's Manual - MSX-DOS2 TOOLS ユーザーズマニュアル". April 1, 1993 – via Internet Archive. https://archive.org/details/MSXDOS2TOOLS ↩
"List folder contents - MATLAB ls". https://www.mathworks.com/help/matlab/ref/ls.html ↩
"Function Reference: Ls". Octave Forge. https://octave.sourceforge.io/octave/function/ls.html ↩
"Multics manual page for ls or list command". 14 February 1985. https://web.mit.edu/multics-history/source/Multics/doc/info_segments/list.info ↩
Fischer, Eric. "A Brief History of the 'ls' command". The Linux Documentation Project. https://tldp.org/LDP/LG/issue48/fischer.html ↩
"Multics programmer's manual - Commands and active functions" (PDF). p. 397. http://bitsavers.org/pdf/honeywell/large_systems/multics/AG92-03A_multicsCmds_Feb80.pdf ↩
ls – Shell and Utilities Reference, The Single UNIX Specification, Version 5 from The Open Group https://pubs.opengroup.org/onlinepubs/9799919799/utilities/ls.html ↩
"(decode_switches): -h and -H override output units". coreutils.git. 1997-12-31. http://git.savannah.gnu.org/cgit/coreutils.git/commit/src/ls.c?id=b76a4533046163978f7517f9ea6d3307bfa0a98a ↩
"[base] Log of /stable/10/bin/ls/ls.c". 2001-12-28. https://svnweb.freebsd.org/base?view=revision&revision=88591 ↩
What's New in the Solaris 9 Operating Environment, Sun Microsystems, 2002 http://docs.oracle.com/cd/E19683-01/806-5202/6je7shk5c/index.html ↩
"General output formatting (GNU Coreutils 9.1)". www.gnu.org. Retrieved 2023-01-07. https://www.gnu.org/software/coreutils/manual/html_node/General-output-formatting.html ↩
"FreeBSD Man Pages — ls". Retrieved June 23, 2013. http://www.freebsd.org/cgi/man.cgi?query=ls ↩