Package managers are tools that automate the process of managing software on your Linux system. They handle the installation, updating, configuration, and removal of software packages. Each Linux distribution tends to favor a specific package manager, though they generally perform similar functions. The most common package managers include:
- APT (Advanced Package Tool): Used in Debian and Debian-based distributions like Ubuntu.
- YUM (Yellowdog Updater, Modified): Utilized in Red Hat and Red Hat-based distributions like CentOS.
- Zypper: The package manager for openSUSE.
- Pacman: Designed for Arch Linux.
These package managers differ mainly in their commands and package repositories but share the common goal of simplifying software management.
Working with apt
in Ubuntu and Debian
Searching for Packages
To search for a package in the apt
repository, use the command:
apt search package_name
Replace package_name
with the name or description of the software you’re looking for. Search for the package named cowsay
.
Installing Packages
To install a package, the command is:
sudo
apt
install package_name
In this example, we will install the package cowsay
:
sudo
apt
install cowsay
Also install the package named fortune
, then you can pipe fortune to cowsay and get output like the following:
sonnyb@ubuntu-server:~$ fortune
| cowsay
_______________________________________
/ As flies to wanton boys are we to the gods
; they
kill us
for their sport.\
|\ -- Shakespeare,
“King Lear” /
---------------------------------------
List installed packages
You can list all install packages by using the command below:
apt list --installed
Updating Package Lists
Before installing new software or updating existing packages, it’s a good practice to update the list of available packages:
sudo
apt update
Upgrading a specific package
There may be times when you only want to upgrade one specific package instead of all of your packages. You can accomplish this with the command below:
sudo
apt
install --only-upgrade package_name
Upgrading Installed Packages
To upgrade all your installed packages to their latest available versions, use:
sudo
apt upgrade
Removing Packages
To remove an installed package:
sudo
apt remove package_name
To remove a package along with its configuration files:
sudo
apt purge package_name
Comparison of Package Managers
Feature / Package Manager | APT | YUM | Zypper | Pacman |
Base Distribution | Debian-based | Red Hat-based | openSUSE | Arch Linux |
Search Command | apt search | yum search | zypper search | pacman -Ss |
Install Command | apt install | yum install | zypper install | pacman -S |
Update Package List | apt update | yum check-update | zypper refresh | pacman -Sy |
Upgrade Packages | apt upgrade | yum update | zypper update | pacman -Su |
Remove Package | apt remove | yum remove | zypper remove | pacman -R |
Verifying Your Actions
After performing any package management operation, you can verify it by checking the status of the package. For instance, to verify installation:
apt list --installed
|
grep package_name