In this lesson, I'd like to tell you about width and locate.
Not the most important utilities, but very convenient. That's why I like to tell you about them. Anyway.
So Find is very powerful and it's a thorough utility that helps you find any file no matter where it is stored.
The disadvantage of Find is that on big file systems it might be slow,
particularly if you have a composed file system that integrates many other devices.
And that's why you might be interested in locate.
Locate is much faster, but it works on a database that needs to be defined using the updatedb command.
And also you need to update this database periodically.
So if you are going to use locate and if you want to rely on it, probably you want
to use updatedb as scheduled job using cron or systemd timers as explained later, which is also convenient. It
is useful to find the exact location of binary files from the path variable. Let me show you.
So let me type LS and let me use locate a file and
then what do we get? We get oh boy, locate. No such file
or directory. And that's because updatedb apparently has never happened on this system.
So I need sudo updatedb to generate it.
And now I'm using locate file and there you can see
that it locates files that match the text pattern file.
So do realize that locate is not going to need any wildcards and
so on. It's just looking for files that contain the text pattern.
Now, how about which.
Which passwd, for instance, is printing the name of usr bin passwd that makes that
you can use constructions like LS l and whichpass wd. Now what is that? When
you put a command between a dollar and parenthesis, that's what we call command substitution.
And the result is that the command will work on the result of the whichpass WD command. So you don't
need to know where exactly this command is on your valve system, which will find it out automatically for you.
As I told you, small utilities, but they can be convenient.