Language Selection

English French German Italian Portuguese Spanish

CLI Magic: locate, slocate, and rlocate

Filed under

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

Intel Cache Allocation Technology / RDT Still Baking For Linux

Not mentioned in my earlier features you won't find in the Linux 4.9 mainline kernel is support for Intel's Cache Allocation Technology (CAT) but at least it was revised this weekend in still working towards mainline integration. Read more Also: Intel Sandy Bridge Graphics Haven't Gotten Faster In Recent Years

Distributing encryption software may break the law

Developers, distributors, and users of Free and Open Source Software (FOSS) often face a host of legal issues which they need to keep in mind. Although areas of law such as copyright, trademark, and patents are frequently discussed, these are not the only legal concerns for FOSS. One area that often escapes notice is export controls. It may come as a surprise that sharing software that performs or uses cryptographic functions on a public website could be a violation of U.S. export control law. Export controls is a term for the various legal rules which together have the effect of placing restrictions, conditions, or even wholesale prohibitions on certain types of export as a means to promote national security interests and foreign policy objectives. Export control has a long history in the United States that goes back to the Revolutionary War with an embargo of trade with Great Britain by the First Continental Congress. The modern United States export control regime includes the Department of State's regulations covering export of munitions, the Treasury Department's enforcement of United States' foreign embargoes and sanctions regimes, and the Department of Commerce's regulations applying to exports of "dual-use" items, i.e. items which have civil applications as well as terrorism, military, or weapons of mass destruction-related applications. Read more

Linux Kernel News

Games for GNU/Linux