i'm new to using ubuntu or any linux distro.

On reading and watching tutorials on the internet, I've seen others just use

sudo apt-get install package-name

while others do these commands before using sudo apt-get install

sudo add-apt-repository (commands here)

what's the better way to install packages?

up vote 2 down vote accepted
sudo apt-get install package-name

This command installs a new package. But if the package can't be found you have to tell the installer where to find it, and that's when you add a PPA(repositiry).

sudo add-apt-repository

Using a Personal Package Archive (PPA), you can distribute software and updates directly to Ubuntu users. Create your source package, upload it and Launchpad will build binaries and then host them in your own apt repository.

That means Ubuntu users can install your packages in just the same way they install standard Ubuntu packages and they'll automatically receive updates as and when you make them.

Every individual and team in Launchpad can have one or more PPAs, each with its own URL.

Packages you publish in your PPA will remain there until you remove them, they're superseded by another package that you upload or the version of Ubuntu against which they're built becomes obsolete.1

1Source:Launchpad Help

If you run

sudo apt-get install package-name

It installs the latest version of package-name available in the official repository or in one of the ppa. So Ubuntu comes with an official repository where there is many packages in relatively recent version. But some packages are not yet in the official repository so their developer (or other people) create a ppa to make it available for you through apt-get. That is an easy way to install packages that are not yet officially supported by Ubuntu.

Sometimes, there is also ppa with newer version of packages that the version in the official repository. Be aware that sometimes, these ppa contains unstable version but most of the time it is stated in the tutorials or even in the names of the ppa or their description.

Also, if you prefer a graphical interface instead of the command line, you can use the Ubuntu Software Center instead of apt-get.

I would say that the version in the Ubuntu Software Center is preferred but if it is not yet available and if it is stable, add the ppa. Or if you need a feature from a newer release, use the ppa too. The ppa are very confortable, their upgrade also appear in the Software Update. However, you sometimes only need a few days before Ubuntu release the new version or the software, that's always the case with. Most of the times, if the tutorials are up to date, you can follow their recommendation IMHO.

  • clearly explained thanks :) thanks – chanHXC Apr 29 '13 at 9:57

The first command you listed here is used to install packages, whereas the second one is a script which allows you to add external software repositories to your system really easily.

An example:

Typing in sudo apt-get install geary will install Geary, a lightweight email client.

However if you'd like to test a daily build of geary (daily might be unstable) you could add a repository (ppa) by doing this: sudo apt-add-repository ppa:yorba/daily-builds

  • in few words. but very helpful. thanks – chanHXC Apr 29 '13 at 9:57

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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