Linux / Bash
Beginner
1 min read
Listing and Inspecting Files with ls and tree
Example
# Basic listing
ls
ls /usr/local/bin
# Long format — permissions, size, date
ls -l
# -rw-r--r-- 1 alice alice 4096 Apr 10 09:22 notes.txt
# Long format + human-readable sizes + hidden files
ls -lah
# Sort by modification time (newest first)
ls -lt
# Sort by size (largest first)
ls -lS
# Reverse sort (oldest or smallest first)
ls -ltr
# List only directories
ls -d */
# Colorised output (usually default on modern distros)
ls --color=auto
# ---- tree ----
# Install if needed: sudo apt install tree
# Show full tree from current directory
tree
# Limit to 2 levels deep
tree -L 2
# Show hidden files
tree -a
# Show sizes
tree -sh
# Ignore specific directories
tree -I 'node_modules|.git|__pycache__'
# Print only directories
tree -d
Related Resources
Linux / Bash Reference
Complete tag & property list
Linux / Bash How-To Guides
Step-by-step practical guides
Linux / Bash Exercises
Practice what you've learned
More in Linux / Bash