Contained WithinFind More DocumentationFeatured Support Resources |
ls(1)NAME | SYNOPSIS | DESCRIPTION | OPTIONS | OPERANDS | USAGE | EXAMPLES | ENVIRONMENT VARIABLES | EXIT STATUS | FILES | ATTRIBUTES | SEE ALSO | NOTES NAME
SYNOPSIS
/usr/xpg4/bin/ls [-aAbcCdfFgilLmnopqrRstux1] [file...] DESCRIPTION
For each file that is a directory, ls lists the contents of the directory; for each file that is an ordinary file, ls repeats its name and any other information requested. The output is sorted alphabetically by default. 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. There are three major listing formats. The default format for output directed to a terminal is multi-column with entries sorted down the columns. The -1 option allows single column output and -m enables stream output format. In order to determine output formats for the -C, -x, and -m options, ls uses an environment variable, COLUMNS, to determine the number of character positions available on one output line. If this variable is not set, the terminfo(4) database is used to determine the number of columns, based on the environment variable TERM. If this information cannot be obtained, 80 columns are assumed. The mode printed under the -l option consists of ten characters. The first character may be one of the following: The next 9 characters are interpreted as three sets of three bits each. The first set refers to the owner's permissions; the next to permissions of others in the user-group of the file; and the last to all others. Within each set, the three characters indicate permission to read, to write, and to execute the file as a program, respectively. For a directory, ``execute'' permission is interpreted to mean permission to search the directory for a specified file. The character after permissions is ACL indication. A plus sign is displayed if there is an ACL associated with the file. Nothing is displayed if there are just permissions. ls -l (the long list) prints its output as follows for the POSIX locale:
Reading from right to left, you see that the current directory holds one file, named part2. Next, the last time that file's contents were modified was 9:42 A.M. on May 16. The file contains 10,876 characters, or bytes. The owner of the file, or the user, belongs to the group dev (perhaps indicating ``development''), and his or her login name is smith. The number, in this case 1, indicates the number of links to file part2; see cp(1). The plus sign indicates that there is an ACL associated with the file. Finally, the dash and letters tell you that user, group, and others have permissions to read, write, and execute part2. The execute (x) symbol here occupies the third position of the three-character sequence. A - in the third position would have indicated a denial of execution permissions. The permissions are indicated as follows: /usr/bin/ls/usr/xpg4/bin/lsFor user and group permissions, the third position is sometimes occupied by a character other than x or -. s also may occupy this position, referring to the state of the set-ID bit, whether it be the user's or the group's. The ability to assume the same ID as the user during execution is, for example, used during login when you begin as root but need to assume the identity of the user you login as. In the case of the sequence of group permissions, l may occupy the third position. l refers to mandatory file and record locking. This permission describes a file's ability to allow other files to lock its reading or writing permissions during access. For others permissions, the third position may be occupied by t or T. These refer to the state of the sticky bit and execution permissions. OPTIONS
The following options are supported: Specifying more than one of the options in the following mutually exclusive pairs is not considered an error: -C and -1 (one), -c and -u. The last option specified in each pair determines the output format. /usr/bin/lsSpecifying more than one of the options in the following mutually exclusive pairs is not considered an error: -C and -l (ell), -m and -l (ell), -x and -l (ell). The -l option overrides the other option specified in each pair. /usr/xpg4/bin/lsSpecifying more than one of the options in the following mutually exclusive pairs is not considered an error: -C and -l (ell), -m and -l (ell), -x and -l (ell). The last option specified in each pair determines the output format. OPERANDS
The following operand is supported: USAGESee largefile(5) for the description of the behavior of ls when encountering files greater than or equal to 2 Gbyte ( 231 bytes). EXAMPLESExample 1 File permissionsAn example of a file's permissions is:
This describes a file that is readable, writable, and executable by the user and readable by the group and others. Another example of a file's permissions is:
This describes a file that is readable, writable, and executable by the user, readable and executable by the group and others, and allows its user-ID to be assumed, during execution, by the user presently executing it. Another example of a file's permissions is:
This describes a file that is readable and writable only by the user and the group and can be locked during access. Example 2 Printing the names of all filesThis command prints the names of all files in the current directory, including those that begin with a dot (.), which normally do not print:
Example 3 Providing file informationAnother example of a command line is:
This command provides information on all files, including those that begin with a dot (a), the i-number-the memory address of the i-node associated with the file-printed in the left-hand column (i); the size (in blocks) of the files, printed in the column to the right of the i-numbers (s); finally, the report is displayed in the numeric version of the long list, printing the UID (instead of user name) and GID (instead of group name) numbers associated with the files. When the sizes of the files in a directory are listed, a total count of blocks, including indirect blocks, is printed. ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of ls: LC_COLLATE, LC_CTYPE, LC_TIME, LC_MESSAGES, NLSPATH, and TZ. EXIT STATUSFILES
ATTRIBUTESSee attributes(5) for descriptions of the following attributes: /usr/bin/ls/usr/xpg4/bin/lsSEE ALSONOTESUnprintable characters in file names may confuse the columnar output options. The total block count will be incorrect if there are hard links among the files. NAME | SYNOPSIS | DESCRIPTION | OPTIONS | OPERANDS | USAGE | EXAMPLES | ENVIRONMENT VARIABLES | EXIT STATUS | FILES | ATTRIBUTES | SEE ALSO | NOTES |
||||||