Update, Upgrade and Clean a Debian-based Linux system at boot
To automatically update, upgrade and clean a Debian-based Linux system at boot, you can create a systemd service file with the following steps:
Thank you for reading this post, don't forget to subscribe!
- Open a terminal and switch to the root user by running the command
sudo su
. - Create a new systemd service file by running the command
nano /etc/systemd/system/update-debian.service
. - In the nano text editor, add the following lines to the service file:
[Unit]
Description=Update Debian at boot
After=network-online.target
[Service]
ExecStart=/usr/bin/apt update && /usr/bin/apt upgrade -y && /usr/bin/apt autoremove -y && /usr/bin/apt autoclean -y
[Install]
WantedBy=multi-user.target
- Save the file and exit the editor by pressing
Ctrl+X
, thenY
, thenEnter
. - Reload the systemd daemon by running the command
systemctl daemon-reload
. - Enable the new service to run at boot by running the command
systemctl enable update-debian.service
.
Now, whenever the system boots up, the update-debian
service will automatically update, upgrade, and clean up the system using the apt
package manager.
Note: Make sure that the system is connected to the internet at boot time to ensure that the updates can be downloaded and installed successfully.
0 - 0