aru Posted January 14, 2003 Report Share Posted January 14, 2003 delboy711 Senior user Joined: 03 May 2002 Posts: 412 Location: Wokingham, UK Post Posted: Mon Aug 05, 2002 9:48 pm Post subject: Finding Files with slocate _________________________________________________________________ Old Linux/Unix hands will already know this one, but it is so darned useful to newbies that it justifies a Tip. Most newbies (me included) assume the best way to find a file is to use the Tools>Find File facility in konqueror, and are then disappointed at how long it takes to find a file. In fact the best file locator is a command line utility called 'slocate' To use it, install the slocate RPM (ML8.2 Powerpack users have a problem here because it is not on your CDs. Go to www.rpmfind.net and download it) Now in a terminal enter su to become root then :- updatedb This will create a database of every file on your computer. A cron job will be run daily automatically to keep the database up to date, so you will only be able to find files created before you switched your computer on in the morning. To find a file enter slocate string Any filename containing the string will be displayed almost instantly. You will never want to use a GUI based file locator again Very Happy Priest Newbie Joined: 28 Jun 2002 Posts: 4 Post Posted: Fri Aug 09, 2002 8:27 pm Post subject: _________________________________________________________________ 'locate' is also linked to slocate, so you can use locate file if that's easier arusabal Moderator Joined: 17 Apr 2002 Posts: 836 Location: Spain Post Posted: Sat Aug 10, 2002 10:01 am Post subject: Re: Finding Files with slocate _________________________________________________________________ delboy711 wrote: Now in a terminal enter su to become root then :- updatedb Also, you don't have to worry about that update because it is done automatically by cron every night at 4:00 am (/etc/cron.daily/slocate.cron) If do you think that such hour is a bit intempestive then change the default behavior editing the file /etc/crontab cannonfodder Moderator Joined: 16 Apr 2002 Posts: 1056 Location: Rochester, NY, USA Post Posted: Sat Aug 10, 2002 6:15 pm Post subject: _________________________________________________________________ Another useful feature of slocate (locate) is the ability to tell it to ignore specific file systems. For example, I have about 4 fat32 (vfat) partitions that contains stuff I don't need to search. Do a man slocate and look at the parameters to see how to do this.. remember a fat32 volume is vfat in linux. frew Senior user Joined: 01 Jun 2002 Posts: 214 Location: Mississippi Post Posted: Sat Aug 10, 2002 7:25 pm Post subject: _________________________________________________________________ I personally find s/locate the best "find" tool on linux. I want to emphasize this to n00bs to linux: use less gui's. I am glad my first box didn't have a lot of ram, that way it forced me to use command line tools. for instance: when I tried to use konquerer to uncompress a tar.gz it took over 2 hours (it was the kernel.) Fortunately I knew the man command and I did a man tar and figured out how to do it in a console, much faster, much better. I know this was kinda've a rant and off topic, but it is important for anyone in linux to learn to use basic tools like this. (No offence if you are not a n00b and you use a full on GUI) DOlson Moderator Joined: 16 Apr 2002 Posts: 2393 Location: Canada Post Posted: Sat Aug 10, 2002 7:42 pm Post subject: _________________________________________________________________ I agree frew. I use Blackbox for minimal gui, in fact, most of my file managing is all cli now too. But anyhow, updatedb is necessary if you install an rpm or whatever and then want to find a particular file right away. So remember BOTH commands, noobs. I usually just use slocate -u and locate. arusabal Moderator Joined: 17 Apr 2002 Posts: 836 Location: Spain Post Posted: Sat Aug 10, 2002 8:09 pm Post subject: _________________________________________________________________ I also agree with frew too DOlson wrote: But anyhow, updatedb is necessary if you install an rpm or whatever and then want to find a particular file right away. In that case there is a tool called 'find', which is one of the most powerfull tools that you can find in a linux system, that will find that particular file faster than rebuilding the db and then executing slocate [at least in an old PC like mine Sad ] DOlson Moderator Joined: 16 Apr 2002 Posts: 2393 Location: Canada Post Posted: Sat Aug 10, 2002 8:16 pm Post subject: _________________________________________________________________ Neat, but then why even use locate? I like locate. Smile arusabal Moderator Joined: 17 Apr 2002 Posts: 836 Location: Spain Post Posted: Sat Aug 10, 2002 8:33 pm Post subject: _________________________________________________________________ DOlson wrote: Neat, but then why even use locate? I like locate. Smile Also I like it Laughing I was talking in that 'particular case', when you are installing things Wink tobyl Frequent user Joined: 01 May 2002 Posts: 115 Location: UK Post Posted: Mon Aug 19, 2002 6:46 pm Post subject: _________________________________________________________________ the command whereis is pretty cool too, if you want to find where that executable lives. You get the full path, and it is v fast. paul Frequent user Joined: 30 May 2002 Posts: 145 Location: New Zealand Post Posted: Mon Aug 19, 2002 9:32 pm Post subject: whereis which _________________________________________________________________ which ... goes hand-in-hand with whereis ex: whereis sendmail which sendmail arusabal Moderator Joined: 17 Apr 2002 Posts: 836 Location: Spain Post Posted: Mon Aug 19, 2002 9:36 pm Post subject: _________________________________________________________________ tobyl wrote: the command whereis is pretty cool too, if you want to find where that executable lives. You get the full path, and it is v fast. Good point. In that contest I better like the command "which" because it just returns where is the executable inside you $PATH, vs "whereis" that returns the executable, the links to it, the source and the man pages of a command that must be within a given group of common binaries directories. The place where I find more useful the "which" command is in scripting, for example to test if a command is there and can be executed by the user that runs the script. Editor's note: This thread was originally posted at the old MUB (Mandrake User Board at club-nihil). This post is the result of a 99% automatic backup, so due to its nature some text may be lost (improbable but possible). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.