LS(1) SysV LS(1)
NAME
ls - list contents of directory
SYNOPSIS
ls [ -RSadCxmlnogrtucpFbqisfT ] [ names ]
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. By default, it sorts the output alphabetically. If you
specify no argument, ls lists the current directory. If you give several
arguments, ls first sorts the arguments appropriately, but prints file
arguments before directories and their contents.
ls produces lists in three major formats. By default, it lists one entry
per line. It can also generate a multi-column format, as well as stream
output format in which files are listed across the page, separated by
commas.
NOTE: Be aware that Domain/OS block device numbers are reported as a
concatenation of the device number and node ID. Additionally, the
node ID has been left shifted and reported in decimal.
OPTIONS
-R Recursively list subdirectories encountered. This option
follows soft links unless the -S option is also used.
-S Shows link text rather than the object to which the link has
been made.
-a List all entries. Usually, entries whose names begin with a
period (.) are not listed.
-d If an argument is a directory, list only its name (not its
contents). Often used with -l to get the status of a
directory.
-C Produce multi-column output with entries sorted down the
columns.
-x Produce multi-column output with entries sorted across rather
than down the page. (-S is ignored.)
-m Produce stream output format.
-l List 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 special file, the size field contains
the major and minor device numbers, rather than a size. The
mode printed under the -l option consists of 10 characters,
interpreted as follows:
The first character is:
d Directory
b Block special file
c Character special file
p Fifo (also called a "named pipe") special file
- Ordinary 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 of others in the user group of the
file; and the last to all others. Within each set, the three
characters indicate permission to read, to write, and to
execute the file as a program, respectively. For a directory,
execute permission is interpreted as permission to search the
directory for a specified file.
NOTE:
Be aware that Domain/OS block device numbers are reported
as a concatenation of the device number and node ID.
Additionally, the node ID has been left shifted and
reported in decimal.
The permissions are indicated as follows:
r File is readable
w File is writable
x File is executable
- Indicated permission is not Granted
l Mandatory locking will occur during access (the set-group-
ID bit is on and the group execution bit is off)
s The set-user-ID or set-group-ID bit is on, and the
corresponding user or group execution bit is also on
S Undefined bit-state (the set-user-ID bit is on and the user
execution bit is off)
t The 1000 (octal) bit, or sticky bit, is on (see chmod(1)),
and execution is on
T The 1000 bit is turned on, and execution is off (undefined
bit-state)
For user and group permissions, the third position (the execute
permission) is sometimes occupied by a character other than x or -. An s
or S may occupy this position, indicating the state of the set-user-ID or
set-group-ID bit. The ability to assume the same ID as the user during
execution is, for example, used during login when you begin as root but
need to assume the identity of the user stated at "login." The group
execute permission may be given as l, indicating that mandatory file and
record locking will occur. This permission describes a file's ability to
allow other files to lock its reading or writing permissions during
access. For others permissions, the third position may be occupied by t
or T, indicating the state of the sticky bit and execution permissions.
-n Same as -l, except that the owner's UID and group's GID numbers
are printed, rather than the associated character strings.
-o Same as -l, except that the group is not printed.
-g Same as -l, except that the owner is not printed.
-r Reverse the order of sort to get reverse alphabetic or oldest
first as appropriate.
-t Sort by time modified (latest first) instead of by name.
-u Use time of last access instead of last modification for
sorting (with the -t option) or printing (with the -l option).
-c Use time of last modification of the i-node (file created, mode
changed, etc.) for sorting (-t) or printing (-l).
-p Put a slash ( / ) after each filename if that file is a
directory.
-F Put a slash ( / ) after each filename if that file is a
directory and put an asterisk (*) after each filename if that
file is executable. If used with -S, softlinks will appear
with an @ symbol.
-b Force nongraphic characters to be printed in the octal \ddd
notation.
-q Force nongraphic characters in filenames to be printed as
question marks (?).
-i For each file, print the i-number in the first column of the
report.
-s Give size in blocks, including indirect blocks, for each entry.
Block size is considered to be 512. Print a total count of
blocks when the sizes of the files in a directory are listed.
-f Force each argument to be interpreted as a directory and list
the name found in each slot. Turn off -l, -t, -s, and -r, and
turn on -a; the order is the order in which entries appear in
the directory.
-T Used with the -l option, -T shows the "Apollo type" of each
file.
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 first set of examples refers to permissions.
To describe a file that is readable, writable, and executable by the user
and readable by the group and others:
-rwxr--r--
To describe a file that is readable, writable, and executable by the
user, readable and executable by the group and others, and allows its
user-ID to be assumed, during execution, by the user presently executing
it:
-rwsr-xr-x
To describe a file that is readable and writable only by the user and the
group and can be locked during access:
-rw-rwl---
The following examples describe the output from ls.
ls -l
(the long list) prints its output as follows:
-rwxrwxrwx 1 smith dev 10876 May 16 9:42 part2
Reading from right to left, you see that the current directory holds one
file, named "part2". Next, the last time that file's contents were
modified was 9:42 A.M. on May 16. The file is moderately sized,
containing 10,876 characters, or bytes. The owner of the file, or the
user, belongs to the group "dev" (perhaps indicating development), and
his or her login name is "smith." The number, in this case "1," indicates
the number of links to file "part2". Finally, the row of letters
beginning with a dash (-) tells you that user, group, and others have
permissions to read, write, execute "part2." The execute (x) symbol here
occupies the third position of the three-character sequence. A - in the
third position would have indicated a denial of execution permissions.
ls -aisn
prints its output as follows:
923765600 16 -rwxrwxrwx 1 20123 38 16329 Sep 3 14:34 part3
This command lists all entries (a), including those whose names begin
with a period (.). The output shows the i-number (the memory address of
the i-node associated with the file) printed in the left-hand column (i);
the size (in blocks) of the files, printed in the column to the right of
the i-numbers (s); finally, the report is displayed in the numeric
version of the long list, printing the UID (instead of user name) and GID
(instead of group name) numbers associated with the files.
NOTES
In a Remote File Sharing environment, you may not have the permissions
that the output of the ls -l command leads you to believe.
To set the date format, see ctime(3C), cftime(4), and environ(5).
BUGS
Unprintable characters in filenames may confuse the columnar output
options.
FILES
/etc/passwd To get user IDs for ls -l and ls -o
/etc/group To get group IDs for ls -l and ls -g
/usr/lib/cftime/* User-settable date format
/usr/lib/terminfo/?/*
To get terminal information
SEE ALSO
chmod (1), find (1).