LS, LF, LR(1,C) AIX Commands Reference LS, LF, LR(1,C) ------------------------------------------------------------------------------- ls, lf, lr PURPOSE Displays the contents of a directory. SYNTAX +---------------+ +--------+ +--------+ +--------+ ls ---| +-------+ |---| one of |---| one of |---| one of |---> | | -a -R | | | +----+ | | +----+ | | +----+ | +---| -d -r |---+ +-| -F |-+ +-| -b |-+ +-| -C |-+ | -i -s | | -p | | -q | | -x | | -A -L | +----+ +----+ | -m | | -N -H | | -1 | | -v -S | +----+ | -G | | -z | +-------+ +----------------------------------+ +-------- . --------+ >---| one of |---| +-----------+ |---| | +----+ +----+ | +---| file |---+ | +-| -c |---| -l |--------------+ | ^ | directory | | | | | -u | ^ | -t | | | | | +-----------+ | +-| +----+ | +----+ | |-+ +---------------+ | +--------+ | | +---------------+ +------+ | +-| one of |---| |-+ | +-------+ | +- -t -+ +---| -g -n |---+ ^ | -k -o | | | | -l | | | +-------+ | +-----------+ +------------+ +--------+ +-----------------+ ls --- -f ---| +----+ |---| one of |---| |---| +---| -d |---+ | +----+ | +--- directory ---+ ^ | -i | | +-| -C |-+ ^ | | | -s | | | -x | +-------------+ | +----+ | | -m | +--------+ +----+ 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 the flags. If you do not specify a file or directory, ls Processed November 8, 1990 LS, LF, LR(1,C) 1 LS, LF, LR(1,C) AIX Commands Reference LS, LF, LR(1,C) displays the contents of the current directory. The lf command is equivalent to ls -F. The lr command is equivalent to ls -R. Note: Users running in different locales see different listings on the screen. For example, suppose two users are listing the contents of a single directory. One user is operating in an English or European locale, and one in a Japanese locale. The user running in the English or European locale sees mostly ASCII characters with some extended characters mixed in. File names in ASCII characters are readable, as are file names with extended characters. File names in Japanese characters are difficult or impossible to read. The user running in the Japanese locale usually sees a mixture of ASCII and Japanese characters. (System files retain their ASCII names in order to work properly, even if all user files are given Japanese names.) File names in ASCII characters are readable in the Japanese locale, as are file names in Japanese characters. File names with English or European extended characters are difficult or impossible to read. By default, ls displays all information in alphabetic order by file name. The collating sequence is determined by the LC_COLLATE environment variable or, in the absence of LC_COLLATE, by the LANG environment variable. Individual file names are listed before directory names. There are three main ways to format the output: o List one entry per line. This is the default format unless output is directed to a terminal, in which case -C is the default. o List entries in multiple columns by specifying either the -C or -x flags. o List entries in a comma-separated series by specifying the -m flag. To determine the number of character positions in the output line, ls uses the environment variable COLUMNS. If this variable is not set, it reads the terminfo file. If ls cannot determine the number of character positions by either of these methods, it uses a default value of 80. The mode displayed with the -l flag is interpreted as follows: If the first character is: d The entry is a directory. b The entry is a block special file. c The entry is a character special file. h The entry is a hidden directory and either the -H flag was specified, the file argument was escaped with a trailing "@", or there was not a component that could be matched in a hidden directory. l The entry is a symbolic link and either the -N flag was specified or else the symbolic link did not point to an existing file. p The entry is a first-in first-out (FIFO) special file. s The entry is a socket. Processed November 8, 1990 LS, LF, LR(1,C) 2 LS, LF, LR(1,C) AIX Commands Reference LS, LF, LR(1,C) - The entry is an ordinary file. 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 any one else with access to the file. 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 You can read the file. w You can edit (write) the file. x You can execute the file or search the directory. - You do not have permission to the file. 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 1000 (octal) bit of mode is set; see "chmod" for the meaning of this mode. The indications of set-ID and 1000 bit of the mode are capitalized (S and T respectively) if the corresponding execute permission is not set. When the size of the files in a directory are listed, the ls command displays a total count of blocks, including indirect blocks. The environment variables LANG and LC_TIME control the format of the date and time. FLAGS -A Lists all entries, except . (dot) and .. (dot dot). This flag is implied if the effective user ID is 0 (root). -a Lists all entries in the directory including the entries that begin with a . (dot). -b Displays nonprintable characters in an octal \nnn notation. -c Uses the time of last modification of the inode (file created, mode changed, and so on) for sorting (when used with -t) or for displaying (when used with -l). This flag has no effect when not used with either -t or -l or both. -C Sorts output vertically in a multi-column format. -d Displays only the information for the directory named. This is useful with the -l flag to get the status of a directory. See also the note under the i option below. Processed November 8, 1990 LS, LF, LR(1,C) 3 LS, LF, LR(1,C) AIX Commands Reference LS, LF, LR(1,C) -f Lists the name in each slot for each named directory. This flag turns off -l, -t, -s, and -r, and turns on -a; the order is the order in which entries appear in the directory. -F Lists all directories with a trailing "/", executable files with a trailing "*", hidden directories without a matching component with a trailing "/", and symbolic links with a trailing "@". Symbolic links are shown with the trailing "@" only if the -N flag is used or if the link points to a non-existent file; otherwise, information about the target file is displayed. This option can also be invoked by entering the lf command. -g Displays the same information as with -l, except for the owner. -G Displays the global file system numbers of the files. -H Treats all hidden directories as regular directories, and suppresses the "sliding through" that would otherwise occur. -i Displays the i-number in the first column of the report for each file. Note: The inode number of a hidden directory is provided by ls -i or ls -di if the directory is empty. If it has components (such as i386), each of the above commands displays the inode numbers of the components instead of the hidden directory. -k Displays the mode, site, owner, group, size (in bytes), and time of last modification for each file. -L If an argument is a symbolic link, lists the file or directory the link references rather than the link itself. This is the default, but, can be used to override -N. -l Displays the mode, number of links, owner, group, size (in bytes), and time of last modification for each file. If the file is a special file, the size field will instead contain the major and minor device numbers. This option can also be invoked by entering the if (type "if"). -m Uses stream output format (a comma-separated series). -n Displays the same information as with -l, except that it displays the user and the group IDs instead of the user and group names. -N Symbolic links are not followed when determining the status of a file. Using this flag with other flags gives the user BSD semantics for symbolic links. -o Displays the same information as with -l, except for the group. Processed November 8, 1990 LS, LF, LR(1,C) 4 LS, LF, LR(1,C) AIX Commands Reference LS, LF, LR(1,C) -p Puts a slash after each file name if that file is a directory. This is useful when you pipe the output of ls to the pr command as follows: ls -p | pr -5 -t -w80 -q Displays nonprintable characters in file names as the character ?. -r Reverses the order of the sort, giving reverse alphabetic or the oldest first, as appropriate. -R Lists all subdirectories recursively. This option can also be invoked by entering the lr command. -s Gives size in kilobytes (including indirect blocks) for each entry. -S Include in the list the site name of the current synchronization site (CSS) for the file being displayed. -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 flag has no effect when not used with either -t or -l or both. -v Specifies the version of the file (count of the number of times the file has been updated). Must be used with the -l option. -x Sorts output horizontally in a multi-column format. -z Include an octal representation of the replicated storage mask (fstore value) in the listing of the file being displayed. To have this information displayed in a symbolic form, use the where command. -1 Forces one entry per line output format; this is the default when output is not to a terminal. EXAMPLES 1. To list all files in the current directory: ls -a This lists all files, including . (dot), .. (dot-dot), and other files with names beginning with a dot. 2. To display detailed information: ls -l chap1 .profile This displays a long listing with detailed information about "chap1" and .profile. Processed November 8, 1990 LS, LF, LR(1,C) 5 LS, LF, LR(1,C) AIX Commands Reference LS, LF, LR(1,C) 3. To display detailed information about a directory: 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 flag, this would list the files in "." and "manual" instead of the detailed information about the directories themselves. 4. To list the files in order of modification time: ls -l -t This displays a long listing of the files that were modified most recently, followed by the older files. FILES /etc/passwd Contains user IDs. /etc/group Contains group IDs. /usr/lib/terminfo/* Contains terminal information. RELATED INFORMATION See the following commands: "chmod," "ctab," "find," and "where." See the environment miscellaneous facility in AIX Operating System Technical Reference. See "Overview of International Character Support" in Managing the AIX Operating System. Processed November 8, 1990 LS, LF, LR(1,C) 6