1

I've noticed while setting up my laptop with Ubuntu for the first time that virtually every guide on how to install X program asks me to

sudo apt-get update

Is it just good practice or is it really that important to keep updating everything?

Tyriuth
  • 31

4 Answers4

3

If you add a new repository, the command

sudo apt-get update

is necessary for the system to know, there is a new repository.

And the command is suggested before you install a new software, to update the repository database, to get the latest version of this package

Furthermore, it is necessary to publicize the system that new packages have been added to the repositories.

A.B.
  • 90,397
2

The previous steps in the tutorials all add repositories or such, and an update needs to be run for this to be recognised by stuff. (Bad wording I know)

Tyriuth
  • 31
  • also, even without installing a ppa, the package list should be updated before installing a package so that you install the version with all the latest security updates and bug fixes. – mchid Jul 24 '15 at 04:39
1

As others explained, apt-get update updates only the list of available packages.

This is indeed important and necessary, because not every old version of packages is still available on the mirror servers. So if you do a apt-get install foo right after installing, it might be that you just get an error about foo-1.2.3-ubuntu4 not found, because the current version is foo-1.2.4-ubuntu1 and the old versions package is not available from the server anymore. This can happen without any modification of the repositories, because when you install a new system, the package lists are usually quite old.

So not only you won't get the most recent version without the update, but it is possible that you can't install the package at all.

Independently from that problem, always do apt-get update and apt-get upgrade!!! on a regular basis, because else your system will contain publicly known security holes!

Josef
  • 179
  • 4
  • 9
0

In simple words apt-get update fetches the package lists from all repositories founded in the /etc/apt/sources.list file or /etc/apt/sources.list.d dir and updates them to get information on the newest versions of packages and their dependencies.

for that whenever you want to add a repository you should do apt-get update to retrieve the needed information about packages founded in that repository.

Also, it's a good habit to just do apt-get update always before any installation to check whether a change occur to any package in your added repositories.

Maythux
  • 84,289