![]() If you’ve made changes recently, such as added or removed large amounts of files and directories, and you want to use the locate command to search through these new directories and files, you can manually update the slocate database at any time with the following command: $ sudo updatedbĭepending on the volume of changes made since the slocate database was last updated, this could take a few seconds to a few minutes to update. This command will update the database with any changes made to the file system since the last update. By default, your system will run a command to update this database once a day at 6:25am. This ability doesn’t come without cost though. This database caches the file system directory and file names and allows the locate command to operate in moments rather than taking long periods of time to search the entire file system. The locate command relies on a slocate database to function. There are still quite a few matches, but we no longer have a sort through all the extra results to find what we’re looking for. usr/share/sounds/KDE-Window-All-Desktops.ogg usr/share/sounds/KDE-Window-All-Desktops-Not.ogg usr/share/kde4/apps/kio_desktop/DesktopLinks usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Controls/Styles/Desktop usr/lib/python3/dist-packages/xdg/_pycache_/ usr/lib/python3/dist-packages/xdg/DesktopEntry.py usr/lib/python2.7/dist-packages/xdg/DesktopEntry.pyc usr/lib/python2.7/dist-packages/xdg/DesktopEntry.py usr/lib/libreoffice/share/gallery/computers/Computer-Desktop.png usr/lib/libreoffice/program/wizards/common/Desktop.py ![]() To reduce the results down to a list of entries that match the search term without all the contained files and directories, use the -b option: $ locate -b Desktop That command returns more than a thousand entries on my system. Something that may confuse you when you first start using locate is that it not only returns matches, but if the match is a directory, it also lists all of the directories and files under that directory. home/chris/Downloads/latest monthly report.doc home/chris/Documents/July Monthly Report.doc home/chris/Documents/August Monthly Report.doc For example: $ locate -i 'monthly report' If you want to look for files without case sensitivity, you can use the -i option. For example, we can search for an exact match for nf with the following command: $ locate -r '/nf$' It’s clear that /etc/X11/nf is the file we’re looking for, but what if dozens or even hundreds of results were returned? How could you manage all of that? If you know a little bit about regular expressions (every Linux user really should learn the basics), you can easily use regular expressions to search for directories or files. You can use locate to find it for you quickly: $ locate nf The document that you are reading says to modify the nf file, but the document doesn’t say where that is and you don’t know how to find it. Let’s say that you’ve read up on how to modify X to provide enhanced video performance. The locate program works in a similar fashion to most graphical search tools. The first tool that you should become comfortable with is also one of the simplest. Today, I’d like to introduce you to a few tools that can turn a chore of finding files into an easy process. As is true with most things in Linux, there are great desktop tools, but more power can be found in Terminal than any streamlined desktop tool can match. Many of you fellow Ubuntu users will be familiar with the “Search for Files” tool that allows you to look for files.
0 Comments
Leave a Reply. |