Content-type: text/html Man page of ls

ls

Section: User Commands (1)
Index Return to Main Contents
 

NAME

ls - Lists and generates statistics for files  

SYNOPSIS

ls [-aAbcCdfFgilLmnopqrRstux1] [file...|directory...]


 

STANDARDS

Interfaces documented on this reference page conform to industry standards as follows:

ls:  XPG4, XPG4-UNIX

Refer to the standards(5) reference page for more information about industry standards and associated tags.
 

OPTIONS

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.

[Compaq]  If CMD_ENV=svr4, the ls command reports an l in the group execution field when mandatory locking is enabled. [Compaq]  Lists the file or directory the link references rather than the link itself, if the argument is a symbolic link. Uses stream output format (a comma-separated series). Displays the same information as -l, except that it displays the user and the group IDs instead of the user names and group names. Displays the same information as with -l, except for the group. The -n option overrides the -o option. Puts a slash after each file name if that file is a directory. Displays nonprintable characters in file names as a ? (question mark) character, if output is to a terminal (default). Reverses the order of the sort, giving reverse collation or the oldest first, as appropriate. Lists all subdirectories recursively. Gives space used in n 1024-byte units (including indirect blocks) for each entry. Sorts by time of last modification (latest first) instead of by name. Uses the time of the last access instead of time of the last modification for sorting (when used with -t) or for displaying (when used with -l). This option has no effect when not used with either -t or -l or both. Sorts output horizontally in a multicolumn format. Forces one entry per line output format; this is the default when output is not directed to a terminal.

When you specify the following mutually exclusive options, the last option on the command line takes effect: [Compaq]  -C and -l (ell) [Compaq]  -C and -1 (one) [Compaq]  -m and -l (ell) [Compaq]  -x and -l (ell) [Compaq]  -c and -u
 

OPERANDS

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.
 

DESCRIPTION

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.

[Compaq]  The ls command uses ioctl() to determine the number of byte positions in the output line. If ls cannot get this information, it uses a default value of 80. Columns may not be smaller than 20 bytes or larger than 400 bytes.
 

Modes

The mode displayed with the -l option is interpreted by the first character, as follows: Block special file Character special file Directory [Compaq]  Symbolic link First-In-First-Out (FIFO) special file [Compaq]  Local socket Ordinary file
 

Permissions

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.

The LC_TIME environment variable controls the format of the date and time.
 

System V Compatibility

[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 ls command produces multicolumn output only if the -C option is specified. In addition, the -s option of the SVID 2 compliant command causes file sizes to be reported in 512-byte units rather than in 1024-byte units.
 

EXIT STATUS

The following exit values are returned: Successful completion. An error occurred.
 

NOTE

[Compaq]  Sparse files, such as quota files, may not be using as much on-disk storage as the ls -l command reports. Use the ls -s command to obtain an accurate report of the on-disk storage used by a sparse file.
 

EXAMPLES

The following example lists the quota.user 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

This lists all files, including . (dot), .. (dot-dot), and other files with names beginning with a dot. To display detailed information, enter: ls -l chap1 .profile
This displays a long listing with detailed information about the files chap1 and .profile. To display detailed information about a directory, enter: ls -d -l . manual manual/chap1
This displays a long listing for the directories . and manual, and for the file manual/chap1. Without the -d option, this command lists the files in . and manual instead of providing detailed information about the directories themselves. To list the files in the current directory in order of modification time, enter: ls -l -t
This displays a long listing of the files that were modified most recently, followed by the older files.
 

ENVIRONMENT VARIABLES

The following environment variables affect the execution of ls: Provides a default value for the internationalization variables that are unset or null. If LANG 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 written by ls. Determines the location of message catalogues for the processing of LC_MESSAGES. Determines the timezone for date and time strings written by ls.
 

FILES

Contains user information. Contains group information.
 

SEE ALSO

Commands:  chmod(1), du(1), find(1), getacl(1), ln(1), stty(1)

Functions:  ioctl(2)

Files:  acl(4)

Standards:  standards(5)


 

Index

NAME
SYNOPSIS
STANDARDS
OPTIONS
OPERANDS
DESCRIPTION
Modes
Permissions
System V Compatibility
EXIT STATUS
NOTE
EXAMPLES
ENVIRONMENT VARIABLES
FILES
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 02:42:58 GMT, October 02, 2010