If no
names
are given, list the files in the current directory.
With one or more
names
, list files contained in a directory
name
or that match a file
name
.
names
can include filename metacharacters. The options let
you display a variety of information in different formats. The most
useful options include
-F
,
-R
,
-l
, and
-s
.
Some options don't make sense together; e.g.,
-u
and
-c
.
-
-a
-
List all files, including the normally hidden
.
files.
-
-b
-
Show nonprinting characters in octal.
-
-c
-
List files by creation/modification time.
-
-C
-
List files in columns (the default format).
-
-d
-
List only the directory name, not its contents.
-
-f
-
Interpret each
name
as a directory (files are ignored).
-
-F
-
Flag filenames by
appending
/
to directories,
*
to executable files,
and @ to symbolic links.
@
to symbolic links, and
=
to sockets.
-
-g
-
Like
-l
, but omit owner name (show
g
roup).
Add group name to
-l
listing.
-
-i
-
List the inode for each file.
-
-l
-
Long format listing (includes permissions, owner, size, modification time,
etc.).
-
-L
-
List the file or directory referenced by a symbolic link rather than
the link itself.
-
-m
-
Merge the list into a comma-separated series of names.
-
-n
-
Like
-l
, but use GID and UID numbers instead of owner and group names.
-
-o
-
Like
-l
, but omit group name (show
o
wner).
-
-p
-
Mark directories by appending
/
to them.
-
-q
-
Show nonprinting characters as
?
.
-
-r
-
List files in reverse order (by name or by time).
-
-R
-
Recursively list subdirectories as well as current directory.
-
-s
-
Print size of the files
in blocks.
in kilobytes.
-
-t
-
List files according to modification time (newest first).
-
-u
-
List files according to the file access time.
-
-x
-
List files in rows going across the screen.
-
-1
-
Print one entry per line of output.
List all files in the current directory and their sizes; use
multiple columns and mark special files:
ls -asCF
List the status of directories
/bin
and
/etc
:
ls -ld /bin /etc
List C source files in the current directory, the oldest first:
ls -rt *.c
Count the files in the current directory:
ls | wc -l