securely locate file and dir

slocate filename/dirname
After you install slocate ,the first thing you have to do with it to initialise the database by issuing a command " slocate -u" . And then onwards just give the filename or dirname as a argument to the slocate command will reveal the files/dirs location in the system along with path.Moreover over it's an securely way of looking into the file system.
Sample Output
slocate httpd
slocate: warning: database /var/lib/slocate/slocate.db' is more than 8 days old
/usr/bin/vnc_inetd_httpd
/usr/sbin/httpd2
/usr/sbin/httpd2-prefork
/usr/sbin/httpd2-worker
/usr/include/apache2/httpd.h
/usr/include/apache2-worker/httpd.h
/usr/include/apache2-prefork/httpd.h
/usr/include/apache2-event/httpd.h
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/configs/lighttpd.conf

output truncated for better viewing.

-3
2009-08-29 03:28:08

These Might Interest You

  • MAC OSX doesn't come with a locate command, This will do the same thing as the locate command on a typical Linux OS. Simply add it to your ~/.bash_profile


    0
    alias locate='if [ $((`date +%s`-`eval $(stat -s /var/db/locate.database); echo $st_mtime`)) -gt 3600 ]; then echo "locate: db is too old!">/dev/stderr; sudo /usr/libexec/locate.updatedb; fi; locate -i'
    jhyland87 · 2013-01-21 17:45:50 0
  • May require the locate package. Locate is awesome, it creates a small file database which is updated once a day or so, or you can do a force update with 'updatedb'. Then you just type in 'locate' with the name of the file or folder that you want and off it goes. Show Sample Output


    0
    locate *.desktop
    Vallamost · 2016-09-21 23:47:39 0
  • This command lists extended information about files, i.e. whether or not it is a true file or link, who owns it, etc. without having to 'ls' from the specific directory. If you know the filename, but not the location, this helps with finding other information about the file. It can be truncated by creating an alias for 'ls -l'. The sample output shows difference in regular locate vs. ls + locate. Show Sample Output


    -5
    ls -l `locate your_search_here`
    tjcertified · 2009-11-27 05:53:46 3
  • If you follow my previous posting regarding "vipw" then no explanation required.The same method goes behind this command also.It will open an tmp file in vi editor to give you the enlisting to edit the group file.And most importantly to attach a lock with it.Once you are done ,the lock is released and the changed reflected to the original file.So you can securely edit the group file over the network without the fear of being tampered . Show Sample Output


    -3
    vigr
    unixbhaskar · 2009-08-29 03:56:07 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: