views:

100

answers:

5

How to get the list of all the files and folders in the root dir including sub-folders and their files.

+1  A: 

Try this (with Ewan's modification):

ls -R /
John Paulett
This will work if you have changed into the root dir. Otherwise use `ls -R /`.
Ewan Todd
list would be quickly populated with ls -R . You can opt for paging with [ls -R | more] if you are you specifically looking for something..type q to quit
Learner
+6  A: 

or this: find /

Dmitry
+2  A: 

If you want to do it programmatically I'd recommend readdir() and opendir().

Jonas Gulle
A: 

use find command eg

$ find /path -print

or if you have tree installed

$ tree /path
ghostdog74
+1  A: 
man find

In all seriousness though,

find / -maxdepth 2

That should show you the root directory, folders in /, and the contents of those folders. If you want the subdirectories of the subdirectories, use -maxdepth 3, and so on.

char