Categories: Ubuntu

Where does apt-get install packages to?

Whether you are a Linux veteran or just starting with Linux, you must have used apt-get or seen it being used somewhere. It is the primary way to install packages and dependencies on Ubuntu. In simpler terms, apt-get is the go-to of every Linux user when looking to set up software on their computer. This gives rise to a new question – where does apt-get install these packages to? Where do the files go, and how can one access them? In this guide, we will find out the answers to these questions.

Ubuntu Filesystem Layout

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.

Sponsored

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.

  • /bin directory holds the primary command binaries.
  • /dev directory contains device files.
  • /etc directory has host-specific configuration files.
  • /home folder contains the user’s personal settings and saved files.

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.

Package Management

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.

$ dpkg [actions]

Another common method of using it is:

$ dpkg [options] filename

You can install a package on your Linux system by running the following simple dpkg command.

$ dpkg -i packagename

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.

How does apt-get work?

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.

$ sudo apt-add-repository multiverse

Once that is out of the way, we move on to installing the package.

Sponsored
$ sudo apt-get install ack

(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.

$ dpkg -L ack

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.

/var/lib/dpkg/info

Additional Information

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.

$ dpkg -x packagename

You can also get a hold of the files such as preinst, postrm, postinst, and more by the command given below.

$ dpkg -e packagename

This will extract said files into the current directory as well.

Conclusion

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.

Ubuntu Server Admin

Recent Posts

How to Install Google Cloud BigQuery Python client library on Linux

In this article, we will see how to Install Google Cloud BigQuery Python client library…

2 days ago

Wallpaper Contest for Xfce 4.20 open for voting

Nov 15,2024 Wallpaper Contest for Xfce 4.20 open for voting The submission phase for the…

2 days ago

Canonical announces the first MicroCloud LTS release

MicroCloud 2.1.0 LTS is now available, expanding the number of Canonical infrastructure solutions with a…

3 days ago

Join Canonical in Paris at Dell Technologies Forum

Canonical is thrilled to be joining forces with Dell Technologies at the upcoming Dell Technologies…

4 days ago

Bringing automation to open source 5G software at Ubuntu Summit 2024

In today’s massive private mobile network (PMN) market, one of the most common approaches to…

5 days ago

Ubuntu Weekly Newsletter Issue 865

Welcome to the Ubuntu Weekly Newsletter, Issue 865 for the week of November 3 –…

6 days ago