ls(1) ls(1)
NAME
ls, lc - list contents of directory
SYNOPSIS
ls [option ...] [file ...]
/sbin/lc [option ...] [file ...]
DESCRIPTION
ls is used to obtain detailed information on files and directories.
The type, scope and output format of the displayed information can be
specified by setting various options.
The lc command corresponds to ls -Cm (see OPTIONS); though all other
options can also be specified.
OPTIONS
No argument specified:
ls lists the names of files and directories in the current work-
ing directory. The output is sorted in alphabetical order.
No option specified:
file is a directory:
ls lists the names of the files and directories in it. The output
is sorted in alphabetical order. The only files not listed are
those which begin with a dot, such as .profile. The output for ls
is divided into a number of columns for terminals (as described
for -C), otherwise it is in a single column.
file is a file:
ls displays the name of the file. You can use a partially quali-
fied file name. If an asterisk (*) is specified for file, all
files and directories (and their contents) are listed.
-a Lists all file names, including those that begin with a dot.
-b Non-printing characters in file names are represented in the
octal notation \ddd, where ddd is the octal value of the charac-
ter.
-c Together with the -l option:
Lists time of last modification of the inode (file created, mode
change, etc.) instead of the time at which the file was last
modified.
Together with the -t option:
ls uses the time of last modification of the inode as the sort
criterion instead of the time of last modification of the file.
Page 1 Reliant UNIX 5.44 Printed 11/98
ls(1) ls(1)
The -c and -u options are conflicting. If a number of these
options are specified, the last option specified determines the
output format.
-C Multi-column output with entries sorted down the columns in
alphabetical order.
ls uses the COLUMNS environment variable to determine the number
of character positions per line. If this variable is not set, the
value of the TERM environment variable is checked in the terminfo
database in order to determine the number of columns. If this
information cannot be obtained, 80 characters per line are
assumed.
The -C and -l or -1 options are conflicting. If a number of these
options are specified, the last option specified determines the
output format.
-d If file is a directory, ls lists its name (not its contents).
This option is often used together with -l in order to obtain
information on the status of the directory. If file is omitted,
ls outputs a period for the current directory.
When the Veritas File System (VxFS) is installed on the system, the
following additional option is available:
-e When used with -l, displays extent attribute information for
files with reserved space or fixed extent sizes. The extent
attribute information appears as follows:
:res 36 ext 3 align noextend
This output line indicates a file with 36 blocks of reservation,
a fixed extent size of 3 blocks, all extents aligned to 3 block
boundaries, and the file unable to be grown once the current
reservation is exhausted.
-f Forces each argument to be interpreted as a directory and lists
the entries of each directory in the order in which they appear.
If no argument is specified, the entries in the current directory
are listed. This option turns on the -a option and turns off the
-l, -t, -F, -s, and -r options.
-F Puts a slash (/) after each file name if the file is a directory,
an asterisk (*) if the file is declared as an executable, a com-
mercial at symbol (@) if the file is a symbolic link, and a pipe
symbol (|) if the file is a FIFO file.
-g Has the same effect as -l, except that the owner is not printed.
-i Prints the unique identification number (inode number) for each
file in the first column of the report.
Page 2 Reliant UNIX 5.44 Printed 11/98
ls(1) ls(1)
-l A list of detailed information is provided in long format for
each file.
This information is displayed as shown below:
-rwxrwxrwx n name group nnnn Mon nn nn:nn file
|| | | | | | | | |
|| | | | | | | | File name
|| | | | | | | |
|| | | | | | | Time
|| | | | | | |
|| | | | | | Day
|| | | | | |
|| | | | | Month
|| | | | |
|| | | | Size in bytes
|| | | |
|| | | Group name
|| | |
|| | Login of owner
|| |
|| Number of links
||
|Access permissions
|
Type of file
Whereby:
Type of file
d for a directory
l for a symbolic link
b for a block special file
c for a character special file
m XENIX for a shared data (memory) file
p for a FIFO file (named pipe)
s XENIX for a semaphore
- for an ordinary file
Page 3 Reliant UNIX 5.44 Printed 11/98
ls(1) ls(1)
Access permissions
3 sets of 3 characters each provide information on the permis-
sions of
- the file owner (characters 1 to 3),
- users belonging to the same group (characters 4 to 6),
- other users (characters 7 to 9).
Each set uses the following codes:
Position 1: r for read permission or - for no read permission.
Position 2: w for write permission or - for no write permission.
Position 3: x for execute permission for directories
s for execute permission with s bit set
t for execute permission with t bit (sticky bit)
set
T for no execute permission with t bit (sticky
bit) set
S for the l bit (set-user-ID bit set, execute
permission not set)
- for no execute permission with no special bit
set
If the s bit (set-user-ID mode) is set for the owner or the group
and the corresponding x bit (execute permission) is also set, the
x will be replaced by an s. The s bit cannot be set without the
corresponding x bit.
In the case of group permissions, an S may occupy the position of
the x bit if the l bit is set for the file, i.e. if mandatory
locking has been enabled for the file. Neither the x bit nor the
s bit can be set for the group in this case.
If the l bit is set for a file, a program using the lockf() func-
tion can lock read and write access to the file for as long as it
is accessing that file [see chmod(1)].
For others permissions, the position of the x bit may be occupied
by a t or T. These refer to the state of the sticky bit (t bit):
t stands for set sticky bit with x bit, T for set sticky bit
without x bit [see chmod(1)].
Number of links
Decimal number indicating the number of links to the file; at
least 1.
Page 4 Reliant UNIX 5.44 Printed 11/98
ls(1) ls(1)
Login of owner
Login name of the file owner.
Group name
Group name of the file owner. Note: The name is not output after
the tenth character.
Size in bytes
Decimal number that indicates the file size in bytes.
If a special file is listed, the major device number and the
minor device number are displayed instead of the file size.
Month, Day, Time
Indicates the date and time of the last modification to the file.
If the last modification was made more than six months ago, the
year is output instead of the time.
File name
Name of the file.
In the case of directories, the size of the entire directory is
displayed in addition to the individual file sizes. This size is
specified in 512-byte blocks (see Example 4).
If the file or directory is a symbolic link, the file name is
printed followed by an arrow -> and the pathname of the refer-
enced file.
The -l and -C, -m or -x options are conflicting. If a number of
these options are specified, the last option specified determines
the output format.
-L With symbolic links, the link name is listed rather than the name
of the original file or directory.
Example:
$ ls -l
-rw------- 1 hugo other 7593 Nov 30 10:48 file
-rw------- 1 hugo other 3 Dec 17 10:53 linker -> file
$ ls -lL
-rw------- 1 hugo other 7593 Nov 30 10:48 file
-rw------- 1 hugo other 7593 Nov 30 10:48 linker
Page 5 Reliant UNIX 5.44 Printed 11/98
ls(1) ls(1)
-m Lists files across the page (stream output format), separated by
commas. ls uses the COLUMNS environment variable to determine the
number of character positions per line. If this variable is not
set, the value of the TERM environment variable is checked in the
terminfo database in order to determine the number of columns. If
this information cannot be obtained, 80 columns are assumed per
line.
The -m and -l options are conflicting. If a number of these
options are specified, the last option specified determines the
output format.
-n Same effect as -l, except that the user ID and the group ID are
displayed instead of the login and group names.
-o same effect as -l, except that the group is not displayed.
-p Puts a slash (/) after each file name if the file is a directory.
-q Non-printing characters in file names are represented by question
marks.
-r Reverses the sorting order.
-R If file is not specified:
All files and directories in the current directory are listed,
followed by a recursive listing of all subdirectories and the
files contained in them.
If file is specified (must be a directory):
All files and subdirectories of the specified directory are
listed recursively.
-s Prints the size of each file in column 1 (in 512-byte blocks) in
addition to the file names.
-t Sorts by time last modified instead of by file name (latest first).
-u Together with the -t option:
Uses the time of last access as the sort criterion.
Together with the -l option:
Displays the time of last access instead of the time of last
modification.
The -u and -c options are conflicting. If a number of these
options are specified, the last option specified determines the
output format.
Page 6 Reliant UNIX 5.44 Printed 11/98
ls(1) ls(1)
-x Multi-column output with entries sorted across instead of down
the page. ls uses the COLUMNS environment variable to determine
the number of character positions per line. If this variable is
not set, the value of the TERM environment variable is checked in
the terminfo database in order to determine the number of
columns. If this information cannot be obtained, 80 characters
per line are assumed.
The -x and -l options are conflicting. If a number of these
options are specified, the last option specified determines the
output format.
-1 Prints only one entry per line of output.
The -1 and -C options are conflicting. If a number of these
options are specified, the last option specified determines the
output format.
-- End of the list of options. All arguments after this character
are interpreted as filenames, even if they begin with -.
file Name of the file or directory for which you want information to
be listed. You can also name more than one file or directory.
file not specified:
The contents of the current directory will be listed.
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed.
LCCOLLATE governs the collating sequence of the output from ls,
LCCTYPE determines which characters are defined as non-printing char-
acters in conjunction with the -q option, and LCTIME governs the for-
mat and content of date and time strings when the -g, -l, -n, and -o
options are used.
If LCMESSAGES, LCCOLLATE, LCCTYPE or LCTIME is undefined or is
defined as the null string, it defaults to the value of LANG. If LANG
is likewise undefined or null, the system acts as if it were not
internationalized. If any of the locale variables has an invalid
value, the system acts as if none of the variables was set.
The LCALL environment variable governs the entire locale. LCALL
takes precedence over all the other environment variables which affect
internationalization.
Page 7 Reliant UNIX 5.44 Printed 11/98
ls(1) ls(1)
EXAMPLES
Example 1
Listing the contents of the current directory in long format. User's
login name: hugo
$ ls -l
total 142
drwx--x--x 2 hugo other 48 Dec 1 16:13 ADDRESSES
-rw------- 1 hugo other 356 Dec 17 13:58 carda
-rw------- 1 hugo other 24802 Dec 1 12:13 cardb
-rw------- 1 hugo other 7890 Nov 30 10:48 cardc
-rwx--xr-x 1 hugo other 7253 Dec 21 13:37 cardd
-rw------- 1 hugo other 9476 Dec 21 13:37 carde
-rwx--x--x 1 hugo other 0 Dec 18 13:16 cardf
-rw------- 1 hugo other 593 Nov 30 10:48 letter1
-rw------- 1 hugo other 837 Dec 17 10:53 letter2
-rw------- 1 hugo other 3247 Dec 17 13:46 letter3
-rw------- 1 hugo other 5222 Nov 30 10:48 letter4
-rw-rw-rw- 1 hugo other 4687 Dec 21 11:15 letter5
-rw------- 1 hugo other 228 Nov 30 10:48 letter6
-r-------- 1 hugo other 105 Dec 21 13:39 typescript
Example 2
Multi-column output of the current directory using a line width of 80
columns per line.
$ ls -C
ADDRESSES cardc cardf letter3 letter6
carda cardd letter1 letter4 typescript
cardb carde letter2 letter5
Example 3
Multi-column output after defining the line width as 40 columns per
line.
$ COLUMNS=40
$ export COLUMNS
$ ls -C
ADDRESSES carde letter4
carda cardf letter5
cardb letter1 letter6
cardc letter2 typescript
cardd letter3
Page 8 Reliant UNIX 5.44 Printed 11/98
ls(1) ls(1)
Example 4
Listing the current directory in long format (option -l), marking
directories (-p option) and including all files that begin with a
period (-a option). User's login name: sisyphus.
$ ls -pla
total 120
drwxr-xr-x 10 sisyphus other 5720 Nov 17 08:00 ./
drwxr-xr-x 13 root root 3380 Nov 04 11:48 ../
-rw------- 1 sisyphus other 79 Jul 19 14:21 .profile
-rw------- 1 sisyphus other 14 Oct 21 08:56 .rhosts
-rwx------ 1 sisyphus other 125 May 25 10:29 begin
drwx--x--x 2 sisyphus other 3380 Nov 09 10:30 commands/
drwx------ 2 sisyphus other 1820 Oct 11 15:35 letters/
drwxr----- 3 sisyphus other 2340 Oct 11 15:35 lingua/
-rw------- 1 sisyphus other 2082 Nov 08 12:29 ls.ex
-rw------- 1 sisyphus other 11597 Nov 17 07:59 ls.rc.1
-rw------- 1 sisyphus other 1351 Jul 19 15:14 plural
drwx------ 2 sisyphus other 3380 Oct 11 15:36 post/
drwx------ 2 sisyphus other 1560 Oct 11 15:36 pro/
drwx--x--x 2 sisyphus other 2080 Nov 07 10:43 proc/
drwx------ 2 sisyphus other 1560 Oct 11 15:36 screens/
drwx--x--x 2 sisyphus other 1040 Nov 15 08:23 sdg/
Example 5
List all files and directories (and their contents). Each directory
name is followed by a colon.
$ ls -C *
Mailboxes authors bvp.col
lingua:
car.cdr engl.ger examples terms
screens:
out pause sinix
FILES
/etc/passwd
Contains all the login names that have been set up.
/etc/group
Contains all the groups that have been set up.
SEE ALSO
chmod(1), find(1), ln(1).
Page 9 Reliant UNIX 5.44 Printed 11/98