What happens when ... you run $apt-get install <>
Girish Koundinya
Posted on August 24, 2019
~~~ This post was originally published in my blog ~~~
If you have tried any Linux based system, chances are that you would have run
apt-get install <>
atleast once.
This would have been followed by you going to have coffee (or tea?) and taking a break while your terminal is spewing stuff like -
I think we need to talk about a few things before we proceed.
- I know the gif shows a windows terminal.
- It doesn't show apt-get install.
- I spent a lot of time procastinating and trying to find the perfect gif. It doesn't exist. But a lot of cat gifs were watched during the process.
- You get the idea.
apt-get is a command line interface for managing packages provided by
What is a package
We need step in to a time machine and head back to the age when software was predominantly distributed via mailing lists and FTP. One would have to download the source code, look for a ./configure that would
install the required depedencies and then use the Makefile to compile and install the software.
Makes you want to give npm a nice hug and say "Thank you" doesn't it?
This was a cumbersome process to install and play around with software.
Packages were designed to battle this complexity. Packages are prebuilt binaries that one could install using a tool called package manager. The early versions of these package managers only handled the binaries and the dependencies of a binary were not part of the downloaded artifcat. Later versions of package managers included dependency resolution which made it easy and removed the need to lookup depedencies before downloading software. Package management systems usually go hand in hand with a software repository which is a collection of packages or meta infromation about packages. Package managers usually search repositories to find software and their depedencies.
What is a Debian Package
Debian GNU/Linux is a particular distribution of the Linux operating system, and numerous packages that run on it.
The Debian Project was created by Ian Murdock and I love the fact that the project name is a contraction of the names of Debra and Ian Murdock.
With Linux having multiple flavours, each of these distributions have their own sofware repositories, package managers and package structures.
Most notable of these are -
- .deb packages which are used in Ubuntu, Linux Mint and Debian
- .rpm used by RedHat, Fedora and SUSE.
.deb package mainly contains the following components
- debian-binary - Contains information regarding version of debian package.
- control archive - This archive contains meta information about the package.
- data archive - Contains the actual software.
So what is apt-get
The .deb packages were initially managed by a tool called dpkg. dpkg was built to download pre-built binaries and it had capabilities to check if depedenices are matched but did not have the ability to resolve dependencies for the user. Later, a new debian project, Advanced Package Tool (APT) was started which would take care of depedency resolution aswell and works with dpkg.
APT includes a collection of tools that deal with package management and also command line programs that use the library. apt-get and apt-cache are the most commonly used command line programs. Popularly, apt and the command line tools are reffered to as a front-end to dpkg. i.e means by which users can communicate with dpkg.
APT uses /etc/apt/sources.list as a list of sources from which packages can be downloaded.
An example of a source list is as follows -
deb http://deb.debian.org/debian buster main
deb-src http://deb.debian.org/debian buster main
deb http://deb.debian.org/debian-security/ buster/updates main
deb-src http://deb.debian.org/debian-security/ buster/updates main
deb http://deb.debian.org/debian buster-updates main
deb-src http://deb.debian.org/debian buster-updates main
You can add or remove sources and after modifiying the source list and apt-get is made aware of new locations to search for packages.
There quite a few front-ends for apt that are avaiable now, some also have a GUI apart from having a command-line interface like Synaptic and aptitude. Historically, apt-get was only designed as a test front-end for libapt-pkg but it was exteremly succesful and popular.
Summary
When you run
sudo apt-get install <package-name>
- apt-get searches for the package in the software repository.
- Checks dependencies.
- Installs dependencies.
- Installs the software package.
A more detailed look into the lookup and dependency resolution process is available here -
https://debian-handbook.info/browse/stable/sect.apt-get.html
References
Posted on August 24, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 29, 2024