Introduction
Welcome everyone! 👋🏻
In the previous part of this series, you learned about data compression. This part will teach you how to manage applications using package managers on Debian and Red Hat-based systems.
So without further ado, let's get started! 🚀
Package Managers
In the early days of Unix and Linux, software was distributed as compressed archives. This was fine for developers, who could easily compile the source code and install the software. But for end users, it was a pain. They had to manually download the archive, extract the source code, compile it, and install it. And if the software depended on other libraries, they had to install those libraries too. This could be a daunting task, especially for users unfamiliar with Linux.
To simplify this process, package managers were developed. Package managers are tools that automate the installation, updation, and removal of software. They keep track of which packages are installed, and they can automatically download and install the dependencies that a package needs. This makes it much easier for end users to manage software on Linux.
Debian based systems
Debian-based systems such as Ubuntu, Linux Mint, etc., use the .deb
package format. This means that software for these systems is distributed in .deb
files. The most common tool for managing .deb
packages is apt. APT is very mature and has been around for many years. This means that it is well-tested, reliable, very powerful and can do a lot of things.
APT uses a utility called dpkg. Dpkg is a lower-level utility that does the actual work of installing, removing, and managing packages. However, most of the time you won't need to use dpkg directly, as apt provides a higher-level interface that is easier to use.
Apt is a powerful package manager that can do a lot of things, including:
Simplifying the download and removal of packages
Automating the process of updating or upgrading the system
Managing the dependencies between packages
Let's see it in action!
To use APT, you first need to update the APT cache. This ensures that APT has the latest information about available packages otherwise it might not work as you expect it to.
- Install packages
Installing a package is very simple just use apt install <package>
as a root user or with sudo privileges. When you install a package using APT it will automatically install any dependencies that the package needs.
You can use the -y
option to automatically answer yes to all prompts.
- Remove packages
Removing is also very simple just use apt remove <package>
Again it is waiting for our confirmation.
One thing to note is that it will not remove any configuration files only remove packages.
If you want to remove the configuration too you need to use apt purge <package>
. This will remove the package as well as all of its configuration files except of user's home directory.
As before you can use the -y
option here as well.
- Search packages
Guess, which command we need to search a package?
If you said apt search <package>
then congratulations you're right. Let's see this.
- Upgrade packages
To upgrade just use apt upgrade
As you can see above the apt upgrade
command outputs a list of all the packages that will be upgraded or installed, as well as the size of the upgrade. This is a great way to see what changes are being made to your system and how much space they will take up.
I know you're wondering how APT knows about all the packages available for your Linux distribution, and where to install them from.
APT gets its information from two main sources:
Official repositories: These are maintained by the developers of your Linux distribution, and contain thousands of packages that have been tested and certified to work with your system.
Third-party repositories: These are maintained by other organizations, and may contain packages that are not available in the official repositories.
The official repository configuration file is /etc/apt/sources.list
. This file tells APT where to download the package for your distribution.
Red Hat-based systems
Red Hat-based systems, such as Fedora, CentOS, Rocky Linux, RHEL, etc. use the .rpm
package format. The most common tool for managing packages in these systems is DNF.
DNF is a newer and more powerful package manager than YUM, which was previously used in these systems. DNF is faster, more efficient, and has better handling of dependencies and conflicts. It also uses a lower-level utility called RPM, which is similar to the dpkg of Debian systems.
Let's see this in action!
- Install packages
Installing is pretty straightforward just like apt, dnf install <package>
Unlike apt
, dnf install
automatically updates its cache for you, so you don't need to run dnf update
every time you install a new package.
You can use the -y
option to automatically answer yes to all prompts.
- Remove packages
Removing is also easy, just use dnf remove <package>
- Search packages
Guess the command.
- Listing all packages
To know which packages are installed on your system just use dnf list
and it will list all the packages.
- Upgrade packages
My system is up to date that's why it is not showing any upgrades but it may be different for you.
As usual, you can get more information about any of these tools by checking their man pages.
That's all for this part!
I hope you found this article informative and helpful. If you have any feedback, please share it in the comments below. Thank you for reading!
Stay tuned for the next part of the Master Linux series!