Language Selection

English French German Italian Portuguese Spanish

CLI Magic: locate, slocate, and rlocate

Filed under
Linux

Slocate and locate both do essentially the same thing: search a database containing the file names and locations on the system for a match and report all that are found. Both count on another program -- updatedb -- to do the heavy lifting by creating/maintaining the database to be searched. Slocate provides greater security by storing the permissions and ownership of each file, and then only showing the files that the user running the slocate request has permission to access.

The format of the locate/slocate is simple: locate options pattern. It's a good idea to be as specific as possible with the search pattern, because locate will list every file name it finds that contains a match. If I use locate to search my SUSE 9.3 desktop system for mono, like this:

locate mono

It responds with over 400 lines of output. But if I search for libmono instead of simply mono, locate returns only 3 matches.

If you're only interested in how many times the pattern is found, you can specify the -c option in your search, like this:

locate -c mono

File names in Linux are -- sometimes infuriatingly so users who are new to Unix -- case sensitive. Trying to remember if a file name is whereami, WhereamI, or WhereAmI before searching for it can add frustration to the task. Tell locate that you are an insensitive lout who is totally case insensitive by adding the -i option to the search, like this:

locate -i whereami

Updating the database

Since updatedb normally runs just once a day, sometimes you need to find a file that has been created since the last update. When that's the case, just enter the command updatedb as root and let it run. It may take several minutes to complete, or even longer if you have a large number of files to be accounted for.

Full Article.

More in Tux Machines

Software and howtos

  • wikipedia2text – A Command Line Tool For Querying The Wikipedia Article
    Hi folks am back with another interesting topic called wikipedia2text. It’s a small Shell script to query the Wikipedia articles in console, also it can open the article in any browser. This shell script uses text-browser to query and render Wikipedia articles. The output will be printed to standard out. It Currently supports around 30 Wikipedia languages. Most of us prefer Wikipedia to know the detailed information about any company or any product information & it’s history. For any google search by default Wikipedia link comes in Top 5.
  • Yay! I Found Yet Another Reliable AUR Helper
    Howdy Arch Users! I’ve got a good news for you. Today, I stumbled upon yet another reliable AUR helper called “Yay”. Yep! the name of this AUR helper is Yay. Currently, I use Pacaur for installing AUR packages. It does great job and I really like it. I also have used other AUR helpers such as Packer and Yaourt in the past. After reading its features, I thought to give “Yay” a try and see how things works. So, here we go!
  •  
  • mount.nfs: requested NFS version or transport protocol is not supported
  • How to Deploy Clojure Web Application on Debian 9
  • Copr stack dockerized!
  • Using Dell Dock With Ubuntu
    Over the years I have found my way around many minor hurdles when using Ubuntu, the most recent being Using the DELL ULTRAHD 4K USB 3.0 DOCKING STATION (D3100).

GNU/Linux Desktops/Laptops and Devices

OSS Leftovers

Security Leftovers

  • Google and IBM launch open-source security tool for containers
    Google and IBM, together with a few other partners, released an open-source project that gathers metadata that developers can use to secure their software. According to an IBM blog post, the goal of the project is to help developers keep security standards, while microservices and containers cut the software supply chain.
  • Top 10 Hacking Techniques Used By Hackers
    We live in a world where cyber security has become more important than physical security, thousands of websites and emails are hacked daily. Hence, It is important to know the Top hacking techniques used by hackers worldwide to exploit vulnerable targets all over the internet.
  • Protect your wifi on Fedora against KRACK
    You may have heard about KRACK (for “Key Reinstallation Attack”), a vulnerability in WPA2-protected Wi-Fi. This attack could let attackers decrypt, forge, or steal data, despite WPA2’s improved encryption capabilities. Fear not — fixes for Fedora packages are on their way to stable.
  • Federal watchdog tells Equifax—no $7.25 million IRS contract for you
    The Government Accountability Office (GAO) on Monday rejected Equifax's bid to retain its $7.25 million "taxpayer identity" contract—the one awarded days after Equifax announced it had exposed the Social Security numbers and other personal data of some 145 million people.
  • Adobe Flash vulnerability exploited by BlackOasis hacking group to plant FinSpy spyware

    Security researchers have discovered a new Adobe Flash vulnerability that has already been exploited by hackers to deploy the latest version of FinSpy malware on targets. Kaspersky Lab researchers said a hacker group called BlackOasis has already taken advantage of the zero-day exploit – CVE-2017-11292 – to deliver its malicious payload via a Microsoft Word document.

  • Companies turn a blind eye to open source risk [Ed: No, Equifax got b0rked due to bad practices, negligence, incompetence, not FOSS]
    For instance, criminals who potentially gained access to the personal data of the Equifax customers exploited an Apache Struts CVE-2017-5638 vulnerability.
  • Checking Your Passwords Against the Have I Been Pwned List
    Two months ago, Troy Hunt, the security professional behind Have I been pwned?, released an incredibly comprehensive password list in the hope that it would allow web developers to steer their users away from passwords that have been compromised in past breaches.