Continuing reviewing some of my old posts, I found this one Examples of find command, now I want to show you a faster and easier way to find files.
We are going to use the commands updatedb and locate
updatedb
This command will update the database of the files in a given file system, with no arguments, it will read from / to all file system structure looking for files and archiving the data in the database, located in Debian (/var/cache/locate/locatedb).
There is an option for those using NFS (like me) that you can use to include your NFS file system in the database.
--netpaths=’path1 path2...’
So you can enter a command like this:
sudo updatedb --netpaths=/media/nfs_drive
Now that you have your database updated lets find files.
locate
You just need to enter:
locate filename
and the file named filename will be showed, example:
locate apt-cacher -b
The output is:
/etc/apache2/conf.d/apt-cacher.conf /etc/apt-cacher /etc/apt-cacher/apt-cacher.conf /etc/cron.daily/apt-cacher /etc/default/apt-cacher /etc/init.d/apt-cacher /etc/logrotate.d/apt-cacher /etc/rc0.d/K20apt-cacher /etc/rc1.d/K20apt-cacher /etc/rc2.d/K20apt-cacher /etc/rc3.d/S20apt-cacher /etc/rc4.d/S20apt-cacher /etc/rc5.d/S20apt-cacher /etc/rc6.d/K20apt-cacher /etc/rcS.d/S20apt-cacher /usr/lib/cgi-bin/apt-cacher /usr/sbin/apt-cacher /usr/share/apt-cacher /usr/share/apt-cacher/apt-cacher /usr/share/apt-cacher/apt-cacher-cleanup.pl /usr/share/apt-cacher/apt-cacher-format-transition.pl /usr/share/apt-cacher/apt-cacher-import.pl /usr/share/apt-cacher/apt-cacher-lib-cs.pl /usr/share/apt-cacher/apt-cacher-lib.pl /usr/share/apt-cacher/apt-cacher.pl /usr/share/apt-cacher/apt-cacher-precache.pl /usr/share/apt-cacher/apt-cacher-report.pl /usr/share/apt-cacher/apt-proxy-to-apt-cacher /usr/share/doc/apt-cacher /usr/share/man/man1/apt-cacher.1.gz /var/cache/apt-cacher /var/cache/apt-cacher/headers/apt-cacher_1.6.1_all.deb /var/cache/apt-cacher/packages/apt-cacher_1.6.1_all.deb /var/cache/apt-cacher/private/apt-cacher_1.6.1_all.deb.complete /var/lib/dpkg/info/apt-cacher.conffiles /var/lib/dpkg/info/apt-cacher.list /var/lib/dpkg/info/apt-cacher.md5sums /var/lib/dpkg/info/apt-cacher.postinst /var/lib/dpkg/info/apt-cacher.postrm /var/lib/dpkg/info/apt-cacher.prerm /var/log/apt-cacher /var/run/apt-cacher.pid
With the option -b only shows the files where the final part of the name matches the given file name, otherwise, it will show you the full content of the directory /etc/apt-cacher.
If this was useful for you, please consider making a donation, any amount is welcome, please proceed by clicking on the yellow donate button, thank you in advance.





