ls(C) 19 June 1992 ls(C) Name l, lc, lf, lr, ls, lx - list contents of directories Syntax l [ -ACFLRabcdfginopqrstu ] [ directory | file ... ] lc [ -1AFLRabcdfgilmnopqrstux ] [ directory | file ... ] lf [ -1ALRabcdfgilmnopqrstux ] [ directory | file ... ] lr [ -1AFLabcdfgilmnopqrstux ] [ directory | file ... ] ls [ -ACFLRabcdfgilmnopqrstux ] [ directory | file ... ] lx [ -1ACFLRabcdfgilmnopqrstu ] [ directory | file ... ] Description l, lc, lf, lr, ls, and lx make up the ls family of commands. For each directory, the contents are listed. For each file, the filename is repeated and any other requested information is displayed. By default, the output is sorted alphabetically. When no argument is given, the current directory is listed. When several arguments are given, they are sorted appropriately; file arguments are processed before directories and their contents. lc lists files in columns by default. lf lists files, indicating directories, executables, and symbolic links. lf is a variant of lc, so files are listed in columns by default. l provides a long listing, one file per line, by default. lr lists files, recursively listing any subdirectories encountered. lr is a variant of lc, so files are listed in columns by default. ls lists files alphabetically, one entry per line, by default. lx, another variant of lc, lists files in columns, but sorted across the page rather than down the page. You can also list files in stream (across the page) output format, separated by commas, using ls -m. ls determines the output format for the -C (lc), -x (lx), and -m options by using an environment variable, COLUMNS, to determine the number of character positions available on one output line. If this variable is not set, the termcap 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. Options are: -1 Forces an output format with one entry per line, for lc, lf, lr, and lx. -A Lists all entries. Entries whose name begin with a dot (.) are listed. Does not list current directory ``.'' and directory above ``..''. -C Lists in columns with entries sorted down the columns. If the argument(s) are filename(s), output is across the page, rather than down the page in columns. -F Causes directories to be marked with a trailing ``/'', executable files to be marked with a trailing ``*'', and symbolic links to be marked with a trailing ``@'' symbol. -L If an argument is a symbolic link, list the information for the file or directory the link references. -R Recursively lists subdirectories. -a Lists all entries; ``.'' and ``..'' are not suppressed. -b Forces printing of non-graphic characters in the \ddd notation, in octal. -c Uses time of last modification of the inode (file created, mode changed, etc.) for sorting; use with -t option. -d If an argument is a directory, lists only its name (not its con- tents); often used with -l to get the status of a directory. -f Forces each argument to be interpreted as a directory and lists the name found in each slot. This option turns off -l, -t, -s, and -r, and turns on -a. The order is the order in which entries appear in the directory. -g The same as -l, except that the owner is not printed. -i For each file, prints the inode number in the first column of the report. -l Lists in long format, giving mode, number of links, owner, group, size in bytes, and time of last modification for each file. If the file is a symbolic link, the filename is printed followed by ``->'' and the pathname of the referenced file. If the file is a special file, the size field will contain the major and minor device num- bers, rather than a size. A total count of blocks in the directory, including indirect blocks, is printed at the top of long format listings. A description of the mode listing follows below. -m Forces stream output format; files are listed across the page, separated by commas. -n The same as -l, except that the user ID (UID) and group ID (GID) numbers are printed, rather than the owner name and the group name. -o The same as -l, except that the group is not printed. -p Puts a slash (/) after each directory. -q Forces printing of non-graphic characters in filenames as the char- acter ``?''. -r Reverses the order of sort to get reverse alphabetic or oldest first, as appropriate. -s Gives size in 512-byte blocks, including indirect blocks, for each entry. -t Sorts by time modified (latest first) instead of by name. -u Uses time of last access instead of time of last modification for sorting; use with the -t option. -x Lists in columns with entries sorted across, rather than down, the page. If the argument(s) are filename(s), output is across the page, rather than down the page in columns. The mode printed under the -l option (long listing, l) consists of 10 characters. The first character is: - If the entry is an ordinary file. d If the entry is a directory. l If the entry is a symbolic link. b If the entry is a block special file. c If the entry is a character special file. p If the entry is a named pipe. s If the entry is a semaphore. m If the entry is a shared data (memory) file. The next 9 characters are the permissions, which control who can access the file. Permissions are in 3 sets of 3 bits each. The first set refers to the owner permissions; the second set to the group permis- sions; and the third set to permissions for all others. Within each set, the three characters indicate permission to read, to write, or to execute the file, respectively. The permissions are as follows: r Read. w Write. x Execute; on a directory, this gives search permission. s Setuid, setgid: set the UID or GID of the executing process to that of the file when the file is executed. S Setuid/setgid is set, but the underlying execute permission is not set. t On an executable file: the binary image of the file will remain in memory after the first time it is used. On a directory: files in the directory can only be removed by their owners, or by root. T The sticky bit (t bit) is set, but the underlying execute permission is not set. - No permission is set. See chmod(C) for more information about permissions. Files /etc/passwd where user IDs are found /etc/group where group IDs are found /etc/termcap where terminal information is found See also chmod(C), coltbl(M), find(C), l(C), lc(C), locale(M), termcap(F) Credit lc and its variants were developed at the University of California at Berkeley; they are used with permission. Notes ls sorts according to the collating sequence defined by the locale. New line and tab are considered printing characters in filenames. Unprintable characters in filenames may confuse the columnar output options. ls -s interprets one 1024-byte block (a standard SCO UNIX block) as two of its own 512-byte blocks. Thus a 500-byte file is interpreted as two blocks rather than one. Standards conformance ls is conformant with: AT&T SVID Issue 2; and X/Open Portability Guide, Issue 3, 1989.