Skip to main content

ls Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for listing files and directories with ls in Linux

The `ls` command lists files and directories in Linux. This cheatsheet covers the most common listing, sorting, filtering, and output-format options you will use in daily terminal work.

Basic Listing

Use these commands for everyday directory listing.

CommandDescription
lsList files in current directory
ls /path/to/dirList files in specific directory
ls -1One entry per line
ls -aInclude hidden files
ls -AInclude hidden files except . and ..

Long Format and Metadata

Show permissions, ownership, size, and timestamps.

CommandDescription
ls -lLong listing format
ls -lhHuman-readable file sizes
ls -laLong format with hidden files
ls -nNumeric UID and GID
ls -liShow inode numbers

Sorting

Sort files by time, size, extension, or version.

CommandDescription
ls -ltSort by modification time (newest first)
ls -ltrSort by modification time (oldest first)
ls -lSSort by file size (largest first)
ls -lXSort by extension
ls -lvNatural sort for version-like names

Time Display

Control which timestamp is shown.

CommandDescription
ls -lt --time=atimeSort/show by access time
ls -lt --time=ctimeSort/show by status change time
ls -l --time-style=long-isoISO-like date format
ls -l --full-timeFull timestamp precision

Directory Views

List directories recursively or show directory entries only.

CommandDescription
ls -la --group-directories-firstLong listing with directories before files
ls -d */List only directories in current path
ls -ld /path/to/dirShow metadata for directory itself
ls -RRecursive listing
ls -laRRecursive long listing with hidden files

Output Formatting

Adjust visual style and indicators.

CommandDescription
ls -FAppend indicator (/, *, @) by file type
ls -pAppend / to directories
ls -mComma-separated output
ls -xList entries across rows instead of down columns
ls --color=autoEnable colorized output when supported

Filtering with Globs

List files that match shell patterns.

CommandDescription
ls *.logList files ending in .log
ls file?.txtMatch single-character wildcard
ls [ab]*.confMatch names starting with a or b
ls -d .[^.]*List hidden files (common shell pattern)

Common Patterns

Frequent command combinations.

CommandDescription
ls -lahMost common detailed listing
ls -lhSLargest files first with readable sizes
ls -latNewest files first including hidden entries
ls -1 | wc -lCount entries in current directory
ls -l | grep '^d'Show only directories from long listing

Troubleshooting

Quick checks for typical listing issues.

IssueCheck
Hidden files not visibleAdd -a or -A
File sizes are hard to readUse -h with -l
Wrong sort orderConfirm flags (-t, -S, -X, -r)
No color outputTry ls --color=auto and check alias settings
Path looks emptyVerify permissions with ls -ld /path

Use these references for deeper file management workflows.

GuideDescription
How to List Files in Linux Using the ls CommandFull ls guide with practical examples
Du Command in LinuxCheck disk usage and file sizes
Linux Commands CheatsheetGeneral command quick reference