57

Oftentimes I try to ‘beat’ the update manager by opening a console and entering the sequence

sudo apt-get update
sudo apt-get upgrade

which, to the best of my knowledge, should update all packages to their newest stable releases. The update manager does the same, as far as I know.

However, the update manager sometimes (most frequently when a new kernel is distributed) requires a restart after terminating. apt-get never does, even when it looks like I’m upgrading the kernel. Why is this so?


In response to the duplicate vote: I am not asking which packages require a reboot as the linked question is. Rather I am asking why apt-get does not ask me to reboot even when I recognise a package being updated that the update manager would require a reboot for.

Jan
  • 757
  • 10
    it's also worth noting that the sort of updates that are covered by apt-get dist-upgrade but not by apt-get updgrade are more likely to be those that would have caused update manager to suggest a reboot. – Jon Hanna Jun 09 '15 at 22:19
  • 5
    FWIW, you can check if restart is required by checking the existence of /var/run/reboot-required. Also, Byobu shows an "update required" icon in the status bar when needed. – Andrea Corbellini Aug 11 '15 at 18:00
  • Note that the "need to update" is not as trivial question as it may sound. For example, if upgrade fixes a glitch in a login screen (gdm/lightdm/...), do you need to restart? The example sounds funny for a server, crazy for a normal desktop, less so for a heavily shared thin station. It really boils down to how you are using the system which no script can really know. – Alois Mahdal Dec 17 '15 at 18:55
  • 2
    @Pilot6 Not even remotely close to being a duplicate. The question you marked is asking which packages require a reboot. My question is asking why one updating method is not asking me to reboot even though I recognise a package being updated that would require reboots. – Jan Feb 10 '16 at 19:28
  • 1
    OK. But it is closely related. – Pilot6 Feb 10 '16 at 19:31
  • 1
    @Pilot6 That I can agree to ;) – Jan Feb 10 '16 at 19:32

5 Answers5

82

Because apt-get (or plain simple apt) is for the pros and when the pros do a:

sudo apt-get dist-upgrade

and see a new kernel being installed, the pros know they have to reboot to activate it.

The automatic update is for everyone else out there!

Alternatively, you can now install Ubuntu Live kernel Patching from version 16.04 onwards which allows you to update your kernel while your server is running.

:-)

Fabby
  • 34,259
  • 4
    I wish I could accept all three answers because they technically all say the same thing. But I think I’ll take yours because you made me grin most ;-) – Jan Jun 09 '15 at 20:29
  • 6

    :) A little bit of humour in an answer is never bad! ;-)

    – Fabby Jun 09 '15 at 20:36
  • 4
    Kernel livepatching support is in mainstream kernels now, so with a bit of luck we may not have to reboot anymore once we get to LTS 16.04. – kasperd Jun 10 '15 at 07:02
  • Your description of the apt-get upgrade vs. apt-get dist-upgrade matches neither man apt-get nor my experience using the tool. I'm pretty sure the difference has to do with how dependencies that would require installing or removing packages are handled; "upgrade" skips those packages, "dist-upgrade" attempts install/remove packages to make the upgrade happen. – derobert Mar 07 '16 at 17:18
  • @derobert: reading manual; can't find anything that contradicts what I'm saying, and it just was my experience, but that could be because of my system... So if you have proof of the contrary, I'll remove again! – Fabby Mar 07 '16 at 19:51
  • 1
    @Fabby somewhat confused as you've currently removed that paragraph, but if you look at the apt-get man page, the description of "upgrade" says e.g., "under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed.". So if a normal app update requires installing a new package (new library soname, for example), it won't be done. Or if a kernel update used the same package name, it would be done. – derobert Mar 09 '16 at 18:23
  • @Fabby the behavior you're describing is the way that turns out to work most of the time, since Ubuntu uses a new package name for each new kernel version and typically app security updates don't require installing a new package. – derobert Mar 09 '16 at 18:24
  • @Fabby unfortunately of course there can be exceptions—which will be very surprising if you understand "upgrade" to mean "not kernel" vs. "dist-upgrade" to mean "including kernel" – derobert Mar 09 '16 at 18:26
37

Update manager suggests to restart when kernels are upgraded or some other system packages with services that are marked for reboot when upgraded.

In this case /var/run/reboot-required is set by a package installation script.

Command line apt-get upgrade does not suggest anything, because it is targeted to more advanced users that can decide themselves when to restart the system ;-)

But after upgrade using apt-get Update Manager in a while will suggest to restart too.

Pilot6
  • 90,100
  • 91
  • 213
  • 324
  • I can't believe that, is that true? "services that can not be restarted without rebooting the whole system." – A.B. Jun 09 '15 at 20:33
  • 2
    Yes this is true. Like "upstart" and some others. Not many. – Pilot6 Jun 09 '15 at 20:34
  • 2
    @Pilot6 Sounds ridiculous if upstart cannot be restarted without a reboot. It was supposed to be an upgrade from SysV init which can be restarted without a reboot. – kasperd Jun 10 '15 at 06:59
  • @kasperd That was just an example. I noticed that Update manager asks for restart on some non-kernel packages. There must be some list of these packages. I am not quite sure upstart is there. – Pilot6 Jun 10 '15 at 08:15
  • But will the user know after running apt-get upgrade whether a package that is marked for reboot has been upgraded? It seems like something that might be useful for the user to know, regardless of whether the user is using the command line. – Max Nanasy Jun 10 '15 at 19:49
  • 1
    @MaxNanasy Update manager will popup and suggest to reboot. it may happen in a while. – Pilot6 Jun 10 '15 at 19:50
  • @kasperd Is lack-of-reboot suddenly the only dimension on which software is judged? It's entirely possible for it to be an overall upgrade while regressing on some things. – Chris Hayes Jun 11 '15 at 02:04
  • @A.B. If you use something like Ksplice, you don't have to reboot. Ksplice is free for Ubuntu and Fedora desktops. – Paddy Landau Jun 16 '15 at 11:07
  • FYI, packages set /var/run/reboot-required when the upgrade requires a reboot. See http://serverfault.com/questions/92932/how-does-ubuntu-keep-track-of-the-system-restart-required-flag-in-motd – ayke Apr 29 '16 at 14:55
15

When you install a new kernel you have to restart the machine in order for the changes to take effect, apt-get just doesn't nag about it.

  • 1
    Not just kernel updates. You also have to either reboot or restart some services when certain other packages are upgraded. If you're savvy you can often restart relevant services and avoid a reboot. If you're not, then a reboot will always work. It's often not simple to work out what services need a restart, because upgraded packages could involve shared libraries that lots of other software depends on directly or indirectly via other software. I don't necessarily 100% trust the graphical update manager to know, either. – thomasrutter Jun 11 '15 at 05:46
7

apt-get actually notifies you on terminal when after installing a certain package, if it requires to reboot.

update-manager is an all-in-one type of solution that takes care all of your upgrade needs by itself.

I do prefer apt-get though , don't know why :)

121n3
  • 75
  • 5
2

apt-get upgrade does not update the kernel.

apt-get dist-upgrade updates the kernel in Ubuntu.

Linux kernel versions before 4.1 need a reboot when the kernel is updated.

Other packages don't need a reboot, just a restart of the application itself. Some Windows applications running on Wine request a reboot but just type the command:

wineserver -k

and restart the application.

Fabby
  • 34,259
user222789
  • 21
  • 1