search
Innovative Web Design and Application Development
PawPrint.net

PawPrint.net Glossary of Terms

Main Menu -> Linux -> ls

ls

list contents
ls [options] [names]

List the contents of a directory or directories. This is similar to the dos command īdirī frequently abbreviated in many shells to ll for ls -l which lists files with long format. If no [names] then the contents of the current directory are listed.

Options
-1, --format=single-column
Print one entry per line of output.

-a
List all files, including the normally hidden files whose names begin with a period.

-b, --escape
Display nonprinting characters in octal and alphabetic format.

-c, --time-ctime, --time=status
List files by status change time (not creation/modification time).

--color, --colour, --color=yes, --colour=yes
Colorize the names of files depending on the type of file.

--color=no, --colour=no
Disables colorization. This is the default. Provided to override a previous color option.

--color=tty, --colour=tty
Same as --color, but only if standard output is a terminal. Very useful for shell scripts and command aliases, especially if your favorite pager does not support color control codes.

-d, --directory
Report only on the directory, not its contents.

-f
Print directory contents in exactly the order in which they are stored, without attempting to sort them.

--full-time
List times in full, rather than use the standard abbreviations.

--help
Print a help message and then exit.

-i, --inode
List the inode for each file.

-k, --kilobytes
If file sizes are being listed, print them in kilobytes. This option overrides the environment variable POSIXLY_CORRECT.

-l, --format=long, --format=verbose
Long format listing (includes permissions, owner, size, modification time, etc.).

-m, --format=commas
Merge the list into a comma-separated series of names.

-n, --numeric-uid-gid
Like -l, but use group-ID and user-ID numbers instead of owner and group names.

-p
Mark directories by appending / to them.

-q, --hide-control-chars
Show nonprinting characters as ? .

-r, --reverse
List files in reverse order (by name or by time).

-s, --size
Print size of the files in blocks.

-t, --sort=time
Sort files according to modification time (newest first).

-u, --time=atime, --time=access, --time=use
Sort files according to the file access time.

--version
Print version information on standard output, then exit.

-x, --format=across, --format=horizontal
List files in rows going across the screen.

-A, --almost-all
List all files, including the normally hidden files whose names begin with a period. Does not include the . and . directories.

-B, --ignore-backups
Do not list files ending in ~, unless given as arguments.

-C, --format=vertical
List files in columns (the default format).

-F, --classify
Flag filenames by appending / to directories, * to executable files, @ to symbolic links, | to FIFOs, and = to sockets.

-G, --no-group
In long format, do not display group name.

-I, --ignore pattern
Do not list files whose names match the shell pattern pattern, unless they are given on the command line.

-L, --dereference
List the file or directory referenced by a symbolic Link rather than the Link itself.

-N, --literal
Do not list filenames.

-Q, --quote-name
Quote filenames with " ; quote nongraphic characters with alphabetic and octal backslash sequences.

-R, --recursive
Recursively list subdirectories as well as the specified (or current) directory.

-S, --sort=size
Sort by file size, largest to smallest.

-T, --tabsize n_cols
Assume that each tabstop is n_cols columns wide. The default is 8.

-U, --sort=none
Do not sort files. Similar to -f but display in long format.

-X, --sort=extension
Sort by file extension.

Examples:

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 nonhidden files in the current directory:
ls | wc -l



Copyright © 1992-2024 PawPrint.net
web development: PawPrint.net