How do I avoid installing the recommended packages and suggested packages along with upgrading the packages when I apt-get install
a particular package?
2 Answers
Suggested packages are not installed by default, to install suggested packages you need to explicitly use --install-suggests
option (or set APT::Install-Suggests yes
apt configuration parameter).
Now, to avoid installing Recommended packages, either use --no-install-recommends
option with apt-get
or set APT::Install-Recommends "0"
in anyplace referred by Dir::Etc::Main
(typically /etc/apt/apt.conf
) or Dir::Etc::Parts
(typically /etc/apt/apt.conf.d/
.
Similarly, to avoid upgrading packages, either use --no-upgrade
option with apt-get
or set APT::Get::Upgrade "0"
in anyplace referred by Dir::Etc::Main
or Dir::Etc::Parts
.
In a nutshell, with apt-get
:
sudo apt-get install --no-install-recommends --no-upgrade <package_name>

- 91,753
In other to install a package without the recommended packages is to run the install command with the --no-install-recommends
option like this:
sudo apt-get install --no-install-recommends package_name
Don't upgrade packages:
sudo apt-get install --no-upgrade pkg_name
Don't install new packages:
sudo apt-get install --only-upgrade pkg_name
--no-upgrade:
Do not upgrade packages; when used in conjunction with install, no-upgrade will prevent packages on the command line from being upgraded if they are already installed. Configuration Item: APT::Get::Upgrade.
--only-upgrade:
Do not install new packages; when used in conjunction with install, only-upgrade will install upgrades for already installed packages only and ignore requests to install new packages. Configuration Item: APT::Get::Only-Upgrade.
So to achieve what your asking:
sudo apt-get install --no-install-recommends --no-upgrade pkg_name
Source: man apt-get

- 36,677
-
Thanks ! but how about suggested ones and packages that will be upgraded? How do I avoid those? – samhitha Feb 27 '17 at 04:47
apt-mark hold package-that-apt-should-leave-alone
. hold hold is used to mark a package as held back, which will prevent the package from being automatically installed, upgraded or removed. – masterxilo Aug 14 '22 at 12:08