Install
sudo apt install tree
Basic usage
tree
tree /path/to/directory
Depth limit
tree -L 2
tree -L 1
Show hidden files
tree -a
Directories only
tree -d
Files only (no dirs)
tree -f
File sizes
tree -h
tree -s
tree --du
Show permissions
tree -p
Show owner/group
tree -ug
Show full path
tree -f
Sort output
tree -v
tree -t
tree -c
tree -r
tree --dirsfirst
Pattern matching
tree -P '*.txt'
tree -I 'node_modules|.git'
tree -I '*.pyc|__pycache__|.git'
Limit files shown
tree --filelimit 10
Output formats
tree -J
tree -X
tree -H baseurl > tree.html
Colorize
tree -C
tree -n
Character set
tree --charset ascii
Statistics
tree --du
Common use cases
Project structure
tree -L 2 -I 'node_modules|.git'
Config files
tree -a /etc/nginx
Find large directories
tree --du -h | sort -h
Generate documentation
tree -H '.' -L 2 > project-structure.html
Backup verification
tree /backup > backup-structure.txt
Advanced examples
Code project
tree -L 3 -I 'node_modules|dist|build|.git|__pycache__|*.pyc'
With file count
tree -L 2 --dirsfirst | head -50
Size sorted
tree --du -h | grep -v /$ | sort -h
Pipe to file
tree > directory-structure.txt
tree -J > structure.json
Comparison
tree > before.txt
tree > after.txt
diff before.txt after.txt
Shell alternative
find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'