Index Index for
Section 1
Index Alphabetical
listing for L
Bottom of page Bottom of
page

ls(1)

NAME

ls - Lists and generates statistics for files

SYNOPSIS

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

STANDARDS

Interfaces documented on this reference page conform to industry standards as follows: ls: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags.

OPTIONS

-a 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. -A [Tru64 UNIX] 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. -b [Tru64 UNIX] Displays nonprintable characters in octal notation. -c 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. -C Sorts output vertically in a multicolumn format. This is the default when output is to a terminal. -d 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. -D If the file is a special file, and the machine is cluster aware, the size field contains the major and minor device numbers assigned on the local machine. -f 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. -F 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, an @ (at sign) for a symbolic link, and a | (vertical bar) for a FIFO. -g Displays the same information as -l, except for the owner. -i Displays the file serial number in the first column of the report for each file. -l Displays the mode, number of links, owner, group, size (in bytes), and time of last modification for each file, and pathname. [Tru64 UNIX] If the file is a symbolic link, the pathname of the linked-to file is also preceded by ->. The attributes of the symbolic link are displayed. The -n option overrides the -l option. [Tru64 UNIX] If CMD_ENV=svr4, the ls command reports an l in the group execution field when mandatory locking is enabled. -L [Tru64 UNIX] Lists the file or directory link references rather than the link itself, if the argument is a symbolic link. -m Uses stream output format (a comma-separated series). -n Displays the same information as -l, except that it displays the user and the group IDs instead of the user names and group names. -o Displays the same information as with -l, except for the group. The -n option overrides the -o option. -p Puts a slash after each file name if that file is a directory. -q Displays nonprintable characters in file names as a ? (question mark) character, if output is to a terminal (default). -r Reverses the order of the sort, giving reverse collation or the oldest first, as appropriate. -R Lists all subdirectories recursively. -s Gives space used in n 1024-byte units (including indirect blocks) for each entry. [Tru64 UNIX] When run on an AdvFS clone file set, the ls -s command displays the space used by the files in the original file set at the time the clone file set was created. The file sizes are displayed in 1024-byte units. -t Sorts by time of last modification (latest first) instead of by name. -u 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. -x Sorts output horizontally in a multicolumn format. -1 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: · [Tru64 UNIX] -C and -l (ell) · [Tru64 UNIX] -C and -1 (one) · [Tru64 UNIX] -m and -l (ell) · [Tru64 UNIX] -x and -l (ell) · [Tru64 UNIX] -c and -u

OPERANDS

file | directory The path name of a file or directory about which information is to be output. If this operand 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. [Tru64 UNIX] There are three main ways to format the output: · [Tru64 UNIX] 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. [Tru64 UNIX] 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: b Block special file c Character special file d Directory l [Tru64 UNIX] Symbolic link p First-In-First-Out (FIFO) special file s [Tru64 UNIX] 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: r read w write x 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 [Tru64 UNIX] 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. [Tru64 UNIX] 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: 0 Successful completion. >0 An error occurred.

NOTE

[Tru64 UNIX] 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

1. 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 2. 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. 3. To display detailed information, enter: ls -l chap1 .profile This displays a long listing with detailed information about the files chap1 and .profile. 4. 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. 5. 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: COLUMNS Determines the user's preferred column position width for writing multiple text-column output. If this variable contains a string representing a decimal integer, the ls utility calculates how many pathname text columns to write (see -C) based on the width provided. If COLUMNS is not set or invalid, an implementation-dependent number of column positions is assumed, based on the implementation's knowledge of the output device. The column width chosen to write the names of files in any given directory will be constant. Filenames will not be truncated to fit into the multiple text-column output. LANG 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. LC_ALL If set to a non-empty string value, overrides the values of all the other internationalization variables. LC_COLLATE Determines the locale for character collation information in determining the pathname collation sequence. LC_CTYPE 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). LC_MESSAGES Determines the locale for the format and contents of diagnostic messages written to standard error. LC_TIME Determines the format and contents for the date and time strings written by ls. NLSPATH Determines the location of message catalogues for the processing of LC_MESSAGES. TZ Determines the timezone for date and time strings written by ls.

FILES

/etc/passwd Contains user information. /etc/group Contains group information.

SEE ALSO

Commands: chmod(1), du(1), find(1), ln(1), stty(1) Functions: ioctl(2) Files: acl(4) Standards: standards(5)

Index Index for
Section 1
Index Alphabetical
listing for L
Top of page Top of
page