1

Files & Folders Lens can be used to locate user's documents easily, but it seems ignoring system files and folders.

How can I search & locate system files and folders?

(Say for example I want to locate a folder named .metadata, which contains some settings of my Eclipse IDE, and I know that this folder is there in the file system somewhere but I don't know where)

I use 12.04 LTS

1

2 Answers 2

3

You can use the find command to find folders with the -type d parameter. Here are a few examples:

#Search Root ( / ) folder for a folder called www

nits@excalibur:~$ sudo find / -name www -type d
/media/6E5E0E255E0DE6A5/cygwin/srv/www
/media/6E5E0E255E0DE6A5/cygwin/usr/share/doc/ImageMagick-6.4.0.6/www
/media/6E5E0E255E0DE6A5/cygwin/usr/share/doc/GraphicsMagick/www
/media/6E5E0E255E0DE6A5/cygwin/var/www
/media/6E5E0E255E0DE6A5/wamp/www

#Search current folder for a folder which start either Capital/lower-case M

nits@excalibur:~$ find . -iname m* -type d
./.local/share/telepathy/mission-control
./.config/menus
./.mozilla/firefox/vwfuj46p.default/minidumps
./.cache/indicators/messages
./.cache/chromium/Default/Media Cache
./Music
./.macromedia/Flash_Player/macromedia.com
./.jedit/macros
./.jedit/modes
./.gconf/apps/metacity

In the above examples, you would have noticed that only the directories with no subdirectories in them are listed. You can use mindepth/maxdepth to set the depth of the level that needs to be traversed.

#Search current directory for directories starting with either capital/lower-case M but only are present in the current directory

nits@excalibur:~$ find . -maxdepth 1 -iname m* -type d
./Music

# Traverse two levels (current level and one level under) in the current directory for directories starting with either capital/lower-case M:

nits@excalibur:~$ find . -maxdepth 2 -iname m* -type d
./.config/menus
./Music
./.jedit/macros
./.jedit/modes

There are a whole load of different options to search directories and files as well using find, you can look through the man-page accessible by man find for all the options and how to use it. Also although find is slower than locate it doesn't require updatedb to update a DB to search through because the search is performed real-time.

0

Use the locate command. It uses a database that gets updated via updatedb. I have a cron job that runs updatedb every hour so the database is up-to-date.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .