ls - Lists and generates statistics for files
ls [-aAbcCdfFgilLmnopqrRstux1] [file...|directory...]
Interfaces documented on this reference page conform to industry standards as follows:
ls: XPG4, XPG4-UNIX
Refer to the
reference page for more information
about industry standards and associated tags.
Lists all entries in the directory, including the entries that begin with a . (dot). Entries that begin with a . are not displayed unless you refer to them specifically, or you specify the -a option. [Compaq] Lists all entries, except . (dot) and .. (dot-dot). If you issue the ls command as the superuser, it behaves as if you specified this option. [Compaq] Displays nonprintable characters in octal notation. Uses the time of last inode modification (file created, mode changed, and so on) for sorting when used with the -t option. Displays the time of last inode modification (instead of the time at which the file's contents were last modified) when used with the -l option. This option has effect only when used with either -t or -l or both. Sorts output vertically in a multicolumn format. This is the default when output is to a terminal. Displays only the information for the directory that is named, rather than for its contents. This is useful with the -l option to get the status of a directory. Lists the name in each slot for each named directory. This option turns off -l, -t, -s, and -r, and turns on -a; this option uses the order in which entries appear in the directory. Puts a / (slash) after each file name if the file is a directory, an * (asterisk) after each file name if the file can be executed, an = (equal sign) after each file name if the file is a socket, and an @ (at sign) for a symbolic link, and a | (vertical bar) for a FIFO. Displays the same information as -l, except for the owner. Displays the i-number in the first column of the report for each file. Displays the mode, number of links, owner, group, size (in bytes), and time of last modification for each file, and path name. If the file is a special file, the size field instead contains the major and minor device numbers. If the file is a symbolic link, the path name of the linked-to file is also printed preceded by ->. The attributes of the symbolic link are displayed. The -n option overrides the -l option.
When you specify the following mutually exclusive options, the last
option on the command line takes effect:
The path name of a file or directory about which information
is to be output. If this parameter is omitted, the current directory is used.
The ls command writes to standard output the contents of each specified directory or the name of each specified file, along with any other information you ask for with options. If you do not specify a file or a directory, ls displays the contents of the current directory.
By default, ls displays all information in collated order by file name. The collating sequence is determined by the LC_COLLATE environment variable.
[Compaq] There are three main ways to format the output: [Compaq] List entries in multiple columns by specifying either the -C or -x options. When output is to a terminal, -C is the default format. List one entry per line. List entries in a comma-separated series by specifying the -m option.
to determine the number of byte positions in the output line. If
cannot get this information, it uses a default value of 80.
Columns may not be smaller than 20 bytes or larger than 400 bytes.
The mode displayed with the
option is interpreted
by the first character, as follows:
Block special file
Character special file
[Compaq] Symbolic link
First-In-First-Out (FIFO) special file
[Compaq] Local socket
The next nine characters are divided into three sets of three characters each. The first three characters show the owner's permission. The next set of three characters show the permission of the other users in the group. The last set of three characters show the permission of everyone else. The three characters in each set show read, write and execute permission of the file. Execute permission of a directory lets you search a directory for a specified file.
Permissions are indicated as follows: read write execute or search (directories) no access
The group-execute permission character is s if the file has set-group-ID mode. The user-execute permission character is s if the file has set-user-ID mode. The last character of the mode (normally x or -) is t if the 01000 (octal) bit of the mode is set; see the chmod command for the meaning of this mode. The indications of set-ID and the 01000 bit of the mode are capitalized (S and T, respectively) if the corresponding execute permission is not set.
When there is an access control list (ACL) on the listed directory or file the group permissions displayed by the ls command are the maximum permissions allowed for the owning group and for any user or group identified in a qualified ``user'' or ``group'' ACL entry. A given user or member of a group can have more restrictive permissions. Use the getacl command to see the ACL for a given file or directory.
When the sizes of the files in a directory are listed, the ls command displays a total count in 1024-byte units, including indirect blocks.
variable controls the format of the date and time.
[Compaq] The root of the directory tree that contains the commands modified for SVID 2 compliance is specified in the file /etc/svid2_path. You can use /etc/svid2_profile as the basis for, or to include in, your .profile. The file /etc/svid2_profile reads /etc/svid2_path and sets the first entries in the PATH environment variable so that the modified SVID 2 commands are found first.
[Compaq] The SVID 2 compliant version of the
command produces multicolumn output only if the
is specified. In addition, the
option of the SVID 2
compliant command causes file sizes to be reported in 512-byte units rather
than in 1024-byte units.
The following exit values are returned:
An error occurred.
[Compaq] Sparse files, such as quota files, may not be using as much
on-disk storage as the
command to obtain an accurate
report of the on-disk storage used by a sparse file.
The following example lists the
file, a sparse file, two different ways. The example shows that although
the last byte in the file is at logical offset 2097151, the file uses only
24 blocks of on-disk storage:
# ls -l quota.user
-rw-r----- 1 root operator 2097152 Apr 29 14:54 quota.user
# ls -s quota.user 24 quota.user To list all files in the current directory, enter: ls -a
The following environment variables affect the execution of
Provides a default value for the internationalization variables
that are unset or null. If
is unset or null, the corresponding value from the default locale is used.
If any of the internationalization variables contain an invalid setting, the
utility behaves as if none of the variables had been defined.
If set to a non-empty string value, overrides the values of
all the other internationalization variables.
Determines the locale for character collation information
in determining the path name collation sequence.
Determines the locale for the interpretation of sequences
of bytes of text data as characters (for example, single-byte as opposed to
multibyte characters in arguments).
Determines the locale for the format and contents of diagnostic
messages written to standard error.
Determines the format and contents for the date and time strings
Determines the location of message catalogues for the processing
Determines the timezone for date and time strings written
Contains user information.
Contains group information.
Commands: chmod(1), du(1), find(1), getacl(1), ln(1), stty(1)