# Ls

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Ls
> Markdown URL: https://mediated.wiki/source/Ls.md
> Source: https://en.wikipedia.org/wiki/Ls
> Source revision: 1356791810
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Shell command for listing files

This article is about the Unix-style command line shell directory listing command. For other uses, see [LS](/source/LS_(disambiguation)).

"ls(1)" redirects here. For similarly named topics, see [LS1 (disambiguation)](/source/LS1_(disambiguation)).

ls Long file listing with ls --color=auto -l in Linux showing various modes, date formats, colors and appended indicators (executables and directories). Original authors coreutils: Richard Stallman and David MacKenzie Developers Various open-source and commercial developers Written in C Operating system Multics, Unix, Unix-like, Plan 9, Inferno, MSX-DOS Type Command License coreutils: GPLv3+ BusyBox: GPL-2.0-only Toybox: 0BSD Plan 9: MIT License

**ls** is a [shell](/source/Shell_(computing)) [command](/source/Command_(computing)) for listing [files](/source/Computer_file) – including [special files](/source/Unix_file_type) such as [directories](/source/Computer_directory). Originally developed for [Unix](/source/Unix) and later codified by [POSIX](/source/POSIX) and [Single UNIX Specification](/source/Single_UNIX_Specification), it is supported in many [operating systems](/source/Operating_system) today, including [Unix-like](/source/Unix-like) variants, [Windows](/source/Microsoft_Windows) (via [PowerShell](/source/PowerShell) and [UnxUtils](/source/UnxUtils)),[1] [EFI](/source/Unified_Extensible_Firmware_Interface),[2] and [MSX-DOS](/source/MSX-DOS) (via [MSX-DOS2 Tools](/source/ASCII_Corporation)).[3]

The [numerical computing](/source/Numerical_analysis) environments [MATLAB](/source/MATLAB) and [GNU Octave](/source/GNU_Octave) include an ls command with similar functionality.[4][5]

An ls command appeared in the first version of [AT&T](/source/AT%26T_Corporation) [UNIX](/source/Unix). The name inherited from [Multics](/source/Multics) and is short for "list".[6][7][8] ls is part of the [X/Open](/source/X%2FOpen) Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the [Single Unix Specification](/source/Single_Unix_Specification).[9]

In [MS-DOS](/source/MS-DOS), [OS/2](/source/OS%2F2), and Windows, the equivalent command is [dir](/source/Dir_(command)). [Apple DOS](/source/Apple_DOS) for the [Apple II](/source/Apple_II) uses CATALOG.

## Behavior

When invoked with no path [argument](/source/Command-line_argument), ls lists the files of the [working directory](/source/Working_directory). Otherwise, it includes each specified file and each file of a specified directory.

Common options include:

- -a Includes **a**ll files, even those starting with ., which on Unix-based systems are otherwise [not included](/source/Hidden_file_and_hidden_directory#Unix_and_Unix-like_environments)

- -A Same as -a, but excludes the special entries . (working directory) and .. (parent of working directory)

- -l Selects the **l**ong output format which extends the default output of the file name with additional information including [type](/source/Unix_file_types) (- for regular file, d for directory, l for [symbolic link](/source/Symbolic_link), n for [network file](/source/Network_filesystem), s for [socket](/source/Network_socket), p for [named pipe](/source/Named_pipe) (FIFO), c for [character special file](/source/Device_file), bfor [block special file](/source/Device_file)), permissions, [hard link](/source/Hard_link) count, owning user and group, size, last-modified timestamp

- -h Output sizes as so-called **h**uman readable by using units of KB, MB, GB instead of bytes. This option is not part of the POSIX standard, although implemented in several systems, e.g., GNU coreutils in 1997,[10] FreeBSD 4.5 in 2002,[11] and Solaris 9 in 2002.[12]

- -R Include files of a directory tree, **r**ecursively

- -t Sort the list by modification time (default sort is alphabetically)

- -u Sort the list by last access time

- -c Sort the list by last attribute (status) change time

- -r Reverse the order, for example most recent time last

- --full-time Show times down to the millisecond instead of just the minute

- -1 One entry per line

- -m Stream format; list items across the page, separated by commas.

- -g Include group but not owner

- -o Include owner but not group (when combined with -g both group and owner are suppressed)

- -d Show information about a directory or symbolic link, rather than the contents of a directory or the link's target

- -F Append a "/" to directory names, a "*" to executable files and a "@" to symbolic links

## Example

The following example shows the long form output:

$ 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

Each output line includes a file type letter ('-' for file, 'd' for directory), 9 letters representing [permissions](/source/File_system_permissions#Notation_of_traditional_Unix_permissions), the number of [hard links](/source/Hard_link), owning user, owning group, [size](/source/File_size), modification date, [name](/source/Filename). 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.

┌─────────── file (not a directory)
|┌─────────── read-write (no execution) permissions for the owner
|│  ┌───────── read-only permissions for the group
|│  │  ┌─────── read-only permissions for others
|│  │  │     ┌── 3 hard links
|│  │  │     │   ┌── owning user
|│  │  │     │   │     ┌── owning group
|│  │  │     │   │     │          ┌── file size in bytes
|│  │  │     │   │     │          │    ┌── last modified on
|│  │  │     │   │     │          │    │                ┌── filename
-rw-r--r--   3 fjones editors    30405 Mar  2 12:52  edition-32

Some implementations support color output to indicate metadata. [GNU](/source/GNU) ls provides the --color option[13] which enables using a database to control colors maintained using dircolors. [FreeBSD](/source/FreeBSD) ls provides the -G option which enables using the [termcap](/source/Termcap) database[14] The following example shows possible color output:

-rw-r--r--    1 tsmitt nregion   26650 Dec 20 11:16 audio.ogg
brw-r--r--    1 tsmitt nregion      64 Jan 27 05:52 bd-block-device
crw-r--r--    1 tsmitt nregion     255 Jan 26 13:57 cd-character-device
-rw-r--r--    1 tsmitt nregion     290 Jan 26 14:08 image.png
drwxrwxr-x    2 tsmitt nregion      48 Jan 26 11:28 di-directory
-rwxrwxr-x    1 tsmitt nregion      29 Jan 26 14:03 ex-executable
-rw-r--r--    1 tsmitt nregion       0 Dec 20 09:39 fi-regular-file
lrwxrwxrwx    1 tsmitt nregion       3 Jan 26 11:44 ln-soft-link -> dir
lrwxrwxrwx    1 tsmitt nregion      15 Dec 20 10:57 or-orphan-link -> mi-missing-link
drwxr-xrwx    2 tsmitt nregion    4096 Dec 20 10:58 ow-other-writeable-dir
prw-r--r--    1 tsmitt nregion       0 Jan 26 11:50 pi-pipe
-rwxr-sr-x    1 tsmitt nregion       0 Dec 20 11:05 sg-setgid
srw-rw-rw-    1 tsmitt nregion       0 Jan 26 12:00 so-socket
drwxr-xr-t    2 tsmitt nregion    4096 Dec 20 10:58 st-sticky-dir
-rwsr-xr-x    1 tsmitt nregion       0 Dec 20 11:09 su-setuid
-rw-r--r--    1 tsmitt nregion   10240 Dec 20 11:12 compressed.gz
drwxrwxrwt    2 tsmitt nregion    4096 Dec 20 11:10 tw-sticky-other-writeable-dir

## See also

- [stat (Unix)](/source/Stat_(Unix)) – Unix system call for querying file metadataPages displaying short descriptions of redirect targets

- [chown](/source/Chown) – Shell command for changing the owner of a file

- [chgrp](/source/Chgrp) – Shell command for changing the group of a file

- [du (Unix)](/source/Du_(Unix)) – Shell command for reporting file system storage use

- [mdls](/source/Mdls) – Search feature found on Apple devicesPages displaying short descriptions of redirect targets

- [User identifier (Unix)](/source/User_identifier_(Unix)) – Value identifying a user account in Unix and Unix-like operating systemsPages displaying short descriptions of redirect targets

- [Group identifier (Unix)](/source/Group_identifier_(Unix)) – Unix/POSIX system account group number; numeric value used to represent a specific groupPages displaying short descriptions of redirect targets

- [List of POSIX commands](/source/List_of_POSIX_commands)

- [Unix directory structure](/source/Unix_directory_structure) – Directory structure used by a Unix-like operating systemPages displaying short descriptions of redirect targets

## References

1. **[^](#cite_ref-1)** ["Native Win32 ports of some GNU utilities"](https://unxutils.sourceforge.net/). *unxutils.sourceforge.net*. [Archived](https://web.archive.org/web/20060209022842/http://unxutils.sourceforge.net/) from the original on 2006-02-09. Retrieved 2025-08-09.

1. **[^](#cite_ref-EFI-Shells-and-Scripting_2-0)** ["EFI Shells and Scripting"](https://web.archive.org/web/20130927203229/http://software.intel.com/en-us/articles/efi-shells-and-scripting/). [Intel](/source/Intel). Archived from [the original](http://software.intel.com/en-us/articles/efi-shells-and-scripting/) on September 27, 2013. Retrieved 2013-09-25.

1. **[^](#cite_ref-3)** ["MSX-DOS2 Tools User's Manual - MSX-DOS2 TOOLS ユーザーズマニュアル"](https://archive.org/details/MSXDOS2TOOLS). April 1, 1993 – via Internet Archive.

1. **[^](#cite_ref-4)** ["List folder contents - MATLAB ls"](https://www.mathworks.com/help/matlab/ref/ls.html). [Archived](https://web.archive.org/web/20121009233800/https://www.mathworks.com/help/matlab/ref/ls.html) from the original on 2012-10-09. Retrieved 2019-04-06.

1. **[^](#cite_ref-5)** ["Function Reference: Ls"](https://octave.sourceforge.io/octave/function/ls.html). *Octave Forge*. [Archived](https://web.archive.org/web/20190406171041/https://octave.sourceforge.io/octave/function/ls.html) from the original on 2019-04-06. Retrieved 2019-04-06.

1. **[^](#cite_ref-6)** ["Multics manual page for ls or list command"](https://web.mit.edu/multics-history/source/Multics/doc/info_segments/list.info). 14 February 1985.

1. **[^](#cite_ref-7)** Fischer, Eric. ["A Brief History of the 'ls' command"](https://tldp.org/LDP/LG/issue48/fischer.html). *[The Linux Documentation Project](/source/The_Linux_Documentation_Project)*. [Archived](https://web.archive.org/web/20230102040116/https://tldp.org/LDP/LG/issue48/fischer.html) from the original on 2023-01-02. Retrieved 2022-12-09.

1. **[^](#cite_ref-8)** ["Multics programmer's manual - Commands and active functions"](http://bitsavers.org/pdf/honeywell/large_systems/multics/AG92-03A_multicsCmds_Feb80.pdf) (PDF). p. 397.

1. **[^](#cite_ref-9)** [ls](https://pubs.opengroup.org/onlinepubs/9799919799/utilities/ls.html) – Shell and Utilities Reference, [The Single UNIX Specification](/source/Single_Unix_Specification), Version 5 from [The Open Group](/source/The_Open_Group)

1. **[^](#cite_ref-10)** ["(decode_switches): -h and -H override output units"](http://git.savannah.gnu.org/cgit/coreutils.git/commit/src/ls.c?id=b76a4533046163978f7517f9ea6d3307bfa0a98a). coreutils.git. 1997-12-31. [Archived](https://web.archive.org/web/20191210055340/https://git.savannah.gnu.org/cgit/coreutils.git/commit/src/ls.c?id=b76a4533046163978f7517f9ea6d3307bfa0a98a) from the original on 2019-12-10. Retrieved 2014-11-05.

1. **[^](#cite_ref-11)** ["\[base\] Log of /stable/10/bin/ls/ls.c"](https://svnweb.freebsd.org/base?view=revision&revision=88591). 2001-12-28. [Archived](https://web.archive.org/web/20150921164916/http://svnweb.freebsd.org/base?view=revision) from the original on 2015-09-21. Retrieved 2014-11-05.

1. **[^](#cite_ref-12)** [*What's New in the Solaris 9 Operating Environment*](http://docs.oracle.com/cd/E19683-01/806-5202/6je7shk5c/index.html), Sun Microsystems, 2002, [archived](https://web.archive.org/web/20150318060312/http://docs.oracle.com/cd/E19683-01/806-5202/6je7shk5c/index.html) from the original on 2015-03-18, retrieved 2014-11-05

1. **[^](#cite_ref-13)** ["General output formatting (GNU Coreutils 9.1)"](https://www.gnu.org/software/coreutils/manual/html_node/General-output-formatting.html). *www.gnu.org*. [Archived](https://web.archive.org/web/20230107084005/https://www.gnu.org/software/coreutils/manual/html_node/General-output-formatting.html) from the original on 2023-01-07. Retrieved 2023-01-07.

1. **[^](#cite_ref-14)** ["FreeBSD Man Pages — ls"](http://www.freebsd.org/cgi/man.cgi?query=ls). [Archived](https://web.archive.org/web/20130922040709/http://www.freebsd.org/cgi/man.cgi?query=ls) from the original on September 22, 2013. Retrieved June 23, 2013.

## External links

The Wikibook *[Guide to Unix](https://en.wikibooks.org/wiki/Guide_to_Unix)* has a page on the topic of: ***[Commands](https://en.wikibooks.org/wiki/Guide_to_Unix/Commands)***

- [ls](https://pubs.opengroup.org/onlinepubs/9799919799/utilities/ls.html) – Shell and Utilities Reference, [The Single UNIX Specification](/source/Single_Unix_Specification), Version 5 from [The Open Group](/source/The_Open_Group)

- [ls(1)](https://www.freebsd.org/cgi/man.cgi?query=ls&sektion=1) – [FreeBSD](/source/FreeBSD) General Commands [Manual](/source/Man_page)

- [ls(1)](https://man.netbsd.org/ls.1) – [NetBSD](/source/NetBSD) General Commands [Manual](/source/Man_page)

- [ls(1)](https://man.openbsd.org/ls.1) – [OpenBSD](/source/OpenBSD) General Commands [Manual](/source/Man_page)

- [ls(1)](https://docs.oracle.com/cd/E88353_01/html/E37839/ls-1.html) – [Solaris 11.4](/source/Solaris_(operating_system)) User Commands Reference [Manual](/source/Man_page)

- [ls(1)](https://man7.org/linux/man-pages/man1/ls.1.html) – [Linux](/source/Linux) User [Manual](/source/Man_page) – User Commands

- [ls(1)](https://9p.io/magic/man2html/1/ls) – [Plan 9](/source/Plan_9_from_Bell_Labs) Programmer's Manual, Volume 1

- [ls(1)](http://man.cat-v.org/inferno/1/ls) – [Inferno](/source/Inferno_(operating_system)) General commands [Manual](/source/Man_page)

- [GNU ls source code (as part of coreutils)](http://ftp.gnu.org/pub/gnu/coreutils/)

- [ls](http://wiki.linuxquestions.org/wiki/Ls) at the LinuxQuestions.org wiki

v t e Unix command-line utilities and shell builtins File system cat chattr chmod chown chgrp cksum cmp cp dd du df file fuser ln ls mkdir mv pax pwd rm rmdir split tee touch type umask Processes at bg crontab fg kill nice ps time User environment env exit logname mesg talk tput uname who write Text processing awk basename comm csplit cut diff dirname ed ex fold head iconv join m4 more nl paste patch printf read sed sort strings tail tr troff uniq vi wc xargs Shell builtins alias cd echo test unset wait Searching find grep Documentation man Software development ar ctags lex make nm strip yacc Miscellaneous bc cal dc expr lp od sleep true and false Categories Standard Unix programs Unix SUS2008 utilities List

v t e Plan 9 command-line interface programs and shell builtins File system chmod chgrp cmp cp dd du file gzip ls mkdir pwd rm split tee touch Processes kill ps User environment passwd who Text processing awk basename comm diff ed eqn join sed sort spell strings tail tr troff uniq wc Shell builtins echo test Networking ip/ipconfig ip/ping netstat Searching grep Software development ar hoc lex nm strip yacc Miscellaneous bc cal fortune sleep Category

v t e GNU Core Utilities command-line interface programs File system chcon chmod chown chgrp cksum cp dd df dir dircolors install ln ls mkdir mkfifo mknod mktemp mv realpath rm rmdir shred sync touch truncate vdir Text utilities b2sum base32 base64 cat cksum comm csplit cut expand fmt fold head join md5sum nl numfmt od paste ptx pr sha1sum shuf sort split sum tac tail tr tsort unexpand uniq wc Shell utilities arch basename chroot date dirname du echo env expr factor false groups hostid id link logname nice nohup nproc pathchk pinky printenv printf pwd readlink runcon seq sleep stat stdbuf stty tee test timeout true tty uname unlink uptime users who whoami yes

---
Adapted from the Wikipedia article [Ls](https://en.wikipedia.org/wiki/Ls) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Ls?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
