LPI 101-500 – 104.7: Find system files and put files in the right place
July 19, 2023

1. locate, whereis, which, type

We have now actually reached the last section of the course 101. This is mainly about finding files in the main area of knowledge. In number 104 seven, you can read the following on the lpi website know the correct locations of files in the files system hierarchy standard. Know the location and purpose of important files and directories according to the fhs. I think we discussed this topic extensively in a previous lesson. So we will concentrate on the commands that are listed here. On the one hand there is the Find command, which we have already discussed in detail in a previous lesson. So let’s look at the Locate command.

With Locate you can search for programs or files by name. And in contrast to Find, no path has to be specified here. In addition, Locate does not search directly in the directory or in the directory structure. Instead, Locate uses an indexing database accordingly. The result is available very quickly, even with large databases. So let’s look for the file 40 711. By the way, maybe you have to install the command first. So in my case I have installed it. Maybe you have to install it before. Let me check here. Here’s the command pseudoapt install mlocate. The package name is mlocate. Okay, so I try to find the file 40 711 locate file 40 711 and we get some results here. 40 711 is therefore system wide.

Eleven times available, but two times with gz ending. And Locate shows us in which directory they are located. Okay, I’m going to create a file 50 711 now. And now I look for the file again with locate locate file 50 711. And this time I have no result. Why is it, as I said, locate queries at database and does not search directly in the file system. The database is not updated every second, so the file has not yet been indexed. You should now use Find instead, or make sure that the database is updated. This is done with the following command you need pseudo rights pseudo update DB so update database. And now I try to find the file again.

Locate sorry, file 50 711. And now the result is displayed to me. That is, the database has been updated. By the way, the main configuration file for this database is as follows etsy as always and updatedb conf. And that’s the whole conf file to explain prune paths means that the paths that are here are not indexed. So here for example, temp, va, fool, varlib media and so on. So for example, in the temp folder or in the var folders, there is usually too much going on and too much is being changed for it to make sense to always index these files. So if you want to search for a file that is stored in temp or viral directories, then you have to use Find or you have to edit this file.

Here the Etsy update dbcon file and edit the prune paths. Let’s leave that file again.Similar to grep, I would also use the I option for locate because then the search term is not case sensitive. So just to show you quickly locate and then when I would search for locate and then file with capital f dot 40 711, then I get no result because it is the search is case sensitive. Now I use it with the I option and then 547 eleven and now I get my results again. Okay, we come to the where is command which can be used to find out where the binaries source files and man pages or documentation foreign command is located.

Now, if you were to apply where is to our file or text file lauren ipsum, then I think we don’t get a result. Let’s try it out with where is Lauren ipsum and here we don’t get any result because that’s not just intended. It should look different if we search for linux command with whereas for example, whereas chmode and here we have the path to the binary file and we have the path to two man pages here. So of course the lorem ipsum text file has no man page and it has also no bin file. With the option b you can just look for binaries only for binaries. For example where is b chmod and then we have our bin directory and our bin file.

And then we have the option m for manuals and here we have our manuals for our man pages and we have the option s for sources. So for the source files where is Schmod and you see, nothing is shown to us here, in which case there seem to be no source files on the system. We choose instead in it where is s in it and here the corresponding source files are also displayed to us. The next command on the list is which which only looks for executable programs and nothing else, which searches neither a database nor the complete file system, but only the content of the path variable. So let’s look at the path variable again echo dollar path and there are the corresponding paths in which searches for executable files.

If there is an executable file in the path, that is not specified here, which will not find anything either. Okay, we will look again with which and then chmot and here is the executable file or another example which kill and shows us the executable file too, which has only one option A for all, which causes the search to continue after the first search result. Okay, we come to the last command that would be type. With the type command we can find out whether a corresponding command is a file, an alias or a function. For this we use the option t for example with type t and then CP for copy and we see it is a file. Another example type t and then LS is an alias. In that case we see that LS is an alias.

An alias is, so to speak, in abbreviation. I always use the command ll throughout the course. Basically, this is not a linux command, but just an alias. Another word for lsla so type t ll. It’s an alias. If we omit the T option, we can determine where the file is located and in the case of an alias, what it refers to or what it consists of. So type LS and here we see LS is an alias of LS with the option color equals auto. That’s probably all the color schemes that happen here automatically. This was said system wide, so that LS is an alias of this whole command. We can at times do to type ll look, in which case ll is an alias of LS with the option al and capital.

Leave a Reply

How It Works

img
Step 1. Choose Exam
on ExamLabs
Download IT Exams Questions & Answers
img
Step 2. Open Exam with
Avanset Exam Simulator
Press here to download VCE Exam Simulator that simulates real exam environment
img
Step 3. Study
& Pass
IT Exams Anywhere, Anytime!