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

NHS open-source Spine 2 platform to go live next week

Last year, the NHS said open source would be a key feature of the new approach to healthcare IT. It hopes embracing open source will both cut the upfront costs of implementing new IT systems and take advantage of using the best brains from different areas of healthcare to develop collaborative solutions. Meyer said the Spine switchover team has “picked up the gauntlet around open-source software”. The HSCIC and BJSS have collaborated to build the core services of Spine 2, such as electronic prescriptions and care records, “in a series of iterative developments”. Read more

What the Linux Foundation Does for Linux

Jim Zemlin, the executive director of the Linux Foundation, talks about Linux a lot. During his keynote at the LinuxCon USA event here, Zemlin noted that it's often difficult for him to come up with new material for talking about the state of Linux at this point. Every year at LinuxCon, Zemlin delivers his State of Linux address, but this time he took a different approach. Zemlin detailed what he actually does and how the Linux Foundation works to advance the state of Linux. Fundamentally it's all about enabling the open source collaboration model for software development. "We are seeing a shift now where the majority of code in any product or service is going to be open source," Zemlin said. Zemlin added that open source is the new Pareto Principle for software development, where 80 percent of software code is open source. The nature of collaborative development itself has changed in recent years. For years the software collaboration was achieved mostly through standards organizations. Read more

Arch-based Linux distro KaOS 2014.08 is here with KDE 4.14.0

The Linux desktop community has reached a sad state. Ubuntu 14.04 was a disappointing release and Fedora is taking way too long between releases. Hell, OpenSUSE is an overall disaster. It is hard to recommend any Linux-based operating system beyond Mint. Even the popular KDE plasma environment and its associated programs are in a transition phase, moving from 4.x to 5.x. As exciting as KDE 5 may be, it is still not ready for prime-time; it is recommended to stay with 4 for now. Read more

diff -u: What's New in Kernel Development

One problem with Linux has been its implementation of system calls. As Andy Lutomirski pointed out recently, it's very messy. Even identifying which system calls were implemented for which architectures, he said, was very difficult, as was identifying the mapping between a call's name and its number, and mapping between call argument registers and system call arguments. Some user programs like strace and glibc needed to know this sort of information, but their way of gathering it together—although well accomplished—was very messy too. Read more