Before we get into the technicalities of the matter, let us start by acquiring a basic understanding of the Filesystem Hierarchy Standard, shortly known as FHS. All Linux distributions get their directory structure and contents from Filesystem Hierarchy Standard. We will briefly go over some parts that are crucial to understanding where apt-get install packages are and why so.
FHS is not considered to be some authority on directory structure and contents for absolutely every Linux distribution, but it is generally the most common standard of file layout. All directories and files in FHS appear under ‘/’ – the root directory. Let’s take a look at some commonly used directories.
A non-profit organization known as Linux Foundation maintains the Filesystem Hierarchy Standard, and the last update (version 3.0) was made on June 3, 2015.
Now that we have gotten a better understanding of how the general Linux filesystem is structured and how it operates, we are ready to learn how apt-get makes use of this very structure to install packages and dependencies.
All operating systems and Linux distributions come with a package manager. These package managers are responsible for installing and removing software from the computer and maintaining them. They give the user more control over what kind of programs they wish to run on the system and make their installation possible.
In Ubuntu (and Debian), dpkg is the package manager that most people use. You can manage packages with .deb extensions through dpkg. Discussing this utility is pertinent to our subject since we will be using it to find apt-get installs packages. “Aptitude” is the more user-friendly way to use dpkg as it provides a front-end to the users. Let us look at how dpkg works in Ubuntu, its syntax, and how you can use it to find out where apt-get installs packages.
The general syntax of this command is as follows.
Another common method of using it is:
You can install a package on your Linux system by running the following simple dpkg command.
We will understand how one can use dpkg and apt-get to install packages and learn where the packages are installed in the following sections.
By this point, we all know that apt-get can be used to install, remove, and upgrade Linux packages. We also learned that it serves as the front-end for dpkg, the native package management utility for Ubuntu and Debian. But how does it really work? And what happens to the files that are installed by it? Let’s find out!
Let us start by installing a test package called ack. For this purpose, we will use apt-get, and later we will trace the files installed by it to their specific locations.
Go ahead and start a new Terminal window through the Activities menu or pressing Ctrl + Alt + T on your keyboard. The next step is to make sure you have the multiverse repository added. Without that, you cannot install ack. You are, obviously, free to use any other package of your choice.
So, to add the repository, run the following command in the Terminal.
Once that is out of the way, we move on to installing the package.
(Note that instead of ack-grep, ack was installed. This is why we will be modifying the next commands we execute)
The installation will be complete within a few seconds. Having done that, we now investigate the package with the help of our package manager, dpkg. We will find out where the files of the package were installed and how to access them.
Recall the general syntax of the dpkg command that we described in the earlier sections. Here, we will be using a variation of that command to list the files in the installed package.
To list the contents of a package, we use the -L operator with the dpkg command. Run the command given below to see the files.
As you can see in the image, all the package manager installed files are shown along with their addresses on the computer.
In addition to that, some files are created or modified by pre/postrm and pre/postinstall scripts included in the installed package. You can view these scripts in the following directory.
Now that we have covered the meat of the tutorial, we will add some additional pieces of information for those that are curious about learning more.
Let’s say, for example, you want to use dpkg to extract all the files of a package in the current directory. You can do this by running the following simple command.
You can also get a hold of the files such as preinst, postrm, postinst, and more by the command given below.
This will extract said files into the current directory as well.
With that being said, we conclude this guide. We learned several things about apt-get today. We saw the Filesystem Hierarchy Standard, how the Ubuntu package manager works, and finally, how we can find where apt-get installs packages to.
In this article, we will see how to Install Google Cloud BigQuery Python client library…
Nov 15,2024 Wallpaper Contest for Xfce 4.20 open for voting The submission phase for the…
MicroCloud 2.1.0 LTS is now available, expanding the number of Canonical infrastructure solutions with a…
Canonical is thrilled to be joining forces with Dell Technologies at the upcoming Dell Technologies…
In today’s massive private mobile network (PMN) market, one of the most common approaches to…
Welcome to the Ubuntu Weekly Newsletter, Issue 865 for the week of November 3 –…