$ls
List directory contents including file sizes, permissions, ownership, and modification timestamps.
ls [OPTIONS] [FILE|DIRECTORY...]Try `ls` Live in Interactive Sandbox
Zero-install client simulation with real-time feedback.
Overview & How ls Works
The `ls` command is the fundamental navigation utility in Linux. It displays the names of files and directories within the current working directory or any specified path. When combined with flags like `-l` (long format) and `-a` (all files), it exposes essential file system metadata including read/write/execute permissions, file owner, group, file byte size, and last modified date.
Common Flags & Command Options
| Flag / Option | Description |
|---|---|
| -l | Use long listing format showing permissions, owner, group, size, and date. |
| -a | Show all files including hidden entries that begin with a period (.). |
| -h | Print file sizes in human-readable units (e.g., 4K, 25M, 2G) when used with -l. |
| -t | Sort files by modification timestamp, newest first. |
| -R | Recursively list all subdirectories and their contents. |
| -S | Sort files by file size, largest first. |
Practical Real-World Examples
ls -l -hDisplays detailed metadata with human-readable file sizes.
ls -a /home/userReveals hidden dotfiles such as .bashrc, .profile, and .config.
Frequently Asked Questions
Why do hidden files start with a dot (.) in Linux?
In Unix convention, any file or directory starting with a period is treated as a hidden configuration file by default to keep directory listings clean.
Related Linux Commands
Change the current working directory in the shell workspace.
Print the absolute path of the current working directory.
Change file access permission mode bits for owner, group, and other users.
Locate the executable binary path of a command in system PATH.
Display directory structure in a recursive visual tree diagram.