File Operations

tree

Display directory contents in a tree-like hierarchical format.

Synopsis

syntax
tree [OPTION]... [DIRECTORY]...

Examples

Show current directory tree
tree
Limit depth to 2 levels
tree -L 2
Exclude node_modules and .git
tree -I 'node_modules|.git'
Directories only, skip large ones
tree -d --filelimit 20

Common options

FlagDescription
-LMax display depth
-aInclude hidden files
-dList directories only
-IExclude pattern
--filelimitSkip directories with more than N entries

About tree

The `tree` command display directory contents in a tree-like hierarchical format. File operation commands are essential for navigating and managing the Linux filesystem.

They form the backbone of everyday system administration and development workflows. Mastering these commands enables you to efficiently create, move, copy, and organize files and directories from the terminal, which is often faster and more scriptable than graphical alternatives.

The command accepts 5 commonly used flags shown above, though the full set of options is available in the man page (`man tree`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More File Operations Commands

Other commands in the File Operations category

Related tools