Online Linux Terminal Logo
OnlineLinuxTerminal
NavigationCLI Reference

$ls

List directory contents including file sizes, permissions, ownership, and modification timestamps.

Syntax DefinitionPOSIX standard
ls [OPTIONS] [FILE|DIRECTORY...]
Linux Community2.4k Online

Chat with real Linux users, learn new commands & get free cheat sheet PDFs.

Try `ls` Live in Interactive Sandbox

Zero-install client simulation with real-time feedback.

Open in Fullscreen Workspace↗
bash — terminal

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 / OptionDescription
-lUse long listing format showing permissions, owner, group, size, and date.
-aShow all files including hidden entries that begin with a period (.).
-hPrint file sizes in human-readable units (e.g., 4K, 25M, 2G) when used with -l.
-tSort files by modification timestamp, newest first.
-RRecursively list all subdirectories and their contents.
-SSort files by file size, largest first.

Practical Real-World Examples

Example #1Detailed human-readable file listing
ls -l -h

Displays detailed metadata with human-readable file sizes.

Sample Output:
-rw-r--r-- 1 user user 482B Aug 28 12:00 welcome.txt -rw-r--r-- 1 user user 1.2K Aug 28 12:05 notes.txt
Example #2List hidden configuration files
ls -a /home/user

Reveals hidden dotfiles such as .bashrc, .profile, and .config.

Sample Output:
. .. .bashrc .profile .config welcome.txt notes.txt

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.