Windows
Linux
File Management
File System
Windows tree equivalent in Linux
Shows the directory structure as a visual tree. May need to be installed on Linux.
Windows
→
tree
Linux equivalents
tree
tree
tree
Overview
What this command does
Shows the directory structure as a visual tree. May need to be installed on Linux.
Migration tip:
tree may not be installed by default. Run sudo apt install tree. As an alternative, find . | sort | sed can approximate it without installing anything.Practical tasks
Common use cases
Display directory tree
Shows the directory structure as a visual tree. May need to be installed on Linux.
tree -L 2
Limit depth to 2 levels
tree -a
Include hidden files
tree -d
Show directories only
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
tree
tree -L 2
tree -d /home/user
sudo apt install tree
sudo dnf install tree
Walkthrough
Examples with explanations
# Windows: tree /f /a
tree # show current directory tree
tree -L 2 # limit to 2 levels deep
tree -d /home/user # directories only
# Install if missing:
sudo apt install tree # Debian/Ubuntu
sudo dnf install tree # Fedora/RHEL
Reference
Common options and variations
| Command or option | Use |
|---|---|
tree -L 2 | Limit depth to 2 levels |
tree -a | Include hidden files |
tree -d | Show directories only |
tree -h | Show human-readable file sizes |
tree -I 'node_modules' | Exclude a pattern |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | tree |
Same command on this distribution. |
| Fedora | same command | tree |
Same command on this distribution. |
| Arch | same command | tree |
Same command on this distribution. |
Keep learning