LS(1) BSD LS(1)
NAME
ls - list contents of directory
SYNOPSIS
ls [ -acdfgilqrstu1ACLFRT ] 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 you
request. By default, ls sorts the output alphabetically. If you do not
specify an argument, ls lists the current directory. If you specify
several arguments, ls sorts the arguments appropriately, but processes
file arguments before directories and their contents.
OPTIONS
-l List in long format, giving mode, number of links, owner, size
in bytes, and time of the last modification (see Long List
Format, below.) When ls lists the sizes of the files in a
directory, it prints a total count of blocks, including
indirect blocks. If the file is a special file, the size field
contains the major and minor device numbers instead of the
total number of blocks. If the file is a soft or symbolic
link, ls prints the pathname of the linked-to file, preceded by
"->".
-g Include the group ownership of the file in a long output.
-t Sort by the time modified (most recent first) instead of by
name.
-a List all entries. Without this option, ls doesn't list entries
whose names begin with a period (.).
-s Give the size, in kilobytes, of each file.
-d If the argument is a directory, list only its name. This
option is often used with -l to get the status of a directory.
-L If the argument is a soft or symbolic link, list the file or
directory the link references rather than the link itself.
-r Reverse the sort order to get reverse alphabetic or oldest
first, as appropriate.
-u Use the time of last access instead of last modification for
sorting (with the -t option) and/or printing (with the -l
option).
-c Use the time of file creation for sorting or printing.
-i For each file, print the i-number in the first column of the
report.
-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. It uses the order in which entries
appear in the directory.
-F Mark directories with a trailing slash (/); sockets with a
trailing equal sign (=); soft or symbolic links with a trailing
@; and executable files with a trailing asterisk (*).
-R Recursively list the subdirectories encountered.
-1 Force one-entry-per-line output format. This is the default
when output is not to a terminal.
-C Force multicolumn output. This is the default when output is
to a terminal.
-q Force printing of non-graphic characters in filenames as the
question mark character (?). This is the default when output
is to a terminal.
-T If you specify -T with the -l option, it shows the "Domain/OS
type" of each file.
LONG LIST FORMAT
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
l if the entry is a symbolic link
s if the entry is a socket
- if the entry is a plain file
The next nine characters are interpreted as three sets of three bits
each. The first set refers to the owner's permissions; the next to
permissions to others in the same user-group; the last to all others.
Within each set, the three characters indicate permission to read, write,
or execute the file as a program, respectively. Execute permission in a
directory is interpreted as permission to search the directory. 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.
ls indicates the group-execute permission character as s if the file has
the set-group-ID bit set. Likewise,it indicates the user-execute
permission character as s if the file has the set-user-ID bit set.
The last character of the mode (normally x or -) is t if the 1000 (octal)
bit of the mode is on. See chmod(1) for the meaning of this mode.
If an object is protected by an extended access control list (ACL), ls -l
displays a plus sign (+) following the standard protections. Use the
lsacl(1) command to list the extended ACL on a file.
EXAMPLES
The following examples show output from ls -l
% ls -lL /tmp
total 9
-rwxrwxrwx+ 1 brian 12636 Mar 30 15:20 alarm_server.msg_mbx
-rw-rw-rwx+ 1 brian 245 Mar 30 15:18 bar
srw------- 1 brian 0 Mar 30 15:18 df136.cmd
srw------- 1 brian 0 Mar 30 15:18 df136.rpy
-rw-rw-rwx+ 1 brian 128 Mar 30 15:18 foo
-rw-rw-rw- 1 root 144 Mar 30 11:06 llb-faerie
-rw------- 1 brian 483 Mar 30 12:49 mhmaila00546
-rwxrwxr-x 1 brian 1024 Mar 30 12:48 pi_hint
The files alarm_server.msg_mbx, bar, and foo, are protected by extended
ACLs.
The following output from ls -l shows a single object, named new.
% ls -l
total 97
-rw-rw-r-- 1 brian 3413 Jan 27 10:01 new
Reading from left to right, you see that the first character is a dash
(-) indicating that new is a file. The permissions rw-rw-r-- indicate
that the file's owner and the group have read and write rights (rw-),
while all others have only read rights (r--). The number 1 in the second
column indicates the number of links to the file. The remaining columns
show that brian is the file's owner, the size is 3413 bytes, it was last
modified on January 27, at 10:01, and finally, the filename is new.
BUGS
Newline and tab are considered printing characters in filenames.
The output device is assumed to be 80 columns wide.
The option setting based on whether the output is a teletype is
undesirable because ls -s is much different than ls -s | lpr. On the
other hand, not doing this setting would make old shell scripts which
used ls almost certain losers.
FILES
/etc/passwd To get user ID's for ls -l.
/etc/group To get group ID's for ls -g.
SEE ALSO
chmod(1), lsacl(1), acl(7)