# How do I find a specific file on my VPS?



## vpsnewb (Jun 5, 2013)

Hi there. How do I find a specific file on my VPS? Like, if the file was called, "example.txt" and I am not sure what directory it is saved in, what would be the easiest way to find this?


----------



## Aldryic C'boas (Jun 5, 2013)

Assuming you want the simplest solution - for a Debian-based OS, simply run the following:


apt-get install locate && updatedb
locate example.txt

The above to be run as root, of course (or via sudo).  _updatedb_ isn't autonomous - it'll run whenever called manually, or the VM is rebooted.  So if you add a bunch of files, and want them included in the search, you'd need to run _updatedb_ again before running _locate filename_.


----------



## rds100 (Jun 5, 2013)

find / -name example.txt


----------



## acd (Jun 5, 2013)

@[member='Aldryic C'bo


----------



## Aldryic C'boas (Jun 6, 2013)

acd said:


> @Aldryic C'bo


----------



## Ishaq (Jun 6, 2013)

I agree, locate is easy. I prefer find though.


----------



## acd (Jun 6, 2013)

find /var/www/ -iname 'bfj*ascii*phallus' -mtime +40 -exec bash -c 'mailx [email protected] -s "A present for you!" < "{}" ' \;


----------



## Aldryic C'boas (Jun 6, 2013)

acd said:


> find /var/www/ -iname 'bfj*ascii*phallus' -mtime +40 -exec bash -c 'mailx [email protected] -s "A present for you!" < "{}" ' \;


I could not hit that Thanks button hard enough


----------



## Adwait_Leap (Jul 18, 2013)

I have always used find command as it gives me an expected result eventhough it is slow compared to locate.


----------

