LS Models
   HOME

TheInfoList



OR:

ls is a
shell Shell may refer to: Architecture and design * Shell (structure), a thin structure ** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses Science Biology * Seashell, a hard outer layer of a marine ani ...
command Command may refer to: Computing * Command (computing), a statement in a computer language * command (Unix), a Unix command * COMMAND.COM, the default operating system shell and command-line interpreter for DOS * Command key, a modifier key on A ...
for listing
files File or filing may refer to: Mechanical tools and processes * File (tool), a tool used to remove fine amounts of material from a workpiece. **Filing (metalworking), a material removal process in manufacturing ** Nail file, a tool used to gentl ...
including special files such as directories. Originally developed for
Unix Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
and later codified by
POSIX The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
and
Single UNIX Specification The Single UNIX Specification (SUS) is a standard for computer operating systems, compliance with which is required to qualify for using the "UNIX" trademark. The standard specifies programming interfaces for the C language, a command-line shell, ...
, it is supported in many
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
s today, including
Unix-like A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
variants,
Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
(via
PowerShell PowerShell is a shell program developed by Microsoft for task automation and configuration management. As is typical for a shell, it provides a command-line interpreter for interactive use and a script interpreter for automation via a langu ...
and
UnxUtils UnxUtils is a collection of utility programs that provide popular Unix-based shell commands ported from GNU implementations as native Windows programs that depend only on Win32 and the Microsoft C- runtime ( msvcrt.dll). The collection wa ...
), EFI, and
MSX-DOS MSX-DOS is a discontinued disk operating system developed by Microsoft's Japan subsidiary for the 8-bit home computer standard MSX, and is a cross between MS-DOS v1.25 and CP/M-80 v2.2. MSX-DOS MSX-DOS and the extended BASIC with 3½-in ...
(via MSX-DOS2 Tools). The numerical computing environments
MATLAB MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementat ...
and
GNU Octave GNU Octave is a scientific programming language for scientific computing and numerical computation. Octave helps in solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly ...
include an ls command with similar functionality. In other environments, such as
DOS DOS (, ) is a family of disk-based operating systems for IBM PC compatible computers. The DOS family primarily consists of IBM PC DOS and a rebranded version, Microsoft's MS-DOS, both of which were introduced in 1981. Later compatible syste ...
,
OS/2 OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
, and
Command Prompt A command-line interface (CLI) is a means of interacting with software via commands each formatted as a line of text. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user-friendly alternativ ...
, similar functionality is provided by the dir command. An ls command appeared in the first version of
AT&T AT&T Inc., an abbreviation for its predecessor's former name, the American Telephone and Telegraph Company, is an American multinational telecommunications holding company headquartered at Whitacre Tower in Downtown Dallas, Texas. It is the w ...
UNIX Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
, the name inherited from
Multics Multics ("MULTiplexed Information and Computing Service") is an influential early time-sharing operating system based on the concept of a single-level memory.Dennis M. Ritchie, "The Evolution of the Unix Time-sharing System", Communications of t ...
and short for "list". is part of the
X/Open X/Open group (also known as the Open Group for Unix Systems and incorporated in 1987 as X/Open Company, Ltd.) was a consortium founded by several European UNIX systems manufacturers in 1984 to identify and promote open standards in the field of info ...
Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the
Single Unix Specification The Single UNIX Specification (SUS) is a standard for computer operating systems, compliance with which is required to qualify for using the "UNIX" trademark. The standard specifies programming interfaces for the C language, a command-line shell, ...
.


Behavior

When invoked with no path
argument An argument is a series of sentences, statements, or propositions some of which are called premises and one is the conclusion. The purpose of an argument is to give reasons for one's conclusion via justification, explanation, and/or persu ...
, ls lists the files of the
working directory In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with the process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd function, or just c ...
. Otherwise, it includes each specified file and each file of a specified directory. Common options include: * Includes all files; even those starting with . which on Unix-based systems are otherwise not included * Same as , but excludes the special entries . (working directory) and .. (parent of working directory) * -l Selects the long output format which extends the default output of the file name with additional information including
type Type may refer to: Science and technology Computing * Typing, producing text via a keyboard, typewriter, etc. * Data type, collection of values used for computations. * File type * TYPE (DOS command), a command to display contents of a file. * ...
(- for regular file, d for directory, l for
symbolic link In computing, a symbolic link (also symlink or soft link) is a file whose purpose is to point to a file or directory (called the "target") by specifying a path thereto. Symbolic links are supported by POSIX and by most Unix-like operating syste ...
, n for network file, s for
socket Socket may refer to: Mechanics * Socket wrench, a type of wrench that uses separate, removable sockets to fit different sizes of nuts and bolts * Socket head screw, a screw (or bolt) with a cylindrical head containing a socket into which the hexag ...
, p for named pipe (FIFO), c for character special file, bfor block special file), permissions,
hard link In computing, a hard link is a directory entry (in a Directory (computing), directory-based file system) that associates a name with a Computer file, file. Thus, each file must have at least one hard link. Creating additional hard links for a fil ...
count, owning user and group, size, last-modified timestamp * -h Output sizes as so-called human 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, FreeBSD 4.5 in 2002, and Solaris 9 in 2002. * -R Include files of a directory tree, recursively * -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 and a "*" to executable files


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, the number of
hard link In computing, a hard link is a directory entry (in a Directory (computing), directory-based file system) that associates a name with a Computer file, file. Thus, each file must have at least one hard link. Creating additional hard links for a fil ...
s, owning user, owning group,
size Size in general is the Magnitude (mathematics), magnitude or dimensions of a thing. More specifically, ''geometrical size'' (or ''spatial size'') can refer to three geometrical measures: length, area, or volume. Length can be generalized ...
, modification date,
name A name is a term used for identification by an external observer. They can identify a class or category of things, or a single thing, either uniquely, or within a given context. The entity identified by a name is called its referent. A person ...
. 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 GNU ( ) is an extensive collection of free software (394 packages ), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operating systems popu ...
ls provides the --color option which enables using a database to control colors maintained using dircolors.
FreeBSD FreeBSD is a free-software Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version was released in 1993 developed from 386BSD, one of the first fully functional and free Unix clones on affordable ...
ls provides the -G option which enables using the
termcap Termcap ("terminal capability") is a legacy software library (computing), library and database used on Unix-like computers that enables programs to use display computer terminals in a terminal-independent manner, which greatly simplifies the proc ...
database 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

* * * * * * * * *


References


External links

* * * * * * * *
GNU ls source code (as part of coreutils)

ls
at the LinuxQuestions.org wiki {{Core Utilities commands Multics commands Standard Unix programs Unix SUS2008 utilities Plan 9 commands Inferno (operating system) commands IBM i Qshell commands