When to use tree
Use tree to inspect a project layout without opening every directory manually. Limit depth and exclude large generated folders so the output remains readable on a remote terminal.
Syntax
tree [PARAMETERS] [DIRECTORY]Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Show project structure
tree -L 2 ./projectOnly two levels of the project tree are displayed.
Show directories only
tree -d -L 3 ./projectThe report includes directories only, limited to three levels.
Exclude dependency directories
tree -L 2 -I 'node_modules|.git' ./projectDependency and repository metadata directories are excluded from this compact view.
Notes and limitations
- The utility is often installed separately from the base system.
- For large trees, set depth and exclusions to limit traversal and output volume.
Common questions and troubleshooting
Why is tree not found?
It is an optional package on many systems. Install it through the server distribution's package manager if permitted, or use find and ls.
Can tree become slow on a large project?
Yes, traversing many directories incurs filesystem work. Restrict the starting path and depth and avoid unnecessary scans of network mounts.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man tree.