Ubuntu – Why isn’t sudo apt-get update an automatic thing

aptpackage-managementupdatesupgrade

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)?

Best Answer

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.

Related Question