Skip to content

Instantly share code, notes, and snippets.

@henri
Last active May 4, 2025 22:32
Show Gist options
  • Save henri/eb26bf5c1b78d73e0bf7fb89424c325a to your computer and use it in GitHub Desktop.
Save henri/eb26bf5c1b78d73e0bf7fb89424c325a to your computer and use it in GitHub Desktop.
apt cheat sheet
### APT Tips (tested only on Ubuntu)
##
## Problem :
## The following packages have been kept back
##
## Possible Solutions (depending on the situation) :
# non-manual upgrade of kept back packages (safest) :
sudo apt-get --with-new-pkgs upgrade
sudo apt-get --with-new-pkgs upgrade <list of packages kept back>
# upgrade / install of new package version (not as great but is sometimes needed) :
sudo apt-get install <packages which you will force upgarde / install>
# list installed version of particular package
sudo apt-cache policy <package-name>
sudo apt list -a <package-name>
# search for available versions of a particular pacakge
# install rmadison from devscripts package eg :
# sudo apt-get install devscripts
sudo rmadison <package-name>
# upgrade to specific version of PHP (for example) - use policy example above to find the available versions
sudo apt-get install php5=5.5.16+dfsg-1+deb.sury.org~precise+2
# use aptitude to upgrade
sudo aptitude (then click "+" "+" "g" "g" then proceed by saying yes and finally quit aptitude).
# dist-upgrade approach - danger will robbinson this can break stuff :
sudo apt-get dist-upgrade
# maybe just upate single package
sudo apt-get install --only-upgrade <package-name>
# enable auto updates on ubuntu (you will want to edit the file to configure things how you like)
sudo apt install unattended-upgrades && vim /etc/apt/apt.conf.d/50unattended-upgrades
# if you have errors like
# dpkg: error processing package update-notifier-common (--configure):
# installed update-notifier-common package post-installation script subprocess returned error exit status 1
# Errors were encountered while processing:
# update-notifier-common
# E: Sub-process /usr/bin/dpkg returned an error code (1)
cd /var/lib/dpkg
sudo mv -i info info.bak
sudo mkdir info
sudo apt-get upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment