Packet management in Linux
Understanding how to manage Linux packages using APT, YUM, and DNF is a key skill for system administrators and developers who use a Linux environment. It allows you to manage your installation, upgrade, or remove packages and their dependencies, ensuring that the operating system and applications function properly.
Knowledge of these tools also helps with system upgrades, managing package repositories, and software security.
Be careful when changing system repositories and connecting third-party repositories – such changes may cause errors when updating the ispmanager panel or installing software through the panel.
Package management with APT
APT (Advanced Package Tool) is a package management tool that is used in most Debian- and Ubuntu-based distributions.
Basic apt commands:
| Command | Description |
|---|---|
| apt update | Updates the list of available packages from the repositories |
| apt upgrade | Updates all installed packages to the latest versions |
| apt install <имя_пакета> | Installs or updates a specified package from the repositories |
| apt remove <имя_пакета> | Removes the specified package, leaving the configuration files |
| apt purge <имя_пакета> | Removes the specified package, removing all configuration files |
| apt search <слово> | Searches the repositories for packages by keyword |
| apt show <имя_пакета> | Shows detailed information about a package |
| apt --reinstall install <имя_пакета> | Reinstalls an already installed package |
| UCF_FORCE_CONFFMISS=1 apt-get --reinstall install <имя_пакета> | Reinstall a package and restore the configuration files if the key --reinstall did not work |
The part UCF_FORCE_CONFFMISS=1 sets the UCF_FORCE_CONFFMISS environment variable to 1, which tells the program ucf to ignore changes to configuration files and accept them by default if they don't exist.
To manage repositories in Debian and Ubuntu, use the main file /etc/apt/sources.list and the files in the directory /etc/apt/sources.list.d/ - they contain information about the repositories from which APT installs packages.
You can create new .list files to add new repositories, or edit the existing files to change the current repositories.
Package management with YUM
YUM (Yellowdog Updater, Modified) is a package management tool used in CentOS, AlmaLinux, Fedora, and other RedHat-based distributions.
The basic YUM commands are:
| Command | Description |
|---|---|
| yum update | Updates all installed packages to the latest versions from the repositories |
| yum install <имя_пакета> | Installs the specified package from the repositories |
| yum remove <имя_пакета> | Removes the specified package |
| yum search <слово> | Searches the repositories for packages by keyword |
| yum info <имя_пакета> | Shows detailed information about the package |
| yum history | This command provides the ability to view a list of package transactions on the system including installation, upgrade, and uninstallation |
| yum history info <имя_пакета> | Shows a detailed history of the package manager command number or displays the history of the specified package |
| yumdownloader -q --urls <имя_пакета> | Used to retrieve URLs for downloading a package (repositories), but without actually downloading the package itself |
In Red Hat distributions, repository files are usually located in the /etc/yum.repos.d/ directory.
You can create new files with the extension .repo to add new repositories, or edit existing files to modify the current repositories.
Package management with DNF
DNF (Dandified YUM) is a next-generation package management tool that provides a faster and more modern approach to package management in Red Hat-based distributions.
Although DNF provides similar features as YUM, it has a number of additional features and enhancements.
Some basic DNF commands are:
| Command | Description |
|---|---|
| dnf upgrade | Upgrades all installed packages to the latest versions from the repositories |
| dnf install <имя_пакета> | Installs the specified package from the repositories |
| dnf remove <имя_пакета> | Removes the specified package |
| dnf search <слово> | Searches the repositories for packages by keyword |
| dnf info <имя_пакета> | Displays detailed information about the package |
In distributions that use DNF, the repository configuration files are usually located in the directory /etc/yum.repos.d/, similar to YUM.
You can modify or add files with the .repo extension in this directory to configure access to different repositories.
DNF offers a more modern and efficient way to manage packages on Red Hat-based systems, while retaining the convenience and reliability of YUM. Using DNF is recommended for more up-to-date versions of Linux distributions such as AlmaLinux.