ls

file managementLinux/Unix
The ls command is one of the most frequently used commands in Linux/Unix-like operating systems. ls List directory contents

Quick Reference

Command Name:

ls

Category:

file management

Platform:

Linux/Unix

Basic Usage:

ls -la

Common Use Cases

  • 1

    List files

    View files and directories in the current location

  • 2

    Show hidden files

    Display all files including hidden ones

  • 3

    File permissions

    Check permissions and ownership of files

  • 4

    Sort by size

    List files ordered by size

Syntax

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

Options

Option Description
-l Use a long listing format
-a Show hidden entries starting with .
-h Human-readable sizes
-R List subdirectories recursively

Examples

How to Use These Examples

The examples below show common ways to use the ls command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

# Basic Examples ls
List files in the current directory.
ls -l
List files in long format with details.
ls -a
List all files including hidden ones.
# Advanced Examples Advanced ls -lah Detailed list with human-readable sizes. ls -R List directories recursively.

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

These are sample notes for the ls command.

Tips & Tricks

1

Use ls -lah for a detailed list including hidden files with human-readable sizes

2

Sort files by modification time with ls -lt

3

Use ls -R to recursively list all subdirectories

4

Colorize output with ls --color=auto

5

Use ls -i to show inode numbers which are unique file identifiers

Common Use Cases

List files

View files and directories in the current location

Show hidden files

Display all files including hidden ones

File permissions

Check permissions and ownership of files

Sort by size

List files ordered by size

Check timestamps

View when files were created or modified

Related Commands

cd

cd

View command

pwd

pwd

View command

find

find

View command

tree

tree

View command

dir

dir

View command

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the ls command works in different scenarios.

$ ls
View All Commands