21

For example, if I run sudo apt-get -y upgrade if there is a package that requires a restart to upgrade, will the yes flag cause the system to reboot after the command finishes upgrading everything? Or, will it still require a manual reboot?

OS and Software:

  • Debian Buster 10 -> kernel version 4.19 on a Raspbian HW

  • apt 1.8.2 (armhf)

0
23

No, apt on its own won’t reboot.

You can check whether the file /var/run/reboot-required exists after running apt to see if a reboot is required. If you use unattended-upgrades, you can configure that to reboot for you.

2
  • If the file /var/run/reboot-required exists, then it's necessary to reboot? Is it normal that the file is empty?
    – A.L
    Mar 2 '20 at 14:41
  • 1
    @A.L it means that a package has requested that the system be rebooted; whether a reboot is necessary is up to the system administrator. Typical occurrences involve kernel upgrades: the kernel upgrade isn’t effective until the system has been rebooted (ignoring live kernel patching techniques). The file is supposed to be empty, yes. Mar 2 '20 at 15:12
4

No, apt-get will not reboot by itself, but if you want your system to reboot automatically after an update if necessary then add [ -e /var/run/reboot-required ] && sudo reboot to your command:

sudo apt-get -y upgrade; [ -e /var/run/reboot-required ] && sudo reboot
1
  • Thanks, I already know how to do scripting, but this does save me some time.
    – AlienDrew
    Mar 2 '20 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.