Online Linux Terminal Logo
OnlineLinuxTerminal
NavigationCLI Reference

$tree

Display directory structure in a recursive visual tree diagram.

Syntax DefinitionPOSIX standard
tree [OPTIONS] [DIRECTORY]
Linux Community2.4k Online

Chat with real Linux users, learn new commands & get free cheat sheet PDFs.

Try `tree` Live in Interactive Sandbox

Zero-install client simulation with real-time feedback.

Open in Fullscreen Workspace↗
bash — terminal

Overview & How tree Works

`tree` is a recursive directory listing program that produces a depth-indented visual tree of files and folders.

Common Flags & Command Options

Flag / OptionDescription
-L [level]Max display depth of the directory tree.
-dList directories only without listing files.
-aAll files are listed including hidden files.

Practical Real-World Examples

Example #1Visualize directory tree up to depth 2
tree -L 2 /home/user

Outputs folder tree hierarchy.

Frequently Asked Questions

How do you prevent tree from flooding your screen on big folders?

Use the `-L` flag (e.g., `tree -L 2`) to restrict visualization depth.