- How do you actually do the restart (I'm a beginner and using 12.04.1 LTS)?
- Should I always restart the system when prompted to?
- Does restarting the system affect access to it via SSH or there any other caveats one needs to think about before doing this?
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 12.04, click the power icon in the upper right corner of the screen, and select "Shut down...". In the dialog that appears, a "Restart" button should be visible. In Ubuntu 12.10, the restart option appears in the power menu directly.
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.
Should I always restart the system when prompted to?
You may view the list of packages that require a restart with:
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)
Another option is using
sudo shutdown -r now
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).
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.
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.
Always try to Restarting the pc after ubuntu updates, install drivers and some application that wants to restart the OS(ubuntu).
when new updates are installed or driver is installed these wants to restart the OS for working performance and properly use.
Normal application or package don't need to restart the OS after installed.