Linux – ls Command

The ls command in Linux is shorthand for “list.” It is used to list the contents of directories. The ls command provides various options to display files and directories in different formats and orders.



Tutorials dojo strip

Initial Example

Using ls without any options lists the files and directories in the current directory:

ls




LS Parameters

ParameterDescription
-a, --allShow all files, including hidden files starting with .
-A, --almost-allShow all files except . and ..
--authorWith -l, display the author of each file
-b, --escapePrint C-style escapes for non-printable characters
--block-size=SIZEDisplay file sizes scaled by SIZE (e.g., --block-size=M)
-B, --ignore-backupsDo not list backup files ending with ~
-cSort by and display ctime (last status change time) with -lt or -l
-CList entries by columns
--color[=WHEN]Colorize the output; WHEN can be always, auto, or never
-d, --directoryList directories themselves, not their contents
-D, --diredGenerate output for Emacs’ dired mode
-fDo not sort, enable -aU, disable -ls --color
-F, --classify[=WHEN]Append indicator (one of */=>@|) to entries based on their type
--file-typeSame as -F, but do not append * to executable files
--format=WORDSpecify output format (e.g., across, commas, horizontal, long)
--full-timeDisplay full timestamp using -l with ISO format
-gLike -l, but do not list owner
--group-directories-firstGroup directories before files; overrides --sort=none (-U)
-G, --no-groupIn long listing, do not display group names
-h, --human-readableWith -l and -s, print sizes in human-readable format (e.g., 1K, 234M, 2G)
--siSimilar to -h, but use powers of 1000 instead of 1024
-H, --dereference-command-lineFollow symbolic links listed on the command line
--dereference-command-line-symlink-to-dirFollow each command line symbolic link that points to a directory
--hide=PATTERNDo not list implied entries matching the shell PATTERN
--hyperlink[=WHEN]Hyperlink file names WHEN; WHEN can be always, auto, or never
--indicator-style=WORDAppend indicator with style WORD to entry names (none, slash, file-type, classify)
-i, --inodePrint the inode number of each file
-I, --ignore=PATTERNDo not list implied entries matching the shell PATTERN
-k, --kibibytesUse 1024-byte blocks for file system usage; used with -s and per directory totals
-lUse a long listing format
-L, --dereferenceWhen showing file information for a symbolic link, show info for the referenced file
-mFill width with a comma-separated list of entries
-n, --numeric-uid-gidLike -l, but list numeric user and group IDs
-N, --literalPrint entry names without quoting
-oLike -l, but do not list group information
-p, --indicator-style=slashAppend / indicator to directories
-q, --hide-control-charsPrint ? instead of non-printable characters
--show-control-charsShow non-printable characters as-is (default for terminal output)
-Q, --quote-nameEnclose entry names in double quotes
--quoting-style=WORDUse specified quoting style for entry names (e.g., literal, locale, shell, c, escape)
-r, --reverseReverse the order of the sort
-R, --recursiveList subdirectories recursively
-s, --sizePrint the allocated size of each file in blocks
-SSort by file size, largest first
--sort=WORDSort by specified WORD instead of name (e.g., none, size, time, version, extension)
--time=WORDSelect the timestamp to use (e.g., atime, ctime, mtime, birth)
--time-style=TIME_STYLESet the time/date format for -l (e.g., full-iso)
-tSort by modification time, newest first
-T, --tabsize=COLSAssume tab stops at each COLS instead of 8
-uWith -lt, sort by and show access time; with -l, show access time and sort by name
-UDo not sort; list entries in directory order
-vSort numbers naturally within text
-w, --width=COLSSet output width to COLS; 0 means no limit
-xList entries by lines instead of by columns
-XSort alphabetically by file extension
-Z, --contextPrint security context of each file
--zeroEnd each output line with NUL instead of newline
-1List one file per line
--helpDisplay help message and exit
--versionOutput version information and exit




Examples

1. List all files in long-listing format

The -l option displays files in long-listing format, which includes detailed information such as permissions, number of links, owner, group, size, and modification date.

ls -l

2. List all files in reverse sort order of creation time

The -rt options combine to sort files by modification time in reverse order (oldest first).

ls -rt

3. List all files in reverse order and in long-listing format

The -lrt options combine to display files in long-listing format and sort them by modification time in reverse order.

ls -lrt




Linux Playground

Scroll to Top