The Linux tree utility produces depth-indented directory listings representing filesystem directory structures and files.

tree Command Examples

Terminal Commandsbash
# 1. Limit recursion depth to 2 directory levels
tree -L 2
 
# 2. Exclude build/cache directories from tree listing
tree -I "node_modules|.git|dist"
 
# 3. Output directory hierarchy in JSON format
tree -J -L 2