Professional Documents
Culture Documents
This is necessary if
you are running a minimal installation, server install (w/o a GUI) and some users actually prefer this to
GUI tools available in Managing Repositories in Ubuntu or Kubuntu.
IconsPage/important.png If you are using a minimal install or server install you will need to be familiar
with a terminal based text editor like nano. If you are using a GUI install you can use Nano or GEdit.
The Basics
Ubuntu uses apt for package management. Apt stores a list of repositories or software channels in the
file
/etc/apt/sources.list
By editing this file from the command line, we can add, remove, or temporarily disable software
repositories.
IconsPage/IconNote.png Note: It's always a good idea to backup a configuration file like sources.list
before you edit it. To do so, issue the following command:
# sources.list
# deb cdrom:[Ubuntu 8.04.1 _Hardy Heron_ - Release amd64 (20080701)]/ hardy main restricted
#deb cdrom:[Ubuntu 8.04.1 _Hardy Heron_ - Release amd64 (20080701)]/ hardy main restricted
## Major bug fix updates produced after the final release of the
## distribution.
* All the lines beginning with one or two hashes (#) are comments and do not get read by apt or its
front-ends apt-get, Synaptic, and Adept.
*
The lines without hashes are apt repository lines. The first two apt lines in our example are
deb: These repositories contain binaries or precompiled packages. These repositories are
required for most users.
deb-src: These repositories contain the source code of the packages. Useful for developers.
o
http://archive.ubuntu.com/ubuntu: The URI (Uniform Resource Identifier), in this case a location
on the internet. See the official mirror list or the self-maintained mirror list to find other mirrors.
o
main & restricted are the section names or components. There can be several section names,
separated by spaces.
Future Versions
*
IconsPage/IconNote.png in the future you would replace the 'hardy' with the current version you
have installed. So if you have Intrepid installed it would look like below:
Adding Repositories
Additional software repositories such as Universe and Multiverse can be enabled by uncommenting the
corresponding apt line (i.e. delete the '#' at the beginning of the line). In our example, we would
uncomment the following lines for the Universe:
*
IconsPage/IconNote.png It is important to add the hardy-updates part of both the universe and the
multiverse to ensure you get updates.
Once you are satisfied with your choices, save the file. Now, retrieve the updated package lists from the
newly added repositories by issuing the following command:
*
Done! Your system is ready to install packages from the Universe and Multiverse repositories.
You can add the partner repositories by uncommenting the following lines in your /etc/apt/sources.list
file:
*
deb http://archive.canonical.com/ubuntu hardy partner
IconsPage/important.png Be aware that the software contained within this repository is NOT open
source.
IconsPage/warning.png Note: There are some (but not many) good reasons for which you might want to
add non-Ubuntu repositories to your list of software sources. Some software cannot be distributed by
Ubuntu due to patent and licensing restrictions in some countries (see the RestrictedFormats page for
examples). You might want to add repositories that offer such software. Make sure that all repositories
you add in this way have been tested and are known to work on Ubuntu systems. Repositories that are
not designed to work with your version of Ubuntu can introduce inconsistencies in your system and
might force you to re-install.
* You can add custom software repositories by adding the apt repository line of your software source
to the list of repositories. It should look something like this:
Add the line at the end of your sources.list and save the file.
* Next, make apt aware of the new software repositories by issuing the following command:
*
Done! The new software repositories should now be available for use.
Ubuntu 9.10, Karmic Koala, introduces a convenient new command for adding Launchpad PPA (Personal
Package Archive) repositories via the command line: add-apt-repository. This command is apparently
the same as addrepo available on Debian.
* The repository is registered with APT and an entry is created in /etc/apt/sources.list and backs up
to /etc/apt/sources.list.save (It should probably be creating a file in /etc/apt/sources.list.d folder - this
may be the case in the future).
Problem: You are looking for a way to enable the extra repositories without any user input.
Example: You are creating a custom install script for an application that needs software packages from
the Universe or Multiverse repositories.
What follows is a simple script that enables the extra repositories that are commented out on a default
install of Ubuntu 8.04 LTS.
* Now make the changes to uncomment all repositories listed in the sources.list file.
sudo sed -i -e "s/# deb/deb/g" /etc/apt/sources.list
* Make apt aware of the new software repositories by issuing the following command:
Done! The new software repositories should now be available for use.
Problem: You are looking for a way to enable a repository which you provide for users of your software.
* Make apt aware of the new software repositories by issuing the following command:
It is always a good idea to back up configuration files like /etc/apt/sources.list before you begin
editing. You can then revert your changes if needed.
If you decide to add other repositories to sources.list, make sure that the repository is meant to work
(and known to work) with Ubuntu. Repositories that are not designed to work with your version of
Ubuntu can introduce inconsistencies in your system and might force you to re-install. Also, make sure
that you really need to add external repositories as the software package(s) you are looking for may
already have been introduced into the official repositories!
Please keep in mind that it may not be legal to enable some non-Ubuntu software repositories in
some countries.
You may be asked enter a security key when adding a non-Ubuntu repository to your sources. See
Managing Authentication Keys for instructions.
Remember to retrieve updated package lists by issuing a sudo apt-get update when you're done
editing sources.list.
Further Reading
Apt-get
Software Management
CategoryCommandLine CategoryPackageManagement
* Parent Page
* Page History
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details