Excluding/Including the packages v17
Different Linux distributions handle recommended or weak dependencies uniquely. This provides instructions on how to include or exclude these dependencies during package installation.
Adjusting these settings allows for more control over package installations, which can be particularly useful for creating minimal environments or reducing unnecessary package bloat.
RHEL/Rocky Linux/AlmaLinux
Exclude Weak Dependencies Temporarily:
To prevent DNF from installing weak dependencies during a single operation:
dnf --setopt=install_weak_deps=False install <package-name>
Exclude Weak Dependencies Permanently:
To disable the installation of weak dependencies system-wide:
Open the DNF configuration file:
sudo nano /etc/dnf/dnf.conf
Add the following line:
install_weak_deps=False
This setting ensures that weak dependencies are not installed by default.
SLES
Exclude Recommended Packages Temporarily:
To install only the required packages without recommended ones:
zypper install --no-recommends <package-name>
Include Recommended Packages Explicitly:
To ensure both required and recommended packages are installed:
zypper install --recommends <package-name>
Configure Default Behavior:
To change the default behavior of Zypper regarding recommended packages:
Edit the Zypper configuration file:
sudo nano /etc/zypp/zypp.conf
Set the following option:
solver.onlyRequires = true
This configuration ensures that only required packages are installed by default.
Debian/Ubuntu
Exclude Recommended Packages Temporarily:
To install a package without its recommended dependencies:
apt-get install --no-install-recommends <package-name>
Set Default Behavior:
To prevent APT from installing recommended packages by default:
Create a new configuration file:
sudo nano /etc/apt/apt.conf.d/99norecommends
Add the following lines:
APT::Install-Recommends "false"; APT::Install-Suggests "false";
This configuration disables the automatic installation of recommended and suggested packages.
- On this page
- RHEL/Rocky Linux/AlmaLinux
- SLES
- Debian/Ubuntu