Linux Filesystem Cheat Sheet

High-value Linux filesystem commands for navigating, listing, inspecting, copying, moving, linking, and organizing files and directories.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Listing and Inspection

List files, inspect metadata, and understand what is in a directory.

Long listing with human sizes

Show detailed directory contents with human-readable sizes.

bashANYlslistingmetadata
bash
ls -lah

List files sorted by modification time

Show newest files first.

bashANYlssortingtime
bash
ls -lt

Show directory tree to a depth

Visualize nested files and directories.

bashANYtreelistingdirectories
bash
tree -L 2

Show detailed file metadata

Inspect inode, permissions, timestamps, and ownership.

bashANYstatmetadatainode
bash
stat path/to/file

Detect file type

Show MIME-like or content-based type information.

bashANYfiletypeinspection
bash
file path/to/file

Directory Creation and Removal

Create directory trees and remove them safely.

Create nested directories

Create a directory path including missing parents.

bashANYmkdirdirectories
bash
mkdir -p app/data/uploads

Remove empty directory

Delete a directory only if it is empty.

bashANYrmdirdirectories
bash
rmdir empty-dir

Remove directory recursively

Delete a directory and all of its contents.

bashANYrmdirectoriesdanger
bash
rm -rf old-build

Powerful and destructive. Verify the path first.

Copy, Move, Rename

Common file and directory manipulation commands.

Copy directory recursively with preserved metadata

Copy directory trees while preserving timestamps and mode when possible.

bashANYcpcopydirectories
bash
cp -a source-dir target-dir

Copy interactively

Prompt before overwriting an existing file.

bashANYcpsafety
bash
cp -i source.txt dest.txt

Rename file

Rename a file or move it within the same filesystem.

bashANYmvrename
bash
mv old-name.txt new-name.txt

Move directory

Move a directory to a new location.

bashANYmvdirectories
bash
mv logs /var/archive/logs

Install file with mode

Copy a file and set destination permissions in one step.

bashANYinstallpermissionsdeploy
bash
install -m 755 script.sh /usr/local/bin/script

Space Usage

Understand file and directory sizes.

Directory size summary

Show total size for a directory in human-readable format.

bashANYdusizedisk-usage
bash
du -sh /var/log

Top-level sizes under current directory

Show one-level deep size totals.

bashANYdusizeanalysis
bash
du -h --max-depth=1 .

Filesystem free space

Display mounted filesystem capacity and usage.

bashANYdffilesystemcapacity
bash
df -h

Find largest files

List the biggest files under a directory.

bashANYfindsizecleanup
bash
find . -type f -printf '%s %p
' | sort -nr | head -20

More in Linux Filesystem

No other published sheets yet.

Recommended next

No recommendations yet.