Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I need to print the full path of directories and all sub directories under some source directory

For example, how do I print all directories/sub directories under /etc or /var .. (include directory that start with dot ".")?

Example of printing

share|improve this question
up vote 2 down vote accepted
find <some path> -type d
share|improve this answer
hi I have littlie problem if for example /var -> /var/newdir/dir then find command cant find the subdirectories (because /var is linked to /var/newdir/dir – jennifer Oct 3 '10 at 11:46
/var -> /var/newdir/dir seems to me a quite strange linkage, but you should use -L option to make find follows symbolic links. – cYrus Oct 3 '10 at 11:57
my linux not support the -L option so I write: find /var -type l -type d (something wrong with this ?) – jennifer Oct 3 '10 at 14:05
@jennifer: You can add a slash at the end of the argument to make find follow a symbolic link on the starting path, e.g., find /var/ -type d. – Gilles Oct 3 '10 at 20:56
@jennifer to do symlinks, find has the -follow flag. find /var -follow -type d – Rich Homolka Oct 4 '10 at 15:39

tree will do it. To include '.dotfiles' -a, to show full path for each file -f:

tree -af

and if you do not like indentation:

tree -afi
share|improve this answer
find has the advantage that it's always installed whereas tree needs to be installed manually on most distributions. – lajuette Oct 3 '10 at 11:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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