Skip to content

Package Management in RedHat/CentOS/Fedora

Fedora —> CentOS Stream —> RHEL

RPM package Format

.rpm file includes all configuration and files required to install software packages

https://mirror.stream.centos.org

AppStream more outer softwares, and BaseOS more core softwares

inspect rpm file

rpm -qpl package.rpm

Install rpm file

rpm -i package.rpm

Remove or uninstall rpm package

rpm -e package.rpm

DNF (Dandified Yum)

ls -al $(which dnf yum)

Search package name

sudo dnf search <package>

Install epel

sudo dnf config-manager --set-enabled crb
sudo dnf install epel-release

Repositories in RHEL / CentOS / Fedora

yum and dnf will search packages in the repositories configured in /etc/dnf/dnf.conf or /etc/yum.repos.d/*.repo

:::info Need not required refresh of the repositories, everytime we install the package or upgrade the repositories definition list gets refreshed :::

Check what functionality a package can provide to the system

dnf repoquery --provides <package-name>

What provides filesystem

dnf repoquery --whatprovides filesystem

Check what functionality is required by the package if it is to be installes

sudo dnf repoquery --requires <package-name>

What requires by package

dnf repoquery --whatrequires package

Level of Dependencies

dnf repoquery --recommends packagename and dnf repoquery --suggests <package-name>

Disable weak dependencies

In the file /etc/dnf/dnf.conf make this false install_weak_deps=False or add it manually in new line

or use command dnf install <package-name> —setopt=install_weak_deps=False

:::info Pre-Install Dependency > Dependency > Recommends > Suggest :::


Remove / Keep dependencies while uninstall

clean_requiements_on_remove=False then run dnf autoremove

Remove package not dependency

sudo dnf remove <package> --noautoremove

Marking package to be installed by user

  • When any package is installed, all its dependencies are marked as dependencies
  • When any dependencies are installed using dnf or yum then it will be marked as dependency
  • When any dependencies are installed using apt then it will be marked as user installed package
  • To make any dependency to be marked as user installed using dnf or yum, the run
    dnf mark install <package>
  • While removing packages, marked packages will not be removes even if it is dependency

Update and downgrade in RHEL / FEDORA / CentOS

Downgrade

dnf downgrade <package>

dnf downgrade <package-version>

List duplicates:

dnf list python3 —showduplicates


Prevent Packages from upgrade

dnf upgrade --exclude=python3

or dnf upgrade --exclude=python3,other-packages

Exclude permanently

in /etc/dnf/dnf.conf

Paste this line

excludepkgs\=[packages]


Automatically keep the system upto date

sudo dnf install dnf-automatic
sudo vim /etc/dnf/automatic.conf
sudo systemctl enable --now dnf-automatic.timer

DNF Modules

dnf module list

dnf module enable [module]:[stream]/[profile]

dnf module remove --all <nodejs>

dnf module disable <package>

dnf module reset <packages>


Repository: epel-release

EPEL: Extra Package for Enterprise Linux

This is community driven project,

Enable epel-release

sudo dnf config-manager --set-enabled crb
sudo dnf install epel-release epel-next-release