How often should I update using apt-get update?
Someone told me to use the command "apt-get update "to update my software and hardware updates frequently. What exactly is updated and how often should I update it.
I'll try to put this in layman's terms.
In Ubuntu, "software" is stored in repositories. Repositories are basically machines that contain an archive of all the software that you can install in Ubuntu.
apt-get update
is a command that tells Ubuntu to "go and update your software index". So Ubuntu goes and asks each one of the repositories "what software do you have? And what version is it?" Your Ubuntu keeps a list of all of the available software and their versions.
Then, apt
(which is the brains behind all of this) compares the version of the software that you have with the version of the software in the repositories. For example, let's say you have Skype version 3 installed, but when Ubuntu went and asked the repositories (apt-get update
), it found out that they have version 4 available, so now, apt
knows that Skype needs to be upgraded.
apt-get upgrade
is the command that actually tells Ubuntu "okay, go and get Skype version 4, and install it". Obviously, this command doesn't only upgrade Skype, it upgrades everything else that needs to be upgraded. So apt-get upgrade
is the command that upgrades your software.
So now, to answer your questions:
What exactly is updated?
apt-get update
updates its index of packages that are available in the repositories. So technically, this command doesn't really "update" (or "upgrade") any software. The command to do that is apt-get upgrade
.
How often should I update it?
I don't think there's a definitive answer here, but Ubuntu takes care of that for you. By default, Ubuntu is pre-configured to run the command apt-get update
every now and then. That is why, if you leave Ubuntu for a while without updating or upgrading it, you'll see a box like this:
It ran apt-get update
in the background, and it identified that there is software that needs to be upgraded. All you need to do is hit Install Now, and Ubuntu should start downloading and installing. Clicking Install Now is just the equivalent of doing apt-get upgrade
.
apt-get
is an incredibly useful tool. Try reading this https://help.ubuntu.com/community/AptGet/Howto site to get an idea of what apt-get
can be used for!
As for your specific question, @Braiam and @Alaa have very well done answers, read theirs first. Your friend is rather mis-informed. This is from the man-page for apt-get
:
update: update is used to resynchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt /sources.list. For example, when using a Debian archive, this command retrieves and scans the Packages.gz files, so that information about new and updated packages is available. An update should always be performed before an upgrade or dist-upgrade. Please be aware that the overall progress meter will be incorrect as the size of the package files cannot be known in advance.
I like what @Braiam broke this down into:
QUOTE: @Braiam:
Long story short: this download the list of packages and their versions from repositories so you can use them later to install, remove or upgrade packages. This don't update/upgrade packages on their own. It just refresh the list of the packages. For upgrading packages you use
apt-get upgrade
:
upgrade: upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available.
Obviously apt-get update
doesn't download/install the latest and greatest program update(s), it only makes sure that any newly added PPAs are included in the sources.list file. This allows you to install programs from non-default sources and is also why you have to run apt-get update
after add-apt-repository
.
In your case you would want to run apt-get update
after adding a PPA. Ubuntu automatically checks for updates either every week or as you configure it. It, when updates are available, shows a nice little GUI that lets you choose the updates to install, and then downloads/installs the selected ones.
Unless you want to force Ubuntu to check for updates, you don't need to run any special commands, just use your computer normally and you will eventually be alerted to the updates and be allowed to install them.
Please, don't trust this "someone". He seems to be mal informed or misinforming on propose.
Lets explain what each commands of apt-get
do and what apt-get
is, from man pages:
apt-get is the command-line tool for handling packages, and may be considered the user's "back-end" to other tools using the APT library.
Now, this is confusing if you don't have previous knowledge. APT stands for Advanced Package Tool, and apt-get
is the APT package handling utility -- command-line interface.
That said, apt-get is the transmission that controls the dpkg
engine that move the entire Debian-based systems. A .deb system without apt-get is severally limited in their functionality to install, remove and upgrade packages.
Now apt-get accepts differents commands or orders, this is what each of them do, from man again:
update: update is used to resynchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list. For example, when using a Debian archive, this command retrieves and scans the Packages.gz files, so that information about new and updated packages is available. An update should always be performed before an upgrade or dist-upgrade. Please be aware that the overall progress meter will be incorrect as the size of the package files cannot be known in advance.
Long story short: this download the list of packages and their versions from repositories so you can use them later to install, remove or upgrade packages. This don't update/upgrade packages on their own. It just refresh the list of the packages. For upgrading packages you use upgrade
:
upgrade: upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available.
Once this confusion is cleared, I think I answered the "What exactly is updated" part of the question. For "how often should I update it" is more like a opinion based behavior, but is common believe and the update-manager (a GUI) is configured like that too, is updating the indexes and upgrading the packages once a day.
Please, tell that someone that is in his wrong and direct them here or to some documentation before misguide users giving flawed advise.