Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

It's often that I need to locate the path to files and directories in Ubuntu Server. Are there any good way to search for files or directories in the filesystem by name?

share|improve this question
Have you tried the locate command? Just checking, because this question sounds too easy... – nickguletskii May 24 '11 at 15:25
@nick: I have tried that now but it wasn't working as I expected, see my comment to the posted answer. – Jonas May 24 '11 at 15:48
up vote 5 down vote accepted

You name it: locate!

locate is a program installed by default that let you search for files/dirs by name, into its database updated with a cron job.

Go through the man page to see other interesting options, like regex search.

Moreover, you can use find to search on the current content of the filesystem (not on a database), with a full set of complicated options, that let you refine your search also based on metadata (permissions, modification time, etc.).

share|improve this answer
I installed a package to PostgreSQL using apt-get install postgresql-contrib-8.4 but I don't know where it is installed and I can't find it using locate contrib or locate *contrib*. – Jonas May 24 '11 at 15:45
so, use locate postgresql, after having updated the db (sudo updatedb) if required. Remember, it is not updated instantly after each filesystem modification. The contrib keyword is not a so happy choice. – enzotib May 24 '11 at 16:08
@enzotib: locate postgresql doesn't work well for me, I only get /etc/bash_completion.d/postgresql as result. – Jonas May 24 '11 at 16:10
@Jonas looking at the file list, it is located in /usr/share/postgresql/8.4/contrib/. Try "locate contrib/" – nickguletskii May 24 '11 at 16:18
@nick: Thanks, that path seem to be correct, but I can't find it using locate contrib/ it just give me a list of other directories but none of them are related to PostgreSQL. – Jonas May 24 '11 at 16:20

The command find / -name "name-to-search-for" seem to work fine. A good thing was to add a * in the end or at the beginning of the name.

E.g. find / -name "postgresql*" list files and directories that starts with "postgresql".

share|improve this answer

According to your comments, you are not looking for specific filenames but for files that belong to a package. To see which files are associated with your installed package just type:

dpkg -L postgresql-contrib-8.4

share|improve this answer
@Jonas: also, update your question, in particular the title. If not pertinent, i will delete my answer. – enzotib May 24 '11 at 15:59
@enzotib: No, the question is how I search for files (not only in this situation). – Jonas May 24 '11 at 16:02
Thanks for this command, but I wan't to learn how to search for files by name, so this command only help me in this specific situation. – Jonas May 24 '11 at 16:05

If you are installing and want to know what files you install... you can do that immediately following an install by doing the following:

touch marker
find <directorypath> -newer marker

There are some situations in which you will get results other than the newly installed applications(s):

  • if Firefox or another browser is running there may be updated files
  • if Virtualbox or other virtualization guest is running its virtual disk file may have been altered.

This method should work with installs from .deb files or scripted installs.


  • Do not use this from the 'root' directory as there are many system files that are updated frequently.
share|improve this answer

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.