A Guide to Yum and Apt on Linux


Introduction

An open-source environment is made available to users of the well-known operating system Linux so they can do a range of jobs. Two of the most popular package managers are Yum and Apt, and package management is crucial in Linux. Users can easily install, update, and uninstall software packages from their systems using any package management. Yum can be found on Red Hat-based systems like CentOS and Fedora, whereas Apt may be found on Debian-based systems like Ubuntu.

In this content, we'll look at two tools for managing packages on Linux: Yum and Apt. Learn about their purposes, results, and illustrations of efficient software package management.

Manage Packages with Yum

Yum is a command-line package manager for Red Hat-based Linux distributions like CentOS and Fedora. It stands for "Yellowdog Updater, Modified" and it provides an easy way to manage software packages and dependencies on a system.

In order to use Yum, administrative privileges or root access are required. If necessary, use the "sudo" command. Here are some basic Yum commands for getting started with package management on our system. To get you started, here are some simple Yum commands −

Updates to system packages −

$ sudo yum update

The "sudo yum update" command updates all installed packages and their dependencies on a Linux system using the Yum package manager.

Putting in a new package −

$ sudo yum install packagename

The "sudo yum install packagename" command utilises Yum package management to install a specified package, together with any required dependencies, on a Linux system.

To delete a package, use the following methods −

$ sudo yum remove packagename

To remove a single package and its dependencies from a Linux system, use the "sudo yum delete packagename" command in the Yum package management.

Trying to find a package

$ sudo yum search packagename

On a Linux system, the "sudo yum search packagename" command searches the Yum repository for packages that match a specified keyword or package name.

Manage Packages with Apt

Apt is a command-line package manager for Debian-based Linux distributions like Ubuntu. It stands for "Advanced Package Tool," and it provides an easy way to manage software packages and dependencies on a system.

In order to use Apt for managing packages on our system, administrative privileges or root access is necessary. Use "sudo" command if required to elevate privileges. Here are some basic commands to get started with Apt −

For update packages −

$ sudo apt update

The "sudo apt update" command is used on a Debian-based Linux system to update the package lists for repositories using the APT package management.

Upgrading the packages −

$ sudo apt upgrade

The "sudo apt upgrade" command is used to install any available package upgrades, making sure that all installed packages are current with the most recent releases.

New package installation process −

$ sudo apt install packagename

The "sudo apt install packagename" command installs all required packages in our Linux operating system.

For removing the specific package

$ sudo apt remove packagename

The "sudo apt remove packagename" command can be delete a single package from our Linux system at a time.

Looking for a package

$ sudo apt search packagename

The "sudo apt search packagename" command is used to search for available packages in the APT repositories that match a specific keyword or package name on a Debian-based Linux system.

List Packages with Yum and Apt

The following command can be used to list installed packages in Yum −

$ sudo yum list installed

This will yield a list of all the packages installed on our system.

Yum may be used to list available packages by running the following command −

$ sudo yum list available

A list of all the packages accessible in the Yum repository will be returned.

APT can be used from the command line to list installed packages −

$ sudo apt list --installed

This will return a list of all the packages that have been installed on our system.

To view a list of APT's readily available packages, type the following command −

$ sudo apt list --available

A list of all the packages that are available in the APT repository will be returned.

Clean Up with Yum and Apt

The "autoremove" command in Yum and APT can be used to remove packages that were installed as dependents but are no longer required since the package(s) on which they depended have been removed.

To run 'autoremove' in Yum, use the following command −

$ sudo yum autoremove

This will uninstall any orphaned packages that were installed as dependencies but are no longer required.

To perform autoremove in APT, enter the following command −

$ sudo apt autoremove

This will uninstall any packages that were installed as dependencies automatically but are no longer needed by any other installed packages.

Reinstall Package with Yum and Apt

Yum may be used to reinstall a package using the command −

$ sudo yum reinstall packagename

This will uninstall the software and then reinstall it, restoring any configuration files to their default settings.

Use the following command to reinstall a package using APT −

$ sudo apt-get install --reinstall packagename

By doing this, any configuration files will have their default settings restored after the product is uninstalled and then reinstalled.

Conclusion

In conclusion, package management is critical for Linux administration, and Yum and Apt are popular tools for managing software packages on our system. They make it simple to install, update, and delete programmes with their user-friendly interfaces and huge repositories, ensuring that our system is secure and up to date.

Updated on: 08-May-2023

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements