Turn on automatic security updates (unattended-upgrades and dnf-automatic)
Keep your server patched without remembering to log in: set up unattended-upgrades or dnf-automatic, test it, and choose how kernel reboots happen.
- Beginner
- Linux VPS
- 2 min read
Most break-ins on small servers use security holes that already have a fix. Automatic security updates close that gap within a day of a patch being released, even when you are busy.
Update everything once by hand
Start from a fully patched system.
sudo apt update && sudo apt upgrade -y # Ubuntu / Debian
sudo dnf upgrade -y # AlmaLinux / Rocky LinuxUbuntu and Debian: unattended-upgrades
1. Install and switch it on
Ubuntu usually has it already. Debian minimal images may not.
sudo apt install -y unattended-upgrades apt-listchanges
sudo dpkg-reconfigure -plow unattended-upgradesAnswer Yes. This writes /etc/apt/apt.conf.d/20auto-upgrades, which should contain:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";2. Decide about reboots
Kernel and core library updates only take effect after a reboot. Open /etc/apt/apt.conf.d/50unattended-upgrades and set these lines if you want the server to reboot itself at a quiet hour when needed:
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";Leave them at false if an unplanned reboot would hurt, and reboot by hand when /var/run/reboot-required exists.
3. Test it
sudo unattended-upgrade --dry-run --debugLogs are kept in /var/log/unattended-upgrades/.
AlmaLinux and Rocky Linux: dnf-automatic
1. Install
sudo dnf install -y dnf-automatic2. Configure security-only updates
Edit /etc/dnf/automatic.conf and set these values in the [commands] section:
[commands]
upgrade_type = security
download_updates = yes
apply_updates = yesUse upgrade_type = default if you prefer all updates, not only security fixes.
3. Enable the timer
sudo systemctl enable --now dnf-automatic.timer
systemctl list-timers 'dnf-automatic*'To see whether a reboot is needed after updates, run:
sudo dnf needs-restarting -rAutomatic updates are not a backup. Keep copies of your data off the server so a bad update is easy to recover from. See Back up your Linux VPS.
Troubleshooting
- Nothing seems to install: on Debian/Ubuntu check
20auto-upgradescontains both lines set to"1". On AlmaLinux/Rocky make sureapply_updates = yesand the timer is active. - A held package is never updated:
apt-mark showholdlists packages pinned by hand. Remove the hold withsudo apt-mark unhold <package>if it is no longer needed. - dpkg was interrupted: run
sudo dpkg --configure -a, thensudo apt -f install.
Next steps
Was this guide helpful?
Still stuck?
Ask RunRacks AI for a quick answer, or open a ticket and our team will take a look at your server.
Related guides
Security
Check the Windows Firewall rule for RDP port 12230
Find and verify the inbound TCP 12230 rule that lets Remote Desktop reach your RunRacks server, recreate it if it was deleted and scope it without locking yourself out.
- Intermediate
- Windows VPS · Admin RDP
- 5 min read
Security
Linux Security: Using aide for File Integrity Monitoring on VPS
AIDE builds a checksum database of your system files and reports anything that changed. This guide installs it, creates a baseline, tunes the rules and schedules daily checks on a Linux VPS.
- Advanced
- Linux VPS
- 6 min read
Security
iptables basics: list, allow, drop and save rules
Learn how iptables chains and rule order work, then build a small ruleset that allows SSH and web traffic, drops everything else and can be edited by line number.
- Intermediate
- Linux VPS
- 6 min read