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.
Best Answer
Your copy of Ubuntu has a private copy of the list of packages that are in Ubuntu's repositories. When you install a package,
apt-get
reads the list and determines the URL of the package to download (which typically contains package version information).apt-get update
updates the package lists. If you don't do it before an installation,apt-get
might complain that it cannot find the package in the repository, because it computed the URL based on an old version of the list (which listed an older version of the package).Of course,
apt-get update
is necessary after you have changed the repositories, because the system needs to download the list for the new repositories.It is essential before upgrading the installed packages, because the system cannot know whether the repo has a new version of a package, unless it has an up-to-date copy of the package list.
There is no reason not to run
apt-get update
before installing a package. However, it is not necessary, if you know that no new version of that package and of its dependencies have been made available on the mirrors since the lastapt-get update
. A special case of this is when the package lists are up to date, which is after a reasonably short time since the lastapt-get update
; this means that all packages on the mirror are the same version as they were.The package list changes whenever a package is upgraded on the mirror. It is impossible to predict how often it changes, in general, without reference to a specific issue or bug report, or without following the development of that Ubuntu release.