Understanding Linux Package Managers
Welcome to Installing Software and Updates. By the end of this blog, you will be able to describe packages and package managers, differentiate between packages for deb- and RPM-based distros, use a package manager to install updates, and use a package manager to install software.
What are Packages and Package Managers?
In Linux, software updates and installation files are distributed in files known as packages. These packages are archive files containing the required components for either installing new software or updating existing software. Package managers are tools used to manage the download and installation of these packages, ensuring that software is installed correctly and kept up to date. Different Linux distributions provide different package managers, some of which are GUI-based and some are command-line tools.
Deb and RPM Packages
Packages come in two primary formats: .deb
and .rpm
. These are used by different families of Linux distributions:
- .deb Files: Used by Debian-based distributions such as Debian, Ubuntu, and Mint. Deb stands for Debian.
- .rpm Files: Used by Red Hat-based distributions such as CentOS/RHEL, Fedora, and openSUSE. RPM stands for Red Hat Package Manager.
While these formats are distinct, they serve the same purpose. If you find a package only available in the other format, you can convert it using the alien
tool.
Converting Packages with Alien
To convert packages from RPM format to deb, use the alien
command and specify the package name you want to convert. To convert to RPM format, use the -r
switch with the alien
command.
Benefits of Package Managers
Package managers offer several benefits:
- Automatic Dependency Resolution: They can automatically resolve dependencies between packages.
- Update Notifications: They notify you when updates are available.
- Automated Updates: GUI-based package managers can automatically check for and install updates on a regular basis.
- Selective Updates: You can select and install only the updates you want.
Popular GUI-based Package Managers
Update Manager
Update Manager is a GUI tool for updating deb-based Linux systems. By default, it checks for software updates daily and automatically downloads and installs any security updates. Other updates are displayed weekly. You can also manually check for updates at any time.
Using Update Manager:
- When notified of software updates, select the updates you want to install.
- Click ‘Install Updates’.
- If prompted, enter your user password and click OK.
- Update Manager installs the updates in the background while you continue working.
PackageKit
PackageKit is a GUI tool for updating RPM-based Linux systems. When updates are available, it displays a starburst icon in the notification area. It automatically checks for updates at a configurable interval, and you can also manually check for them at any time.
Using PackageKit:
- Click the starburst icon to open the Software Update window.
- Select the updates you want to install.
- Click ‘Install Updates’.
- If requested, enter your user password and click OK.
- PackageKit installs the updates in the background while you continue working.
Popular Command-Line Package Managers
APT (Advanced Package Tool)
APT is a command-line tool for updating deb-based Linux systems. It provides a powerful interface for managing packages.
Updating Packages with APT:
- Run
sudo apt update
to find available packages for your distro. - The output lists each available package and builds a dependency tree.
- Use
sudo apt upgrade
to install all available updates. - To install a specific package, use
sudo apt install <package-name>
.
YUM (Yellowdog Updater, Modified)
YUM is a command-line tool for updating RPM-based systems.
Updating Packages with YUM:
- Run
sudo yum update
to fetch all available package updates. - After entering your password, YUM displays a summary of the updates and asks for confirmation.
- Confirm to download and update the packages.
- YUM completes the process and displays the message “Complete!”.
Installing New Software with YUM:
- Use the command
sudo yum install <package-name>
to install new software.
Other Package Managers
Many software applications use package managers tailored to specific programming languages or environments, such as pip
or conda
for Python.
Using pip for Python Packages
Assuming you have a Python environment and pip
installed:
- Run
pip install pandas
to install the popular Pandas library. - Pip searches for the latest pandas package, downloads it, checks for dependencies, and installs it.
- When the installation is complete, pip displays the new software version number.
Conclusion
In this blog, you learned about the essential role of packages and package managers in Linux. We covered the two primary package formats, .deb
and .rpm
, and how to convert between them using alien
. We also explored popular GUI and command-line package managers for both Debian- and Red Hat-based distributions, including Update Manager, PackageKit, APT, and YUM. Additionally, we touched on the use of specialized package managers like pip
for managing Python environments.
Understanding how to effectively use package managers ensures that your Linux system remains up-to-date, secure, and functioning optimally. Whether you prefer graphical interfaces or command-line tools, there is a package manager that fits your workflow and needs.