Linux - ls command in Linux
The ls
command in Linux is one of the most fundamental and frequently used commands. It stands for "list" and is used to display the contents of a directory.
What Does ls
Do?
When you type ls
in the terminal and press Enter, it shows the names of files and folders in your current working directory.
Basic Syntax
ls [options] [file/directory]
Commonly Used ls
Options
Option | Description |
---|---|
ls |
Lists files and directories in the current folder |
ls -l |
Long format: shows permissions, owner, size, and date modified |
ls -a |
Includes hidden files (those starting with . ) |
ls -h |
Human-readable file sizes (e.g., 1K, 234M) |
ls -t |
Sorts by modification time (newest first) |
ls -r |
Reverses the order of the listing |
ls -S |
Sorts by file size |
ls -R |
Lists directories recursively |
ls -i |
Shows inode numbers |
ls -d |
Lists directory names only, not their contents |
Visual Example
Here’s what ls -l
output might look like:
-rw-r--r-- 1 user group 1024 Aug 15 10:00 report.txt
drwxr-xr-x 2 user group 4096 Aug 14 09:30 documents/
Breakdown:
-rw-r--r--
: File permissions1
: Number of linksuser
: Ownergroup
: Group1024
: File size in bytesAug 15 10:00
: Last modified datereport.txt
: File name
Try It Yourself
ls -lh
This will list files with human-readable sizes.
ls -la
This will show all files, including hidden ones, in long format.