Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the command that can be used to draw the directory tree inside the terminal emulator?

enter image description here

share|improve this question
up vote 39 down vote accepted

You can use tree to print the directory tree in terminal. Install tree from terminal,

sudo apt-get install tree

To see the directory tree, use

tree /path/to/folder

Or navigate to a directory and just use


It has some advanced options too. You can see owner's username, groupname, date of last modification of a file/folder and so on using tree. It supports directory colors of ls so you can see colourized outputs.

See man tree for more.

share|improve this answer
+1 Great option buddy – Maythux Mar 8 '14 at 9:14
If you wish to tree only directories use -d switch. – souravc Mar 8 '14 at 9:21
clean and easy tool – zhihong Feb 16 '15 at 15:57
or if you use brew on OSX. "brew install tree" – AshHimself Sep 15 '15 at 4:13

You can do it easily with the following command:

find . -type d | sed -e "s/[^-][^\/]*\//  |/g" -e "s/|\([^ ]\)/|-\1/"

This command will search recursively for directories inside the parent directory and then draw the tree of the founded directories.

share|improve this answer
Please split and explain the above command for me. – Avinash Raj Mar 8 '14 at 9:08
@AvinashRaj Buddy the overall of the command is clear if you wan to learn more about sed please refer to some tutorials or google it. It's really hard to explain all sed here! – Maythux Mar 8 '14 at 9:23

There is a program called "tree" which lists directory content in a tree structure.

I think it's in the repositories (or even installed)

sudo apt-get install tree

tree -d /path/to/directory

Check this link for more.

share|improve this answer

protected by Community Dec 3 '14 at 5:33

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.