Help Running your server Care and troubleshooting
Keep your server updated
Update by hand, install security fixes automatically, tell when a reboot is needed, and reboot at a time that suits you.
Most break-ins use holes fixed weeks or months before. Keeping a server updated is the most useful habit there is, and it can mostly run by itself.
| Job | Ubuntu / Debian | AlmaLinux / Rocky |
|---|---|---|
| See what's new | sudo apt update && apt list --upgradable | sudo dnf check-update |
| Install it all | sudo apt upgrade -y | sudo dnf upgrade -y |
| Clear out leftovers | sudo apt autoremove -y | sudo dnf autoremove -y |
| Reboot needed? | cat /var/run/reboot-required.pkgs | sudo dnf needs-restarting -r |
| Automatic updates | unattended-upgrades | dnf-automatic |
Update by hand#
Ubuntu / Debian
Fetch the list of what's new, then see it:
sudo apt updateapt list --upgradableInstall it all:
sudo apt upgrade -yNow and then, run sudo apt full-upgrade for updates that add or remove other packages, such as a new kernel series. Then clear out old kernels and leftovers:
sudo apt autoremove -yIf Ubuntu asks which services to restart, the ticked ones are fine: press Tab to Ok, then Enter.
AlmaLinux / Rocky
See what's new:
sudo dnf check-updateInstall it all:
sudo dnf upgrade -yAlmaLinux removes old kernels by itself. To clear out other leftovers:
sudo dnf autoremove -yDoes it need a reboot?#
Most updates restart what they change. A new kernel only takes effect after a reboot.
Ubuntu / Debian
On Ubuntu, this file appears when a reboot is needed:
cat /var/run/reboot-required.pkgs"No such file" means none is needed. Debian doesn't always write it, so compare the running kernel with the newest installed:
uname -r && ls /boot/vmlinuz-*If the newest in the list is newer than the first line, reboot.
AlmaLinux / Rocky
sudo dnf needs-restarting -rIf needs-restarting isn't found: sudo dnf install -y dnf-plugins-core.
Reboot from the server:
sudo rebootOr use Reboot on the server's page in the portal, which works even if you can't log in: see Start, shut down and reboot.
Install updates automatically#
Ubuntu / Debian
unattended-upgrades installs security updates once a day. Ubuntu has it on already. On Debian, install it and switch it on:
sudo apt install -y unattended-upgradessudo tee /etc/apt/apt.conf.d/20auto-upgrades <<'EOF'
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
EOFCheck what it would do, without installing anything:
sudo unattended-upgrade --dry-run --debugWhat it did is logged in /var/log/unattended-upgrades/.
AlmaLinux / Rocky
dnf-automatic downloads and installs updates on a daily timer:
sudo dnf install -y dnf-automaticsudo systemctl enable --now dnf-automatic-install.timerTo install only security updates, set upgrade_type = security in /etc/dnf/automatic.conf. Check when it next runs:
systemctl list-timers dnf-automatic-install.timerReboot automatically
Automatic updates don't reboot, so a new kernel waits. If a few minutes' downtime at night is fine, let the server reboot itself when it needs to.
Ubuntu / Debian
Reboot at 4am, only when an update needs it:
sudo tee /etc/apt/apt.conf.d/52unattended-upgrades-local <<'EOF'
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";
EOFAlmaLinux / Rocky
Check every night at 4am and reboot only if needed, from root's crontab:
echo '0 4 * * * root /usr/bin/dnf needs-restarting -r >/dev/null || /usr/sbin/reboot' | sudo tee /etc/cron.d/reboot-if-neededIf there's no /etc/cron.d folder, cron isn't installed: sudo dnf install -y cronie && sudo systemctl enable --now crond.
Times are in the server's time zone. Check it with timedatectl, and change it with sudo timedatectl set-timezone America/New_York.
Moving to a new release#
Each release gets updates for some years, then stops. Check what you're running:
cat /etc/os-releaseUpgrading a release in place is a bigger job and can go wrong, so back up first. Often it's cleaner to build a new server on the new release and copy your data across.
Still stuck? Open a ticket and say which guide you followed.