4

I just recently learned that sudo apt-get update only updates the list of packages to their most recent versions and doesn't actually install or update your software until you do sudo apt-get upgrade.

Is there any reason why apt-get update is not some automatic thing? Would it make sense to include sudo apt-get update as part of an automatic startup script somehow so we don't have to manually do it before running what we really want (the upgrade)?

DoubleBass
  • 337
  • 1
  • 3
  • 9
  • 2
    No, not really. Sometimes apt-get update fails (due to network problems, or similar) and you want to have the output. Moreover, using a user's network silently in the background is a very bad idea. Finally, soon we will move to snappy packages, abandoning the old apt-get system. – dadexix86 Mar 07 '16 at 22:00
  • 3
    Well, it sort of is. That popup that tells you when you have updates available is running apt-get update automatically. Open the Software & Updates app and you can change that schedule. – TheWanderer Mar 07 '16 at 22:04
  • 1
    Just a quick note, sudo apt-get upgrade won't actually upgrade everything, to upgrade all things that need upgrading do sudo apt-get dist-upgrade (though obviously this won't upgrade you to a new distribution - sudo do-release-upgrade will do that). –  Mar 07 '16 at 22:07
  • My point is - that's good too, but may not be user's desired behavior – Sergiy Kolodyazhnyy Mar 07 '16 at 22:21
  • @Serg: It upgrades packages to new release package versions? I thought it just handled kernel upgrades and more serious upgrades to the system... I don't think on 14.04 that it would get versions of packages which are for 15.10... Otherwise wouldn't that be the same as a do-release-upgrade? –  Mar 07 '16 at 22:28
  • @Serg: I think you are wrong and getting confused with do-release-upgrade because this is what the apt-get manpage says and it doesn't say anything you say about the dist-upgrade option: –  Mar 07 '16 at 22:30
  • dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; –  Mar 07 '16 at 22:31
  • apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. The dist-upgrade command may therefore remove some packages. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the general settings for individual packages. –  Mar 07 '16 at 22:31
  • @ParanoidPanda yes, you're right. I did confuse it with do-release-upgrade. My bad – Sergiy Kolodyazhnyy Mar 07 '16 at 22:45

2 Answers2

4

Technically speaking, the GUI version of apt-get update does it automatically already - those already cater to the needs of a desktop user. Command line tools are more of a technical type of user, typically admins , who know what they're doing.

However, there's nothing stopping you from making a script out of it, and reviewing logs every once in a while. For example, here's a quick sketch:

#!/bin/bash

main()
{
  local DATE=$(date +%Y_%m_%d_%H_%M)
  local LOGFILE=AUTO_UPDATE_$DATE
  local DIR="/home/localuser/logs" # where to store logs

  apt-get update &> "$DIR"/"$LOGFILE"
}

main

And use that as script to run upon shutdown or reboot using /etc/rc6.d directory scripts or alternatively - cronjob to schedule this script at specific time of day. Remember though that checking logs will be your responsibility.

In future, there will come snappy - a newer system for transactional updates which is now is in very young stage and supposedly should come to 16.04. My experience with it is somewhat limited, but on Raspberry Pi it does update automatically and reboots itself once newer version of packages are available, sort of how Windows update works

Addition

Per muru's suggestion one could use unattended-upgrades to automate the updates as well, and probably in a less verbose way than my solution.

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
1

Sometimes you just want to see what would be upgraded or what new packages are available for install. This is especially important if you are managing a server as upgrading some packages can cause problems. For a desktop user that doesn't care, the graphical software updater hides all this from you anyway.

msdin
  • 366