161

The server version of Ubuntu does not have the add-apt-repository command. How can I add a Personal Package Archive (PPA) to the server without this command?

3
  • in the latest version of synaptic you can add ppa's directly in the software sources instead of a deb line Aug 2, 2011 at 12:39
  • 1
    - @Doug's answer is correct for Ubuntu 16.04 - @fossfreedom's answer is correct for Ubuntu 14.04 On Ubuntu 16.04 the right package is indeed software-properties-common, as shown by: $ type add-apt-repository add-apt-repository is hashed (/usr/bin/add-apt-repository) $ apt-file search /usr/bin/add-apt-repository software-properties-common: /usr/bin/add-apt-repository on previous versions it can be found indeed on python-software-properties --- UPDATE: I comment it here, because I couldn't add it as a comment!
    – azbarcea
    Aug 3, 2016 at 3:09
  • apt-add-repository works right out of the box.
    – Atif
    Aug 19, 2016 at 0:40

6 Answers 6

197

You can simply add the add-apt-repository command. In 13.10 and later, you also need to run this command:

sudo apt-get install software-properties-common

Side note: in 11.04 they added a symlink to add-apt-repository so it can be run as apt-add-repository which totally makes more sense to me. Everything else apt starts with "apt".

NOTE: It's part of the python-software-properties package (before 13.10):

sudo apt-get install python-software-properties
6
  • Seeing it's actually a function of apt it is actually logical to me. "add repository with apt" > "apt-add-repository" Mar 27, 2012 at 15:32
  • 5
    what if "python-software-properties" is already installed, and you still get "command not found" when trying to use "apt-add-repository"?
    – monkut
    Jul 23, 2012 at 1:08
  • Did you also try "add-apt-respository"? On versions before 11.04 you must put the "add" before the "apt". Jul 26, 2012 at 21:24
  • what are you supposed to do when 'apt-get install python-software-properties' fails because it depends on python-curl, which is 'not installable'? On my 12.04 system, it complains that it's "unable to correct problems - you have held broken packages"
    – Hoobajoob
    Jan 16, 2015 at 22:15
  • Is software-properties-common a set of defined tools or collection of utils?
    – Alex
    May 21, 2015 at 8:20
75

Let me teach you how to fish. apt-file enables you to find out which package provides a given file. dpkg -S does the same thing, but only for installed packages. apt-file works whether or not the package has been installed.

So, first you install apt-file: sudo apt-get install apt-file. You then need to update its information, just as you have to with apt-get: sudo apt-file update. Now it's ready for use:

$ apt-file search add-apt-repository
python-software-properties: /usr/bin/add-apt-repository
python-software-properties: /usr/share/man/man1/add-apt-repository.1.gz

So, in this case the next thing to do would be to install python-software-properties.

4
  • 4
    excellent tip - it perhaps shouldnt be buried in this question - a separate question would be a good idea to highlight this.
    – fossfreedom
    Aug 2, 2011 at 11:47
  • @fossfreedom Is this what you're talking about? - askubuntu.com/questions/13792/…
    – jrg
    Aug 2, 2011 at 12:46
  • 9
    Due to this tip I discovered that in 12.10 server apt-add-repository is located in software-properties-common (no longer in python-software-properties) Mar 10, 2013 at 22:08
  • 1
    Why do I keep forgetting that this incredibly useful command exists! Great answer.
    – lleaff
    Mar 7, 2017 at 10:38
56

It is not necessarily the best answer, but this will function:

The old-fashioned way (pre Ubuntu 9.10, they call it) of editing /etc/apt/sources.list still works. You will also need to get the GPG key on the system manually.

On older (pre 9.10) Ubuntu systems:

Step 1: Visit the PPA's overview page in Launchpad. Look for the heading that reads Adding this PPA to your system and click the Technical details about this PPA link.

Step 2: Use the Display sources.list entries drop-down box to select the version of Ubuntu you're using.

Step 3: You'll see that the text-box directly below reads something like this:

deb http://ppa.launchpad.net/gwibber-daily/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/gwibber-daily/ppa/ubuntu jaunty main

Copy those lines.

Step 4: Open a terminal and type:

sudo gedit /etc/apt/sources.list

This will open a text editor containing the list of archives that your system is currently using. Scroll to the bottom of the file and paste the lines you copied in the step above.

Save the file and exit the text editor.

Step 5: Back on the PPA's overview page, look for the Signing key heading. You'll see something like:

1024R/72D340A3 (What is this?)

Copy the portion after the slash but not including the help link; e.g. just 72D340A3.

Step 6: Now you need to add that key to your system so Ubuntu can verify the packages from the PPA. In your terminal, enter:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 72D340A3

(Replace 72D340A3 with whatever you copied in the step 5.)

This will now pull down the PPA's key and add it to your system.

Step 7: Now, as a one-off, you should tell your system to pull down the latest list of software from each archive it knows about, including the PPA you just added:

sudo apt-get update

Now you're ready to start installing software from the PPA!

7
  • 1
    If no other quicker and more user friendly answer is given then i will put this one as the correct. It solves the problem in a "special" way ;) Apr 29, 2011 at 15:10
  • 1
    While add-apt-repository is easier, in a server install I like to keep things lean, so I don't mind doing it manually. This was the answer I was looking for. Apr 14, 2013 at 18:30
  • 1
    This method is way better than installing apt-add-repository and all the crap that comes with the requisite package. Oct 22, 2013 at 20:25
  • 4
    software-properties-common package is HUGE, seems too much for just appending some text to a file and running a couple of commands. Such a waste of space while using in Docker. This answer is so very helpful!
    – rsmoorthy
    Sep 11, 2015 at 6:56
  • 3
    This should be the accepted answer, since the OP asked how to get around not using add-apt-repository... Thanks a bunch for this one!
    – djBo
    May 21, 2016 at 9:52
15

add-apt-repository is provided by the package python-software-properties.

Thus if you should install via

sudo apt-get install python-software-properties
6
  • Thanks! I must say that I find a quite illogical name. Also, do you have any idea why I it is not standard installed?
    – Peter Smit
    Aug 2, 2011 at 10:41
  • 2
    agreed illogical - as to why, you could speculate that servers are usually 'fixed' in terms of running software. Thus you dont need the 'luxury' of adding and removing repositories frequently ... end-of-speculation!
    – fossfreedom
    Aug 2, 2011 at 10:46
  • Why is it illogical? It's a set of python tools to deal with software properties. add-apt-repository is one of those tools. Aug 2, 2011 at 13:32
  • I already have python-software-properties installed but I keep getting this error. I tried apt-add and add-apt notations, and none work... what to do?
    – Mohamad
    May 15, 2013 at 23:17
  • 1
    @Mohamad, because it's wrong, at least for Ubuntu 14.04. All you need to install is software-properties-common. Jan 9, 2015 at 22:21
15

Run this command:

sudo apt-get install software-properties-common

And then you can add your repository running:

sudo add-apt-repository [REPOSITORY]

Renember to replace [REPOSITORY] with the repository name you want to add.

1
  • This worked perfectly.
    – Aaron
    Jan 22, 2015 at 3:16
0

I had a debate with a colleague about this a few weeks ago. Give

apt-add-repository

a try. Doesn't need any other packages. Note that apt appears before add. Order does matter because add-apt-repository needs to be installed.

For those naysayers out there. Give this Vagrant file a try. Note, I'm starting from a fresh trusty image, and adding the ppa right out of the box.

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|

  config.vm.box = "ubuntu/trusty64"
  config.ssh.username = "vagrant"

  config.vm.provision "shell", inline: <<-SHELL
    sudo apt-add-repository ppa:george-edison55/cmake-3.x -y
    sudo apt update
    sudo apt upgrade
    sudo apt install -y virtualbox-guest-dkms
    sudo apt-get install -y curl g++ libpng12-dev  \
      libtiff5-dev libssl-dev libxml2-dev libxslt1-dev libpq-dev postgresql-client \
      postgresql pgadmin3 liblcms2-dev libcrypto++9 libcrypto++-dev \
      graphviz-dev libboost1.55-dev libboost-filesystem1.55-dev libboost-system1.55-dev \
      libexpat1-dev python-software-properties qtbase5-dev qttools5-dev  \
      libqt5svg5-dev qtscript5-dev qtdeclarative5-dev qtmultimedia5-dev \
      libsqlite3-dev qt5-default cmake

  SHELL
end

Update: Just to clarify, it looks like the cloud images for ubuntu precise and up have the correct package already installed. So whether we are talking cloud-init scripts or a vagrant file, apt-add-repository is present. Since add-apt-repository is in the same package that should work as well.

4
  • Order doesn't matter. See askubuntu.com/questions/83489/….
    – edwinksl
    Aug 19, 2016 at 0:45
  • 1
    Do explain why this vagrant file works then. Note I'm not argueing that they do something different. They do exactly the same thing. You just need a package for the add-apt, where as the other works from scratch.
    – Atif
    Aug 19, 2016 at 0:48
  • @atifm: See this answer: $ apt-file search add-apt-repository software-properties-common: /usr/bin/add-apt-repository software-properties-common: /usr/share/man/man1/add-apt-repository.1.gz $ apt-file search apt-add-repository software-properties-common: /usr/bin/apt-add-repository software-properties-common: /usr/share/man/man1/apt-add-repository.1.gz
    – tricasse
    Oct 25, 2016 at 22:53
  • @tricasse: Thanks for the link to apt-file, that'll be useful elsewhere. So your right, they are in the same package as verified by apt-file. That said, it looks like the ubuntu cloud images (for vagrant) for precise and trusty has the package already installed. Not sure if this was always the case, but it seems to be the case at the moment
    – Atif
    Oct 26, 2016 at 10:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .