View Directories as a Tree with tree
tree prints an indented hierarchy of a directory, with depth limits, hidden files, and size options.
Run `tree -L 2` to show two levels of the directory tree, adding `-a` to include hidden files.
01Command
Command
$ tree -L 2 -a02What it does
Other flags worth remembering: `-d` shows only directories, `-h` human-readable sizes with `-s`, `-I 'node_modules|.git'` to prune noise, and `-o file.txt` to save the listing for documentation. Without a depth limit, tree on a huge directory can flood your terminal — always reach for -L first. If tree isn't installed, `ls -R` is the poor-man's fallback.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- tree(1) - Linux manual pageEvidence: tree lists the contents of directories in a tree-like format; -L limits the depth of display and -a includes hidden files.
Last verified: 2026-09-17 · Category: Files & Folders