index.txt
LS(1) General Commands Manual LS(1) NAME ls - list contents of directory SYNOPSIS ls [ -abcdfilqrstu1CFLR ] name ... DESCRIPTION For each directory argument, ls lists the contents of the directory; for each file argument, 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 argu‐ ments are given, the arguments are first sorted appropriately, but file arguments appear before directories and their contents. Output to a terminal is normally listed in multiple columns. If the standard output is not a terminal, the default format is to list one entry per line. There are an unbelievable number of options: -l List in long format, giving mode (see below), number of links, owner, group, size in bytes, and time of last modification for each file. Symbolic links are identified by a link count marked `L'; the link count is that of the ultimate file. If the file is a special file the size field will instead contain the major and minor device numbers. -t Sort by time modified (latest first) instead of by name, as is normal. -a List all entries; usually `.' and `..' are suppressed. -s Give size in kilobytes (kilo=1024) for each entry. -d If argument is a directory, list its name, not its contents. -r Reverse the order of sort to get reverse alphabetic or oldest first as appropriate. -u Under -t sort by time of last access; under -l give access time. -c Under -t sort by time of inode change; under -l give inode change time. -i Print i-number in first column of the report for each file listed. -L Under -l for each symbolic link give the immediate, not the ul‐ timate, link count and append the name pointed to. -f Force each argument to be interpreted as a directory and list 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. -1 force one entry per line output format, e.g. to a teletype -C force multi-column output, e.g. to a file or a pipe -q force printing of non-graphic characters in file names as the character `?'; this normally happens only if the output device is a teletype -F cause directories to be marked with a trailing `/' and exe‐ cutable files to be marked with a trailing `*' -R recursively list subdirectories encountered. The mode printed under the -l option contains 11 characters which are interpreted as follows: the first character is d if the entry is a directory; b if the entry is a block-type special file; c if the entry is a character-type special file; - if the entry is a plain file. The next 9 characters are interpreted as three sets of three bits each. The first set refers to owner permissions; the next to permissions to others in the same user-group; and the last to all others. Within each set the three characters indicate permission respectively to read, to write, or to execute the file as a program. For a directory, `execute' permission is interpreted to mean permission to search the directory for a specified file. The permissions are indicated as follows: r if the file is readable; w if the file is writable; x if the file is executable; - if the indicated permission is not granted. The group-execute permission character is given as s if the file has set-group-ID mode; likewise the user-execute permission character is given as s if the file has set-user-ID mode. The last character of the mode (normally `x' or `-') is t if the 1000 bit of the mode is on. See chmod(1) for the meaning of this mode. When the sizes of the files in a directory are listed, a total count of blocks is printed. FILES /etc/passwd, /etc/group to get ID's for `ls -l'. BUGS The output device is assumed to be 80 columns wide. The option setting based on whether the output is a teletype is unde‐ sirable as `ls -s' behaves differently from `ls -s | lpr'. On the other hand, not doing this setting would make many shell scripts which use ls almost certain losers. Option -s counts unwritten holes as if they were real data. LS(1)