What does add-apt-repository mean?

What does this mean?

sudo add-apt-repository ppa:maco.m/ruby
sudo apt-get update
sudo apt-get install rubygems

Hows does it differ from running

sudo apt-get install rubygems

?


There are three steps to what you're running:

  1. add-apt-repository adds a PPA to your list of sources, (importing the GPG public key of the PPA automatically), so that Ubuntu knows to look for updates from that PPA as well as from the official Ubuntu sources. Usually this is used by developers to provide updates more quickly than in the official Ubuntu repositories.

  2. apt-get update tells APT to update its database of what packages can be installed and where to install them from. In this case, apt-get will see your newly-added PPA and discover that ppa:maco.m/ruby has the newest version of rubygems that it knows about, so it will make a note to install rubygems from the PPA next time someone asks to install it.

  3. apt-get install causes apt-get to find the package in its database and download and install the indicated file. In this case, it will find the rubygems package, download it from ppa:maco.m/ruby, and install it.

If you were to simply run apt-get install rubygems, you would get a less-recent version (or perhaps nothing at all, depending on whether rubygems is also in the Ubuntu repositories or only in the PPA).

In general, the format ppa:a/b will expand to https://launchpad.net/~a/+archive/b, where you can view the files and download them individually. In your case, that would be https://launchpad.net/~maco.m/+archive/ruby.