ls
— list
directory contents
ls |
[-giklnoqrs ] [-A |
-a ] [-1 |
-C | -m |
-x ] [-F |
-p ] [-H |
-L ] [-R |
-d ] [-S |
-f | -t ]
[-c | -u ]
[file ...] |
The
ls
utility writes each given file, and the contents
of each given directory to the standard output. If no
file is given the contents of the current directory are
written on the standard output.
-1
- Output one entry per-line.
-A
- List all entries except for ‘.’ and ‘..’.
-a
- List entries whose name begin with a dot (‘.’), along with
the default output.
-C
- Output multi-column entries sorted down the columns.
-c
- Use time file's status was last changed for sorting or writing.
-d
- Treat directories as plain files.
-F
- Append a file type indicator to all special files.
-f
- Do not sort. This option implies
-a
.
-g
- Supress owner name. This option implies
-l
.
-H
- Follow symbolic links on the command line.
-i
- Write the inode number of each file.
-k
- Set the block size to 1024 bytes.
-L
- Follow all symbolic links.
-l
- Output entries in long format.
-m
- Output entries across the page, separated by commas.
-n
- Write user and group IDs in a numeric format. This option implies
-l
.
-o
- Supress group. This option implies
-l
.
-p
- Append a file type indicator to directories.
-q
- Replace non-printable characters in filename with ‘?’.
-R
- Descend recursively through its directories arguments.
-r
- Reverse the sort order.
-S
- Sort files by size, in decreasing order.
-s
- Write the number of file system blocks actually used by each file.
-t
- Use file's last modification time for sorting or writing.
-u
- Use file's last access time for sorting or writing.
-x
- Output multi-column entries sorted across the page.
The long format consists of the entry type, permissions, links,
owner, group, size or major and minor numbers if the file is a
character/block device, and last file modification time.
The mode field consists of eleven characters. The first character
describes the type entry:
- -
- Regular file.
- b
- Block special file.
- c
- Character special file.
- d
- Directory.
- l
- Symbolic link.
- p
- FIFO
The last nine characters are interpreted as three sets of three
bits each. The first set refers to the owner permissions; the next to group
permissions; and the last to others permissions. Within each set, the three
characters indicate permission to read, to write, and to execute,
respectively. The permissions are indicated as follow:
- -
- The indicated permission is not granted.
- r
- The file is readable.
- S
- The set-user-ID or set-group-ID is on, and execution is off.
- s
- The set-user-ID or set-group-ID is on, and execution is on.
- T
- The sticky bit is set, and execution is off.
- t
- The sticky bit is set, and execution is on.
- w
- The file is writable.
- x
- The file is executable.
COLUMNS
- Output is formatted to the given width in columns. Otherwise,
ls
defaults to 80 columns.
The ls
utility exits 0 on success,
and >0 if an error occurs.
The ls
utility is compliant with the
specification.