Basics

Linux ls command

List files and folders. Add flags to show hidden files and details.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

ls [OPTION]... [FILE]...

Examples

Show hidden entries and readable file sizes in long format.

ls -lah /var/log

Sort by newest modification time using an ISO-like date format.

ls -lt --time-style=long-iso

Parameters, options and clauses

Option / clauseDescription
-a, --allInclude names beginning with a dot.
-A, --almost-allInclude hidden names, except . and ...
-lUse a long listing with permissions, owner, size and time.
-h, --human-readableWith -l, show sizes in readable units.
-R, --recursiveList subdirectories recursively.
-tSort by modification time, newest first.
-r, --reverseReverse the selected sort order.
-SSort by file size, largest first.
-d, --directoryList directories themselves, not their contents.
-F, --classifyAppend a type marker such as / to directories.
--color[=WHEN]Control coloured output: always, never or auto.
--time-style=STYLEChoose the timestamp format in long listings.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory