Here is the video version, if you prefer it:
Today we are going to talk about locating files. This is very useful and I use it relatively frequently myself.
locate command is used to locate files. (Shotts, 2019) It is used as such:
string is a part of the pathname you want to locate. To remind ourselves, a pathname is a location on your disk, such as
/home/mislav/Linux_folder, so you are asking your computer “give me all the pathnames that contain string within themselves” (string being an array of characters).
Here is an example:
mislav@mislavovo-racunalo:~/Linux_folder$ locate Linux_folder
Here, all paths that contain
Linux_folder within them are located.
Note: You may not have
locate installed as a command (I know I haven’t). You can install the locate command by following an answer provided here: (“How to install the locate command?,” n.d.)
locate uses a database to find files. What that means is that pathnames are stored in a database and then that database is searched for pathnames matching string.
There also exists a command called
find, which you can also use to find files, but we will talk about find in another article.
Thank you for reading!
How to install the locate command? (n.d.). Retrieved February 6, 2020, from https://askubuntu.com/questions/215503/how-to-install-the-locate-command
Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 241-243
Subscribe to my newsletter to keep abreast of the interesting things I'm doing. I will send you the newsletter only when there is something interesting. This means 0% spam, 100% interesting content.