Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Possible Duplicate:
Why run sudo apt-get update before installing a package?

If I wanted to install some software like below.

Why do I need to run the

sudo apt-get update

before installing the program?

So for example.

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.7
share|improve this question

marked as duplicate by Jorge Castro, Ringtail, jrg Jul 12 '12 at 17:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

The 'sudo apt-get update' is necessary because apt-get has to know where to download the packages from.

Apt-get doesn't know that you added a new PPA. So, the program has to update the sources.

share|improve this answer

The 'sudo apt-get update' is not all the time necessary : it tells apt to checks software repository for newer versions and update local cache.

It is not necessary to do it all the time. But if your local software cache is old, and you try to install something new, apt would try to fetch a (old) version that is no longer available and will complain. Then you can do 'sudo apt-get update' to force refresh.

'sudo apt-get update' is also done automatically by desktop "software update" when it check for updates.

This is why you must 'sudo apt-get update' when adding a new PPA or any kind of Debian software repository, if you don't, your local apt cache won't know new available packages.

Just a reminder :

apt-cache policy vim

will show you available and installed versions for package "vim".

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.