Linux Tree Command

tree is a handy little tool to visualise structures in a file system, from the command line. Here’s a basic Django project that we want to inspect:


Output from Linux Tree

Tree’s not usually installed by default, but is in most distro’s package managers.

On Debian or Ubuntu based systems:

sudo apt-get install tree

And on Redhat, Fedora or CentOS based systems:

sudo yum install tree

Show only the directories:

tree -d

Output from Linux Tree

Show all files including hidden dot files:

tree -a

Output from Linux Tree

Limit the level or depth of recursion:

tree -L 2

Output from Linux Tree

You can filter files by pattern. It’s not quite regex power, but you can use:

* for none or more characters.

? for one character.

[] for character classes:

tree -P "*"

Output from Linux Tree

And, of course, you can mix multiple options together:

tree -daL 2

Output from Linux Tree

Tags: Linux

blog comments powered by Disqus


@MTerzza Twitter Icon

+MikeTerzza Google Plus Icon

Atom | RSS RSS Icon

Recent Posts:

RTL SDR Frequency Drift Offset

Random Seriousness with Python and Password Generation

Random Fun and the Busy Linux Geek

Ampersands & on the command line

Killing processes in Linux