Rocky or Alma Linux are the best Linux distros for servers. They offer both stability and reliability for a wide range of software. Managing packages is the most essential part when it comes to Linux. Packages are the collection of libraries, applications, and other components that make it functional.
In this article, we will learn how to install and remove packages from Rocky or Alma Linux
Rocky and Alma, Linux uses DNF (Dandified YUM) to manage packages. DNF is developed keeping performance in mind. It has the best algorithm to work with dependencies.
Prerequisites
Rocky or Alma Linux installed in the system with sudo or root user
Updating Package Information
In Linux, updating package information is the most important step before installing any package. If not done, you may experience errors like package not found.
You can check the list of available updates for your system using
$ sudo dnf check-update
To update, execute
$ sudo dnf update -y
Installing Packages
To install packages, you can follow “dnf install” syntax
$ sudo dnf install [Package-Name]
For example, you want to install PHP, execute the following command
$ sudo dnf install php
Removing Packages
To remove any package from Rocky or Alma Linux, you can follow the “dnf remove” syntax
$ sudo dnf remove [Package-Name]
For example, if you want to remove PHP, execute the following command
$ sudo dnf remove php
Removing Unnecessary Packages
To remove unnecessary packages, you can use “dnf autoremove” syntax. Autoremove syntax scans your system and lists out the packages that aren’t needed and have no dependencies. So, it is safe to remove them
$ sudo dnf autoremove
Execute the command and it will remove the packages automatically.