Shell Update Script for Debian / Ubuntu
Note: This is a recovered post from my old blog. See how we recovered these posts using the Wayback Machine and AI tooling.
Update script to automate Debian system updates. You can set this up as a cron job to run on a schedule, or run it manually. For unattended updates (like starting via SSH), use TMUX to keep the script running in the background so it continues even after you disconnect.
#!/bin/bash
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt autoremove -y
sudo apt-get clean
sudo reboot
Run with:
sudo sh nameofscript.sh
For unattended updates, use TMUX to keep the script running in the background:
tmux
sudo sh nameofscript.sh
# Press CTRL + B then D to detach