Welcome back, techies! Through part 1 of the Linux basics terminologies article, we learned about kernel & distribution, command-line interface, Terminal, shell, root, and directories. I hope you all read that and now let’s learn about Linux repositories and packages. If you ever used any Debian-based Linux distributions in your life, You definitely used a command called “apt” (apt update, apt install, etc.) Even if you are a script kiddie.
You probably used it for installing any tools or updating packages but do you really know why we use apt? What is apt? Let’s talk about it through this article.
Linux Basics – Repositories and package management:
In windows, If we want to install any software we will just head to their website -> download the .exe file, and then install that software just by double-clicking the .exe file, Right?
But in Linux systems, It is totally different. We will download the software as a package from our repository and install it through the terminal using package managers.
Wait, What is a package? Repository? Package managers?
- Simply, a package == collection of software/programs.
Linux distributions come with a wealth of software pre-installed, but what do you do if you want to add something new or want to uninstall something old? The answer is to use packages. Yes, you can add/remove software by downloading/uninstalling the appropriate Package.
A package is a collection of programs and data that are bundled together for our convenience. Whenever we install any software, it will come as a whole package and not just the software.
A package composes of,
- Precompiled software (Binary executable files)
- A list of dependencies (Dependencies are needed for the packaged software to work correctly.)
There are many different types of packages, but the most common are application packages and libraries. Application packages contain programs that you can run on your computer. For example, the LibreOffice suite comes with an application package called LibreOffice-core that contains the programs – office, Writer, and Calc.
Libraries are collections of code that you can use in your own applications or projects. For example, the OpenGL library is a library that you can use in your own applications to render graphics.
All packages follow a defined format which is called the package format. For instance, let’s say, based on how the metadata are stored, how the files are interlinked, etc. a package format is specified.
The two most popular package formats are
- The deb package format.
- The rpm package format.
The .deb package format is used in Debian-based distributions such as Ubuntu, Kali, Parrot, etc., and the .rpm package format is used in RedHat-based distributions such as CentOS, Fedora, etc. let’s talk more about this in the package managers section.
Interested in Cybersecurity? Introduction to Cybersecurity
- Simply, a Repository is a collection of packages.
Now, Technically, A repository is a collection of files that stores the software packages which have been compiled for use on a particular Linux distribution or version.
The repository is a storage location hosted by our Linux distribution which contains all the essential software as packages. When you install any software, the package is downloaded from a repository and installed onto your system.
Linux repositories provide a way for users to easily find, install, and update software packages on their Linux systems.
There are many different types of repositories, including those for Fedora, Debian, OpenSUSE, and Arch Linux. Each has its own set of features and benefits.
One advantage of using a repository is that it allows users to easily upgrade their software without having to reinstall everything. For example, if they have installed an application from a repository but now want to upgrade to a newer version, all they have to do is download the new package and install it on their system. If the application is not available through the official distribution channels (such as the Ubuntu Software Center), then the user can usually find it in a repository.
Another advantage of using repositories is that they often include pre-compiled versions of popular applications and libraries so that users don’t have to compile them themselves. This saves time and makes installation faster.
Let’s say, We want to install a package from a repository, but how can we do that? We know, This repository is stored on Linux servers and not on our computers, Right? So, how can we use these software packages? How to access them? This is where the package managers come into play.
In order to install a package from a Linux repository, you will need to first have the appropriate software installed i.e you will need to have a package manager.
Package managers are software or systems utilities that allow users to install and manage software packages from a repository. So, a package manager is the one which is responsible for accessing and manipulating the packages.
Types of package managers
There are several package managers available for Linux: dpkg, rpm, apt, yum, Pacman, etc. but the two most common are yum and apt. Each has its own benefits and drawbacks.
These package management tools are categorized as
- Low-level tools
- High-level tools
|DISTRIBUTION||LOW-LEVEL TOOL||HIGH-LEVEL TOOL|
Before getting into tools, Know what are software dependencies. Dependencies are a kind of prerequisites that are required for some software to work properly. These dependencies will come together with the software when we download the package.
Low-level tools can install, uninstall, and query individual software packages but, they cannot manage dependency resolution. As we said, Software needs dependencies to work properly but these low-level tools can’t manage dependencies. Some popular low-level tools are dpkg and rpm.
- dpkg is the default package manager for Debian-based systems. It’s very simple to use, and it can query, install, remove, provide information about and build *.deb packages. Like other package managers, dpkg has its own command line interface(CLI) that you can use to interact with it. Its main advantage is that it can scan all versions of a given software package to see if there are any updates available.
- One downside of dpkg is that it doesn’t have a lot of features available, such as installing multiple versions of a given software package simultaneously or managing software dependencies.
- RPM is the default package manager for Red Hat-based systems. Like dpkg, it can query, install, verify, upgrade, and remove packages and also offers more features than dpkg. rpm has a command-line interface (CLI) and can be used on both systems that run Linux and those that use Windows Subsystem for Linux (WSL). rpm system has a better error reporting system than dpkg.
- One downside of RPM is that it can be more complicated to use than dpkg, and it doesn’t support as many software packages as dpkg does. Additionally, RPM may not be compatible with some third-party applications that require the use of dpkg().
High-level tools can do more than low-level tools such as install, uninstall, and query individual software packages, and also they can manage dependencies. Some popular High-level tools are apt and yum.
- A popular command-line package management tool called the Advanced Package Tool (or APT) serves as a Front-end for the Debian Package (DPKG). APT can also resolve more complex dependencies and download packages from remote locations.
- A command-line package management tool called the Yellowdog Updater, Modified (yum) serves as a user interface for the Red Hat Package Manager (RPM). It has the ability to manage .rpm packages (RPM distributions) from both local and remote sources.
All these days we have used the command “apt” without knowing its actual meaning and work. I hope now you know why we use apt and the purpose of using it. Still, if you got any doubts check out the workflow below.
Whenever we download/install a package, this is what happens.
- The user requests a package through the system’s package manager (apt/yum), which initiates the general workflow. The Package manager then locates and downloads the requested package from a recognized location (repository)and then installs the package. The package manager then recommends any additional manual procedures it determines are required.
For example, Let’s say, I’m gonna install python in my Kali Linux. For this, I will use the command below which gets the work done.
- sudo apt install python3
Here the package manager “apt” will install the package named “python3” from the Kali Linux repository.
I hope you remember everything we taught you through this Linux basics article. still, I will give you a quick recall.
- apt, yum -> high-level package managers.
- dpkg, rpm -> low-level package managers.
- package managers -> used to install the packages from the repositories.
- packages -> collection of programs/software.
- repository -> collection of packages.
That’s it for this article. Remember this is a series of Linux basics and will continue further. So keep following our blog to learn more from scratch. subscribe to our newsletter so that we can notify you whenever we add a new post. Feel free to comment and ask your doubts if you have any in the comment section. We will meet you in the following Linux basics article. Cheers!