Home   Profile   Fun
#144 Linux  07.01.2008

Get a nice directory overview in the shell with tree


Tired of typing cd and ls? With the tree command you get a very nice tree overview of the content of a directory, its files and subdirectories. The output is even colorized according to the object type. On the distributions I know (Gentoo, Debian and openSUSE) it is not installed per default.

Print a tree of the files in the current directory and all subdirectories.
tree

Print also hidden files.
tree -a

List directories only.
tree -d

Print the full path for each directory and file starting from the current working directory.
tree -f

Print the full path for each directory and file starting from the current working directory But print all found objects as a list instead of a tree (no indention).
tree -fi

Display more details: permissions, user name and group name.
tree -pug

Add inode and device numbers to the output.
tree --inodes --device

With -L you can control the depth of the descent into the directory structure. Print only the content of the current directory.
tree -L 1

Print only the content of the current directory and the first level of subdirectories.
tree -L 2

Save output in a file.
tree -o output.txt

With -A you get a nicer indention, here is an example:
tree -Apug -L 2