If you are in a situation when you want to upgrade your system, but do not want to upgrade a certain software in it you can just instruct apt not to upgrade these packages with:
apt-mark hold <package name(s)>
Here is how you can block updating 4 packages – ca-certificates, firefox, ghostscript, linux-firmware. First we update and upgrade and you can see there is no packages to keep back, and then we use apt-mark to “hold” package “linux-firmware” and ca-certificates, firefox, ghostscript at once. Initiating apt upgrade again will give you “The following packages have been kept back:” and it will include all packages, which will not be upgraded (it will include dependencies, which require some of the blocked packages).
myuser@myuser-pc:~$ sudo apt update Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease Hit:2 http://es.archive.ubuntu.com/ubuntu xenial InRelease Hit:3 http://es.archive.ubuntu.com/ubuntu xenial-updates InRelease Hit:4 http://es.archive.ubuntu.com/ubuntu xenial-backports InRelease Reading package lists... Done Building dependency tree Reading state information... Done 248 packages can be upgraded. Run 'apt list --upgradable' to see them. myuser@myuser-pc:~$ sudo apt upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following NEW packages will be installed: ubuntu-advantage-tools The following packages will be upgraded: apparmor apt apt-transport-https apt-utils apturl apturl-common bind9-host binutils ca-certificates cpp-5 cups cups-bsd cups-client cups-common cups-core-drivers cups-daemon cups-ppdc cups-server-common distro-info-data dnsutils dpkg dpkg-dev firefox fonts-opensymbol friendly-recovery fwupd g++-5 gcc-5 gcc-5-base gettext gettext-base ghostscript ghostscript-x gir1.2-javascriptcoregtk-4.0 gir1.2-packagekitglib-1.0 gir1.2-webkit2-4.0 gnupg gpgv hwdata imagemagick imagemagick-6.q16 imagemagick-common initramfs-tools initramfs-tools-bin initramfs-tools-core intel-microcode iproute2 kmod libapparmor-perl libapparmor1 libappstream-glib8 libapt-inst2.0 libapt-pkg5.0 libarchive13 libasan2 libasprintf-dev libasprintf0v5 libatomic1 libbind9-140 libcapnp-0.5.3 libcc1-0 libcilkrts5 libcups2 libcupscgi1 libcupsimage2 libcupsmime1 libcupsppdc1 libcurl3 libcurl3-gnutls libdfu1 libdns-export162 libdns162 libdpkg-perl libexiv2-14 libfreerdp-cache1.1 libfreerdp-client1.1 libfreerdp-codec1.1 libfreerdp-common1.1.0 libfreerdp-core1.1 libfreerdp-crypto1.1 libfreerdp-gdi1.1 libfreerdp-locale1.1 libfreerdp-plugins-standard libfreerdp-primitives1.1 libfreerdp-utils1.1 libfwupd1 libgcc-5-dev libgd3 libgettextpo-dev libgettextpo0 libglib2.0-0 libglib2.0-bin libglib2.0-data libgomp1 libgs9 libgs9-common libisc-export160 libisc160 libisccc140 libisccfg140 libitm1 libjavascriptcoregtk-4.0-18 libkmod2 libkpathsea6 liblcms2-2 liblcms2-utils libldap-2.4-2 liblouis-data liblouis9 liblsan0 liblwres141 libmagickcore-6.q16-2 libmagickcore-6.q16-2-extra libmagickwand-6.q16-2 libmpx0 libnm-glib-vpn1 libnm-glib4 libnm-util2 libnm0 libnss3 libnss3-nssdb libnux-4.0-0 libnux-4.0-common libpackagekit-glib2-16 libpam-systemd libperl5.22 libpoppler-glib8 libpoppler58 libpython2.7 libpython2.7-minimal libpython2.7-stdlib libpython3.5 libpython3.5-minimal libpython3.5-stdlib libquadmath0 libraw15 libreoffice-avmedia-backend-gstreamer libreoffice-base-core libreoffice-calc libreoffice-common libreoffice-core libreoffice-draw libreoffice-gnome libreoffice-gtk libreoffice-impress libreoffice-math libreoffice-ogltrans libreoffice-pdfimport libreoffice-style-breeze libreoffice-style-galaxy libreoffice-writer libsasl2-2 libsasl2-modules libsasl2-modules-db libsmbclient libsnapd-glib1 libsnmp-base libsnmp30 libssh-4 libssl1.0.0 libstdc++-5-dev libstdc++6 libsystemd0 libtsan0 libubsan0 libudev1 libunity-settings-daemon1 libwavpack1 libwbclient0 libwebkit2gtk-4.0-37 libwebkit2gtk-4.0-37-gtk2 libwinpr-crt0.1 libwinpr-dsparse0.1 libwinpr-environment0.1 libwinpr-file0.1 libwinpr-handle0.1 libwinpr-heap0.1 libwinpr-input0.1 libwinpr-interlocked0.1 libwinpr-library0.1 libwinpr-path0.1 libwinpr-pool0.1 libwinpr-registry0.1 libwinpr-rpc0.1 libwinpr-sspi0.1 libwinpr-synch0.1 libwinpr-sysinfo0.1 libwinpr-thread0.1 libwinpr-utils0.1 libx11-6 libx11-data libx11-xcb1 libxcursor1 libxkbcommon-x11-0 libxkbcommon0 libxml2 linux-firmware linux-libc-dev mokutil network-manager nux-tools openssl perl perl-base perl-modules-5.22 poppler-utils ppp python2.7 python2.7-minimal python3-cryptography python3-distupgrade python3-louis python3-lxml python3-requests python3-software-properties python3-uno python3-update-manager python3-urllib3 python3.5 python3.5-minimal samba-libs secureboot-db snapd-login-service software-properties-common software-properties-gtk squashfs-tools systemd systemd-sysv tzdata ubuntu-desktop ubuntu-minimal ubuntu-release-upgrader-core ubuntu-release-upgrader-gtk ubuntu-standard udev unity-settings-daemon uno-libs3 update-manager update-manager-core update-notifier update-notifier-common ure wpasupplicant x11-common xorg xserver-common xserver-xorg-core-hwe-16.04 xserver-xorg-legacy-hwe-16.04 248 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 301 MB of archives. After this operation, 13,5 MB of additional disk space will be used. Do you want to continue? [Y/n] n Abort. myuser@myuser-pc:~$ sudo apt-mark hold linux-firmware linux-firmware set on hold. myuser@myuser-pc:~$ sudo apt-mark hold ca-certificates firefox ghostscript ca-certificates set on hold. firefox set on hold. ghostscript set on hold. myuser@myuser-pc:~$ sudo apt-mark showhold ca-certificates firefox ghostscript linux-firmware myuser@myuser-pc:~$ sudo apt upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following NEW packages will be installed: ubuntu-advantage-tools The following packages have been kept back: ca-certificates firefox ghostscript ghostscript-x libgs9 linux-firmware The following packages will be upgraded: apparmor apt apt-transport-https apt-utils apturl apturl-common bind9-host binutils cpp-5 cups cups-bsd cups-client cups-common cups-core-drivers ..... ..... ..... x11-common xorg xserver-common xserver-xorg-core-hwe-16.04 xserver-xorg-legacy-hwe-16.04 242 upgraded, 1 newly installed, 0 to remove and 6 not upgraded. Need to get 202 MB of archives. After this operation, 2.255 kB of additional disk space will be used. Do you want to continue? [Y/n]
To remove the blocking of the above packages use “unhold”:
myuser@myuser-pc:~$ sudo apt-mark unhold ca-certificates firefox ghostscript linux-firmware Canceled hold on ca-certificates. Canceled hold on firefox. Canceled hold on ghostscript. Canceled hold on linux-firmware. myuser@myuser-pc:~$ sudo apt-mark showhold myuser@myuser-pc:~$
Multiple packages with wildcard *
You can hold packages with a wildcard * if you want to block updating a group of packages:
myuser@myuser-pc:~$ sudo apt-mark hold libreoffice-* libreoffice-gtk3 set on hold. libreoffice-core set on hold. libreoffice-writer set on hold. libreoffice-avmedia-backend-gstreamer set on hold. libreoffice-base set on hold. libreoffice-base-core set on hold. libreoffice-base-drivers set on hold. libreoffice-java-common set on hold. libreoffice-report-builder set on hold. libreoffice-common set on hold. libreoffice-sdbc-firebird set on hold. libreoffice-sdbc-hsqldb set on hold. libreoffice-mysql-connector set on hold. libreoffice-sdbc-postgresql set on hold. libreoffice-calc set on hold. libreoffice-pdfimport set on hold. libreoffice-script-provider-bsh set on hold. libreoffice-script-provider-js set on hold. libreoffice-script-provider-python set on hold. libreoffice-style-breeze set on hold. libreoffice-style-galaxy set on hold. libreoffice-style-hicontrast set on hold. libreoffice-style-human set on hold. libreoffice-style-oxygen set on hold. libreoffice-style-tango set on hold. libreoffice-wiki-publisher set on hold. libreoffice-writer2latex set on hold. libreoffice-writer2xhtml set on hold. libreoffice-style-sifr set on hold. libreoffice-dev set on hold. libreoffice-draw set on hold. libreoffice-gnome set on hold. libreoffice-gtk set on hold. libreoffice-impress set on hold. libreoffice-kde set on hold. libreoffice-officebean set on hold. libreoffice-dbg set on hold. libreoffice-dev-doc set on hold. libreoffice-style-elementary set on hold. libreoffice-help-ca set on hold. libreoffice-l10n-ca set on hold. libreoffice-help-cs set on hold. libreoffice-l10n-cs set on hold. libreoffice-help-da set on hold. libreoffice-l10n-da set on hold. libreoffice-help-de set on hold. libreoffice-l10n-de set on hold. libreoffice-help-dz set on hold. libreoffice-l10n-dz set on hold. libreoffice-help-el set on hold. libreoffice-l10n-el set on hold. libreoffice-help-en-gb set on hold. libreoffice-l10n-en-gb set on hold. libreoffice-help-en-us set on hold. libreoffice-help-es set on hold. libreoffice-l10n-es set on hold. libreoffice-help-et set on hold. libreoffice-l10n-et set on hold. libreoffice-help-eu set on hold. libreoffice-l10n-eu set on hold. libreoffice-help-fi set on hold. libreoffice-l10n-fi set on hold. libreoffice-help-fr set on hold. libreoffice-l10n-fr set on hold. libreoffice-help-gl set on hold. libreoffice-l10n-gl set on hold. libreoffice-help-hi set on hold. libreoffice-l10n-hi set on hold. libreoffice-help-hu set on hold. libreoffice-l10n-hu set on hold. libreoffice-help-it set on hold. libreoffice-l10n-it set on hold. libreoffice-help-ja set on hold. libreoffice-l10n-ja set on hold. libreoffice-help-km set on hold. libreoffice-l10n-km set on hold. libreoffice-help-ko set on hold. libreoffice-l10n-ko set on hold. libreoffice-help-nl set on hold. libreoffice-l10n-nl set on hold. libreoffice-help-om set on hold. libreoffice-l10n-om set on hold. libreoffice-help-pl set on hold. libreoffice-l10n-pl set on hold. libreoffice-help-pt set on hold. libreoffice-l10n-pt set on hold. libreoffice-help-pt-br set on hold. libreoffice-l10n-pt-br set on hold. libreoffice-help-ru set on hold. libreoffice-l10n-ru set on hold. libreoffice-help-sk set on hold. libreoffice-l10n-sk set on hold. libreoffice-help-sl set on hold. libreoffice-l10n-sl set on hold. libreoffice-help-sv set on hold. libreoffice-l10n-sv set on hold. libreoffice-help-tr set on hold. libreoffice-l10n-tr set on hold. libreoffice-help-vi set on hold. libreoffice-l10n-vi set on hold. libreoffice-help-zh-cn set on hold. libreoffice-l10n-zh-cn set on hold. libreoffice-help-zh-tw set on hold. libreoffice-l10n-zh-tw set on hold. libreoffice-l10n-af set on hold. libreoffice-l10n-am set on hold. libreoffice-l10n-ar set on hold. libreoffice-l10n-as set on hold. libreoffice-l10n-ast set on hold. libreoffice-l10n-be set on hold. libreoffice-l10n-bg set on hold. libreoffice-l10n-bn set on hold. libreoffice-l10n-br set on hold. libreoffice-l10n-bs set on hold. libreoffice-l10n-cy set on hold. libreoffice-l10n-en-za set on hold. libreoffice-l10n-eo set on hold. libreoffice-l10n-fa set on hold. libreoffice-l10n-ga set on hold. libreoffice-l10n-gd set on hold. libreoffice-l10n-gu set on hold. libreoffice-l10n-gug set on hold. libreoffice-l10n-he set on hold. libreoffice-l10n-hr set on hold. libreoffice-l10n-id set on hold. libreoffice-l10n-in set on hold. libreoffice-l10n-ml set on hold. libreoffice-l10n-mr set on hold. libreoffice-l10n-or set on hold. libreoffice-l10n-pa-in set on hold. libreoffice-l10n-ta set on hold. libreoffice-l10n-te set on hold. libreoffice-l10n-is set on hold. libreoffice-l10n-ka set on hold. libreoffice-l10n-kk set on hold. libreoffice-l10n-kmr-latn set on hold. libreoffice-l10n-lt set on hold. libreoffice-l10n-lv set on hold. libreoffice-l10n-mk set on hold. libreoffice-l10n-mn set on hold. libreoffice-l10n-nb set on hold. libreoffice-l10n-ne set on hold. libreoffice-l10n-nn set on hold. libreoffice-l10n-nr set on hold. libreoffice-l10n-nso set on hold. libreoffice-l10n-oc set on hold. libreoffice-l10n-ro set on hold. libreoffice-l10n-rw set on hold. libreoffice-l10n-si set on hold. libreoffice-l10n-sr set on hold. libreoffice-l10n-ss set on hold. libreoffice-l10n-st set on hold. libreoffice-l10n-tg set on hold. libreoffice-l10n-th set on hold. libreoffice-l10n-tn set on hold. libreoffice-l10n-ts set on hold. libreoffice-l10n-ug set on hold. libreoffice-l10n-uk set on hold. libreoffice-l10n-uz set on hold. libreoffice-l10n-ve set on hold. libreoffice-l10n-xh set on hold. libreoffice-l10n-za set on hold. libreoffice-l10n-zu set on hold. libreoffice-math set on hold. libreoffice-nlpsolver set on hold. libreoffice-ogltrans set on hold. libreoffice-voikko set on hold. libreoffice-report-builder-bin set on hold. libreoffice-canzeley-client set on hold. libreoffice-dmaths set on hold. libreoffice-librelogo set on hold. libreoffice-lightproof-en set on hold. libreoffice-lightproof-hu set on hold. libreoffice-lightproof-ru-ru set on hold. libreoffice-subsequentcheckbase set on hold. libreoffice-templates set on hold. libreoffice-zemberek set on hold. myuser@myuser-pc:~$ sudo apt upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following NEW packages will be installed: ubuntu-advantage-tools The following packages have been kept back: libreoffice-avmedia-backend-gstreamer libreoffice-base-core libreoffice-calc libreoffice-common libreoffice-core libreoffice-draw libreoffice-gnome libreoffice-gtk libreoffice-impress libreoffice-math libreoffice-ogltrans libreoffice-pdfimport libreoffice-style-breeze libreoffice-style-galaxy libreoffice-writer python3-uno The following packages will be upgraded: apparmor apt apt-transport-https apt-utils apturl apturl-common bind9-host binutils ca-certificates cpp-5 cups cups-bsd cups-client cups-common cups-core-drivers cups-daemon cups-ppdc cups-server-common distro-info-data dnsutils dpkg dpkg-dev firefox fonts-opensymbol friendly-recovery fwupd g++-5 gcc-5 gcc-5-base gettext gettext-base ghostscript ghostscript-x gir1.2-javascriptcoregtk-4.0 gir1.2-packagekitglib-1.0 gir1.2-webkit2-4.0 gnupg gpgv hwdata imagemagick imagemagick-6.q16 imagemagick-common initramfs-tools initramfs-tools-bin initramfs-tools-core intel-microcode iproute2 kmod libapparmor-perl libapparmor1 libappstream-glib8 libapt-inst2.0 libapt-pkg5.0 libarchive13 libasan2 libasprintf-dev libasprintf0v5 libatomic1 libbind9-140 libcapnp-0.5.3 libcc1-0 libcilkrts5 libcups2 libcupscgi1 libcupsimage2 libcupsmime1 libcupsppdc1 libcurl3 libcurl3-gnutls libdfu1 libdns-export162 libdns162 libdpkg-perl libexiv2-14 libfreerdp-cache1.1 libfreerdp-client1.1 libfreerdp-codec1.1 libfreerdp-common1.1.0 libfreerdp-core1.1 libfreerdp-crypto1.1 libfreerdp-gdi1.1 libfreerdp-locale1.1 libfreerdp-plugins-standard libfreerdp-primitives1.1 libfreerdp-utils1.1 libfwupd1 libgcc-5-dev libgd3 libgettextpo-dev libgettextpo0 libglib2.0-0 libglib2.0-bin libglib2.0-data libgomp1 libgs9 libgs9-common libisc-export160 libisc160 libisccc140 libisccfg140 libitm1 libjavascriptcoregtk-4.0-18 libkmod2 libkpathsea6 liblcms2-2 liblcms2-utils libldap-2.4-2 liblouis-data liblouis9 liblsan0 liblwres141 libmagickcore-6.q16-2 libmagickcore-6.q16-2-extra libmagickwand-6.q16-2 libmpx0 libnm-glib-vpn1 libnm-glib4 libnm-util2 libnm0 libnss3 libnss3-nssdb libnux-4.0-0 libnux-4.0-common libpackagekit-glib2-16 libpam-systemd libperl5.22 libpoppler-glib8 libpoppler58 libpython2.7 libpython2.7-minimal libpython2.7-stdlib libpython3.5 libpython3.5-minimal libpython3.5-stdlib libquadmath0 libraw15 libsasl2-2 libsasl2-modules libsasl2-modules-db libsmbclient libsnapd-glib1 libsnmp-base libsnmp30 libssh-4 libssl1.0.0 libstdc++-5-dev libstdc++6 libsystemd0 libtsan0 libubsan0 libudev1 libunity-settings-daemon1 libwavpack1 libwbclient0 libwebkit2gtk-4.0-37 libwebkit2gtk-4.0-37-gtk2 libwinpr-crt0.1 libwinpr-dsparse0.1 libwinpr-environment0.1 libwinpr-file0.1 libwinpr-handle0.1 libwinpr-heap0.1 libwinpr-input0.1 libwinpr-interlocked0.1 libwinpr-library0.1 libwinpr-path0.1 libwinpr-pool0.1 libwinpr-registry0.1 libwinpr-rpc0.1 libwinpr-sspi0.1 libwinpr-synch0.1 libwinpr-sysinfo0.1 libwinpr-thread0.1 libwinpr-utils0.1 libx11-6 libx11-data libx11-xcb1 libxcursor1 libxkbcommon-x11-0 libxkbcommon0 libxml2 linux-firmware linux-libc-dev mokutil network-manager nux-tools openssl perl perl-base perl-modules-5.22 poppler-utils ppp python2.7 python2.7-minimal python3-cryptography python3-distupgrade python3-louis python3-lxml python3-requests python3-software-properties python3-update-manager python3-urllib3 python3.5 python3.5-minimal samba-libs secureboot-db snapd-login-service software-properties-common software-properties-gtk squashfs-tools systemd systemd-sysv tzdata ubuntu-desktop ubuntu-minimal ubuntu-release-upgrader-core ubuntu-release-upgrader-gtk ubuntu-standard udev unity-settings-daemon uno-libs3 update-manager update-manager-core update-notifier update-notifier-common ure wpasupplicant x11-common xorg xserver-common xserver-xorg-core-hwe-16.04 xserver-xorg-legacy-hwe-16.04 232 upgraded, 1 newly installed, 0 to remove and 16 not upgraded. Need to get 229 MB of archives. After this operation, 13,5 MB of additional disk space will be used. Do you want to continue? [Y/n] ..... ..... .....
Old Ubuntu/Debian versions
Here what you can use if you miss “apt-mark”
echo <package> install | sudo dpkg --set-selections