File Operations

ls

List directory contents showing file names, permissions, sizes, and timestamps.

Synopsis

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

Examples

List all files including hidden in long format
ls -la
List /var/log sorted by size descending, human-readable
ls -lhS /var/log
Color-coded list sorted by modification time
ls -lt --color=auto
List only directories in current path
ls -d */

Common options

FlagDescription
-lLong listing format
-aInclude hidden entries starting with .
-hHuman-readable sizes (K, M, G)
-RList subdirectories recursively
-tSort by modification time, newest first

About ls

The `ls` command list directory contents showing file names, permissions, sizes, and timestamps. File operation commands are essential for navigating and managing the Linux filesystem.

They form the backbone of everyday system administration and development workflows. Mastering these commands enables you to efficiently create, move, copy, and organize files and directories from the terminal, which is often faster and more scriptable than graphical alternatives.

The command accepts 5 commonly used flags shown above, though the full set of options is available in the man page (`man ls`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More File Operations Commands

Other commands in the File Operations category

Related tools