View Directories as a Tree with tree

tree prints an indented hierarchy of a directory, with depth limits, hidden files, and size options.

LinuxdirectorylistingtreeLow risk
Run `tree -L 2` to show two levels of the directory tree, adding `-a` to include hidden files.

01Command

Command
$ tree -L 2 -a

02What 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

RiskLow risk
Requirementstree installed (apt install tree / dnf install tree); not preinstalled on many distros

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • tree(1) - Linux manual page
    Ubuntu Manpages · technical · 2026-09-17
    Evidence: 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