ls(1)ls(1)NAME
ls, lc, l, ll, lsf, lsr, lsx - list contents of directories
SYNOPSIS
[names]
[names]
[ls_options] [names]
[ls_options] [names]
[ls_options] [names]
[ls_options] [names]
[ls_options] [names]
DESCRIPTION
For each directory argument, the command lists the contents of the
directory. For each file argument, repeats its name and any other
information requested. The output is sorted in ascending collation
order by default (see Environment Variables below). When no argument
is given, the current directory is listed. When several arguments are
given, the arguments are first sorted appropriately, but file arguments
appear before directories and their contents.
If you are a user with appropriate privileges, all files except and are
listed by default.
There are three major listing formats. The format chosen depends on
whether the output is going to a login device (determined by whether
output device file is a device), and can also be controlled by option
flags.
The default format for a login device is to list the contents of direc‐
tories in multicolumn format, with entries sorted vertically by column.
(When individual file names (as opposed to directory names) appear in
the argument list, those file names are always sorted across the page
rather than down the page in columns because individual file names can
be arbitrarily long.) If the standard output is not a login device,
the default format is to list one entry per line.
The and options enable multicolumn formats, and the option enables
stream output format in which files are listed across the page, sepa‐
rated by commas. In order to determine output formats for the and
options, uses an environment variable, to determine the number of char‐
acter positions available on each output line. If this variable is not
set, the database is used to determine the number of columns, based on
the environment variable If this information cannot be obtained, 80
columns is assumed.
The command functions the same as except that the default output is
columnar, even if output is redirected.
Options
recognizes the following options:
List all entries; usually entries whose names begin with a
period
are not listed.
List nonprinting characters in the octal
notation.
Use time of last modification of the inode
(file created, mode changed, etc.) for sorting or print‐
ing (ell)).
If an argument is a directory, list only its name (not its con‐
tents);
often used with (ell) to get the status of a directory.
Under the UNIX 2003 environment (see standards(5)), with
does not follow symbolic links unless the or option is
specified.
List the extent attributes of the file.
If any of the files has a extent attribute, this option
lists the extent size, space reserved and allocation
flags. This option must be used with the (ell) option.
Interpret each argument as a directory
and list the name found in each slot. This option dis‐
ables (ell), and and enables the order is the order in
which entries appear in the directory.
Same as
(ell), except that only the group is printed (owner is
omitted). If both (ell) and are specified, the owner is
not printed.
For each file, list the inode number
in the first column of the report. When used in multi‐
column output, the number precedes the file name in each
column.
(ell) List in long format, giving mode, number of links,
owner, group, size in bytes, and time of last modifica‐
tion for each file (see further and below). If the time
of last modification is greater than six months ago, or
any time in the future, the year is substituted for the
hour and minute of the modification time. If the file is
a special file, the size field contains the major and
minor device numbers rather than a size. If the file is
a symbolic link, the filename is printed, followed by and
the pathname of the referenced file.
Under the UNIX 2003 environment (see standards(5)), with
does not follow symbolic links unless the or option is
specified.
Stream output format.
The same as
(ell) except that the owner's UID and group's GID numbers
are printed, rather than the associated character
strings.
The same as
(ell) except that only the owner is printed (group is
omitted). (If both (ell) and are specified, the group is
not printed).
Put a slash
after each file name if that file is a directory.
List nonprinting characters in file names as the character
Reverse the order of sort to get reverse (descending) collation
or oldest first, as appropriate.
List size in blocks of 512-byte units, including indirect
blocks,
for each entry. The first entry listed is the total num‐
ber of blocks in the directory. When used in multicolumn
output, the number of blocks precedes the file name in
each column. The number of indirect blocks in a file is
filesystem dependent.
Sort by time modified (latest first) before sorting alphabeti‐
cally.
Use time of last access instead of last modification for sorting
option) or printing (ell) option).
List multicolumn output with entries sorted across rather than
down the page.
The same as
except that the current directory and parent directory
are not listed. For a user with appropriate privileges,
this flag defaults to on, and is turned off by
List multicolumn output with entries sorted down the columns.
After each file name, put one of:
· A slash if the file is a directory or a symbolic link
to a directory.
· An asterisk if the file is executable;
· An at-sign if the file is a symbolic link to a file;
· A vertical bar if the file is a fifo.
Under the UNIX 2003 environment (see standards(5)), with
does not follow symbolic links unless the or option is
specified.
If a symbolic link referencing a file of type directory is spec‐
ified
on the command line, evaluates the file information and
file type to be those of the file referenced by the link,
and not the link itself. However, writes the name of the
link itself and not the file referenced by the link.
Evaluate the file information and file type for all symbolic
links
(whether named on the command line or encountered in a
file hierarchy) to be those of the file referenced by the
link, and not the link itself. However, writes the name
of the link itself and not the file referenced by the
link. When is used with write the contents of symbolic
links in the long format.
Recursively list subdirectories encountered.
(one) List the file names in single column format
regardless of the output device. This forces single col‐
umn format to the user's terminal.
Specifying more than one of the options in the following mutually
exclusive pairs is not considered an error: and (ell), and (ell), and
(ell), and (one), and and and
is known by several shorthand-version names for the various formats:
is equivalent to
is equivalent to
(ell)
is equivalent to
is equivalent to
is equivalent to
The shorthand notations are implemented as links to Option arguments to
the shorthand versions behave exactly as if the long form above had
been used with the additional arguments. The mode printed in listings
produced by the (ell) option consists of 10 characters, for example,
The first character indicates the entry type:
Block special file
Character special file
Directory
Symbolic link
Network special file
Fifo (also called a "named pipe") special file
Socket
Ordinary file
The next 9 characters are interpreted as three sets of three characters
each which identify access and execution permissions for the owner,
group, and others categories, as described in chmod(1). The indicates
the permission is not granted. The various permissions can be put
together in any combination, except that the and characters are mutu‐
ally exclusive, as implied below.
Read by owner
Write by owner
Execute (or search directory) by owner; do not set user ID on
execution
Execute/search by owner; set user ID on execution
No execute/search by owner; set user ID on execution
Read by group
Write by group
Execute/search by group; do not set group ID on execution
Execute/search by group; set group ID on execution
No execute/search by group; set group ID on execution
Read by others
Write by others
Execute/search by others; do not set sticky bit on execution
Execute/search by others; set sticky bit on execution
No execute/search by others; set sticky bit on execution
The mode characters are interpreted as follows:
Deny all permissions in the corresponding position.
Grant read permission to the corresponding user class.
Grant write permission to the corresponding user class.
Grant execute (or search in directory) permission
to the corresponding user class.
Grant execute (search) permission to the corresponding user
class.
Execute the file as if by the owner (set user ID, SUID)
or group (set group ID, SGID), as indicated by position.
Deny execute (search) permission to the corresponding user
class.
Execute the file as if by the owner (set user ID, SUID)
or group (set group ID, SGID), as indicated by position.
Grant execute (search) permission to others.
The "sticky" bit is set (see the description of in
chmod(2)).
Deny execute (search directory) permission to others.
The "sticky" bit is set.
When an option is specified that results in a listing of directory
and/or file sizes in bytes or blocks (such as the or (ell) option), a
total count of blocks, including indirect blocks, is also printed at
the beginning of the listing.
Access Control Lists (ACLs)
If a file has optional ACL entries, the (ell) option displays a plus
sign after the file's permissions. The permissions shown are a summary
representation of the file's access control list, as returned by in the
field (see stat(2)). To list the contents of an access control list,
use the command (see lsacl(1) and acl(5)) for HFS file systems, or the
command (see getacl(1) and aclv(5)) for JFS file systems.
EXTERNAL INFLUENCES
For information about the UNIX standard environment, see standards(5).
Environment Variables
If the variable is set, uses the width provided in determining posi‐
tioning of columnar output.
determines the locale to use for the locale categories when both and
the corresponding environment variable (beginning with do not specify a
locale. If is not set or is null, it defaults to (see lang(5)).
determines the order in which the output is sorted.
determines which characters are classified as nonprinting for the and
options, and the interpretation of single- and/or multibyte characters
within file names.
determines the date and time strings output by the (ell), and options.
determines the language in which messages (other than the date and time
strings) are displayed.
If any internationalization variable contains an invalid setting, they
all default to (see environ(5)).
International Code Set Support
Single- and multibyte character code sets are supported.
RETURN VALUE
exits with one of the following values:
All input files were listed successfully.
was aborted because errors occurred when accessing files.
The following conditions cause an error:
· Specified file not found.
· User has no permission to read the directory.
· Process could not get enough memory.
· Invalid option specified.
EXAMPLES
Print a long listing of all the files in the current working directory
(including the file sizes). List the most recently modified (youngest)
file first, followed by the next older file, and so forth, to the old‐
est. Files whose names begin with a are also printed.
WARNINGS
Setting options based on whether the output is a login (tty) device is
undesirable because is very different from On the other hand, not using
this setting makes old shell scripts that used almost inevitably fail.
Nonprinting characters in file names (without the or option) may cause
columnar output to be misaligned.
DEPENDENCIES
NFS
The (ell) option does not display a plus sign after the access permis‐
sion bits of networked files to represent existence of optional access
control list entries.
AUTHOR
was developed by AT&T, the University of California, Berkeley and HP.
FILES
For group IDs for (ell) and
For user IDs for (ell) and
For terminal information.
SEE ALSOchmod(1), find(1), getacl(1), lsacl(1), stat(2), acl(5), aclv(5), stan‐
dards(5).
STANDARDS CONFORMANCEls(1)