Install, Remove, Update & Configure Packages in CentOS, Ubuntu & Linux

In this chapter, you will learn

  1. What are the different types of package manager?
  2. What are the apt, dnf, and yum package manager and how to use it?
  3. What are the dpkg and rpm package managers?

The package manager within a Linux distribution is a crucial feature that empowers users to effortlessly install, remove, update, upgrade, or configure applications. Various Linux distributions employ distinct package managers; for instance, Ubuntu utilizes apt, while CentOS relies on yum, each tailored to the specific needs of its distribution.

In this tutorial, we will explore various types of package managers and their respective uses.

apt and apt-get Package Manager - Ubuntu/Debian/Kali/Linux-Mint

The Advanced Packaging Tool (apt) is a widely used package management tool with Ubuntu, Debian, Kali, and Linux Mint operating systems. It's handy for tasks like installing, removing, updating, or configuring .deb (Debian) packages.

You can operate this package manager using the apt and apt-get command line option as follows:

1. apt & apt-get Command Options


1. Install a package:
apt
sudo apt install package_name
apt-get
sudo apt-get install package_name

2. Remove a package:
apt
sudo apt remove package_name
apt-get
sudo apt-get remove package_name

3. Remove package with its configuration file
apt
sudo apt purge package_name
apt-get
sudo apt-get purge package_name

4. Update Package Lists:
apt
sudo apt update
apt-get
sudo apt-get update

5. Upgrade Installed Packages
apt
sudo apt upgrade
apt-get
sudo apt-get upgrade

6. Full System Upgrade:
apt
sudo apt dist-upgrade
apt-get
sudo apt-get dist-upgrade

7. Search for a Package:
apt
sudo apt search search_term
apt-get
sudo apt-cache search search_term

8. Show Package Information:
apt
sudo apt show package_name
apt-get
sudo apt-cache show package_name

9. List Installed Packages:
apt
sudo apt list --installed

10. Clean Package Cache:
apt
sudo apt clean
apt-get
sudo apt-get clean

11. Autoremove Unused Packages:
apt
sudo apt autoremove
apt-get
sudo apt-get autoremove

2. yum Package Manager

The yum package manager is used for installing, removing, and managing packages in Red Hat based OS such as RHEL, CentOS, and Fedora. This tool is used for managing .rpm packages.

yum Command Options

# Uses yum
1 Install a package
sudo yum install package_name
2 Remove a Package:
sudo yum remove package_name
3 Update Installed Packages:
sudo yum update
4 Search for a Package:
sudo yum search search_term
5 List Installed Packages:
sudo yum list installed
6 Show Package Information:
sudo yum info package_name
7 Clean Package Cache:
sudo yum clean all

3. dnf Package Manager

The dnf stands for "Dandified yum". It is the more advanced version of yum and provides a more modern and improved package management experience compared to yum.

dnf Command Options

# Uses dnf
1 Install a package
sudo dnf install package_name
2 Remove a Package:
sudo dnf remove package_name
3 Upgrade Installed Packages:
sudo dnf upgrade
4 Search for a Package:
sudo dnf search search_term
5 List Installed Packages:
sudo dnf list installed
6 Show Package Information:
sudo dnf info package_name
7 Clean Package Cache:
sudo dnf clean all
8 Check for updates:
sudo dnf check-update
9 List Repositories:
sudo dnf repolist

4. ZYPPER Package Manager

zypper is the package management tool used in openSUSE and SUSE Linux Enterprise. Here are some common command line options for zypper:

zypper Command Options

# Uses zypper
1 Install a package
sudo zypper install package_name
2 Remove a Package:
sudo zypper remove package_name
3 Update Installed Packages:
sudo zypper update
4 Search for a Package:
sudo zypper search search_term
5 List Installed Packages:
sudo zypper list installed
6 Show Package Information:
sudo zypper info package_name
7 Clean Package Cache:
sudo zypper clean
8 Refresh Package Manager
sudo zypper refresh
9 List Repositories:
sudo zypper repos

Summary:

In this tutorial, you've explored different package managers designed for various Linux distributions. You've also acquired insights into utilizing these package managers through a range of command line options, empowering you to efficiently perform tasks like updating, upgrading, installing, removing, and managing packages on your system.