ubuntu, updated

Packages and updates

Install, remove and update software with apt, find which package owns a file, and handle reboots and automatic updates.

The idea

Software comes as packages from repositories (download servers). apt downloads them, resolves dependencies and keeps track of what is installed. apt update only refreshes the list of available versions; apt upgrade actually installs them.

apt cheat sheet

WhatCommand
Refresh package listssudo apt update
Install all updatessudo apt upgrade
Updates incl. new dependencies / removalssudo apt full-upgrade
Installsudo apt install nginx
Remove (keep config)sudo apt remove nginx
Remove incl. configsudo apt purge nginx
Remove unused dependenciessudo apt autoremove
Searchapt search keyword
Details / versionapt show nginx
What can be updated?apt list --upgradable
Is it installed?apt list --installed | grep nginx
Which files did a package install?dpkg -L nginx
Which package owns this file?dpkg -S /usr/sbin/nginx
Install a downloaded .debsudo apt install ./file.deb
Keep a package at its versionsudo apt-mark hold PACKAGE (unhold to undo)

Reboot needed?

After kernel or library updates:

cat /var/run/reboot-required.pkgs 2>/dev/null || echo "no reboot needed"

Automatic security updates

Ubuntu Server installs unattended-upgrades by default. It installs security updates daily, but does not reboot unless you allow it.

systemctl status unattended-upgrades
less /var/log/unattended-upgrades/unattended-upgrades.log

Settings are in /etc/apt/apt.conf.d/50unattended-upgrades (e.g. Automatic-Reboot).

Snaps

Some software (e.g. lxd) comes as a snap: a self-contained package that updates itself.

WhatCommand
List snapssnap list
Install / removesudo snap install NAME / sudo snap remove NAME
Update nowsudo snap refresh

Upgrade to the next Ubuntu release

sudo apt update && sudo apt full-upgrade
sudo do-release-upgrade

Run it inside tmux (see Terminal shortcuts) and take a snapshot first. By default you are only offered the next LTS release once its first point release is out.

§ home
~/knubertus/home/
1,1 Top