Should I always restart the system when I see "System restart required"?

169,406

Solution 1

Should I restart when prompted?

Yes, you should. For most cases, a restart is required when an update to the Linux kernel has been installed. These updates are usually security updates, and then only come into effect after a reboot. Updates to normal applications such as Firefox come into effect after you restart the program. Firefox should prompt you to do this automatically, but other programs may not, so it's something to bear in mind.

How to restart:

To restart the computer in Ubuntu 21.04, click the power icon in the upper right corner of the screen, and select "Power Off/Log out". In the sub-menu that appears, click "Restart...".

To restart from the command-line, run this command:

$ sudo reboot

The downsides of restarting:

On the whole, restarting is a very safe operation, and I would not consider it in any way unsafe. Of course, when you restart the computer, you lose all the information in RAM, so make sure you save all open documents and files before shutting down your computer. While you are restarting, your computer will of course be offline for a few minutes. If you're running a server, it will be down for a few minutes. If you have an open SSH session, it will be terminated.

Solution 2

Should I always restart the system when prompted to?

You may view the list of packages that require a restart with:

more /var/run/reboot-required.pkgs

Based on the list, you can decide whether it is worth restarting.

Example of output:

user@server:~$ more /var/run/reboot-required.pkgs
libssl1.0.0
linux-image-4.4.0-62-generic
linux-base
linux-base
linux-image-4.4.0-63-generic
linux-base
linux-base
linux-image-4.4.0-64-generic
linux-base
linux-base
network-manager
linux-image-4.4.0-66-generic
linux-base
linux-base
linux-base
linux-base
linux-base
linux-base
linux-base
network-manager

(The answer was tested on Ubuntu 14.04 LTS x64 and Ubuntu 16.04 LTS x64)

Solution 3

  1. How to restart:

    $ sudo reboot
    

    Or

    $ sudo init 6
    
  2. Yes as its most probably a security updates.

  3. Nothing will affect ssh connectivity after restart.

Solution 4

Another caveat I haven't seen anyone else mention:

If the box you are SSH'ing into is connected via wifi then when you reboot you may not have access to the wifi network until a user physically logs in in at the remote machine which means SSH will fail since the box won't be connected to the network.

To avoid this, on the remote machine you have to configure the wifi in advance to be available to all users. Click the network icon in the system tray and choose "Edit Connections..", select your wifi network and click edit button, then make sure "Connect automatically" and "Available to all users" check boxes are checked.

You can also apparently solve this by messing with /etc/network/interfaces and wpa_supplicant but I found that road much more complicated than simply checking the box.

Side note: For me, before making the above change, connecting from WSL on windows to an ubuntu box gave "Resource temporarily unavailable". Googling this will take you down a rabbit hole of possible WSL bugs, but for me the problem was simply that the wifi wasn't connected until someone logged in. Applying the above fix solved the issue.

Solution 5

  1. Another option is using sudo shutdown -r now

  2. If prompted, you should do so; as system have things need to be applied (most common if you choose to download and install updates automatically, or you have changed something yourself that requires a reboot to apply changes to your system).

  3. SSH will definitely be affected on a reboot and it will be terminated. I may suggest Putty as it will give an option on its context menu to reconnect the session.

Share:
169,406

Related videos on Youtube

killer boyz
Author by

killer boyz

web programming-javascript, php, mysql, css, html-is my thang

Updated on September 18, 2022

Comments

  • killer boyz
    killer boyz almost 2 years

    These two nice SE posts (1, 2) comment on restarting one's ubuntu machine but they leave me with a few questions:

    1. How do you actually do the restart (I'm a beginner and using 12.04.1 LTS)?
    2. Should I always restart the system when prompted to?
    3. Does restarting the system affect access to it via SSH or there any other caveats one needs to think about before doing this?
    • Admin
      Admin about 7 years
      2. no: bug
  • Noam
    Noam about 8 years
    Just to add to the downsides: If you have any process running, like memcache, MySQL, a mounted disk, etc.., those might not return after the reboot (depends on how they were configured). Also, it's best to shut them down manually before the reboot.
  • Flimm
    Flimm about 8 years
    @Noam: To answer your first point, that's true, but wouldn't you rather discover that when you're there to reboot the machine rather than when the kernel panics in the middle of the night? For your second point, why would it be best to shut them down manually? It's the same process either way.
  • Noam
    Noam about 8 years
    1) I agree the term downside isn't exactly correct, but I do think it's important to be aware of this, and to plan the process accordingly 2) Is it? I'm sure you're much more knowledgable than I am on these issues, but I was under the impression doing a manual service stop/graceful can be both be safer and you'll also be able to see any on-screen errors/warnings. Am I wrong?
  • Auspex
    Auspex over 7 years
    No, absolutely not always. In the OP's case, where he's doing unattended upgrades, yes, but in fact the "restart required" flag gets set whenever grub changes (among other things, I believe) and so is set if you only remove old kernels.
  • Phil_1984_
    Phil_1984_ over 7 years
    It may also be necessary to use sudo apt-get autoremove to remove the obsolete kernels. I have to do this on some servers before the reboot because my boot partition can only hold 3 or 4 kernels at once.
  • PeMa
    PeMa about 7 years
    About the SSH: True, it is not directly effected. However, if you are in a situation, where restart may cause your ISP to give you a new ip address, you won't find your server anymore. That's an effect in a sense.
  • glaux
    glaux about 5 years
    Do you have a resource for determining which packages make a restart a must (i.e. important security)? I have no idea from looking at this list.
  • Boris Verkhovskiy
    Boris Verkhovskiy about 4 years
    Another caveat: if you're using full disk encryption you need to walk over to the machine to put in the disk encryption password.
  • Boris Verkhovskiy
    Boris Verkhovskiy about 4 years
    @glaux you can try looking through usn.ubuntu.com (Ubuntu security notices).
  • Alexey Abraham
    Alexey Abraham almost 4 years
    "restarting is a very safe operation" is not correct, 2 months ago restarted a server on AWS ... and it became a complete stone. Looks like booter was somehow damaged. It took me about a week to recover&setup everything back. So every reboot better be backed up by proper backup. And yes, on AWS you have not so much options after system failure occurs.
  • berezovskyi
    berezovskyi almost 3 years
    Just to be painfully clear: you must always use sudo reboot, even for cloud VMs. Using cloud admin panel for a reboot is similar to pulling the power cord from a server and plugging it back again. A proper reboot may also fail but it's more of a case of a dead machine walking, e.g. when RPi has an SD card failure you may be able to SSH and rescue something but it won't boot if you power cycle it.