Skip to content
LangStop
The Linux tree Command: Directory Tree Visualization

The Linux tree Command: Directory Tree Visualization

1 min read
Last updated:

The Linux tree Command: Directory Tree Visualization

tree displays directory hierarchies in a tree format - much nicer than recursive ls.


Basic Usage

tree
tree /path/to/dir

Show directory tree.


Options

  • -L N — Limit depth to N levels
  • -d — Directories only
  • -a — Include hidden files
  • -I pattern — Exclude pattern
  • -f — Print full path prefix
  • -s — Print sizes

Examples

Limit depth

tree -L 2

2 levels deep.

Directories only

tree -d

Show folders only.

Exclude patterns

tree -I 'node_modules|dist'

Ignore build directories.


Further Reading

Explore Our Toolset