100 Useful Command-Line Utilities

by Oliver; 2014

64. tree

Note: tree is not a default shell program. You may have to download and install it.

tree prints out a tree, in ASCII characters, of your directory structure. For example:
$ mkdir -p tmp/{a,b}/c/{d,e}
Let's run tree on this directory and illustrate its output:

image

If you make the mistake of running this command in your home directory, you'll get a monstrously large output. For that reason, you can restrict the depth with the -L flag:
$ tree -L 2 tmp
This prints the tree only two directory levels down.

tree is like vanilla find with graphics.

<PREV   NEXT>