CommandLine

Differences between revisions 9 and 10
Revision 9 as of 2006-06-01 22:10:40
Size: 7260
Editor: 137
Comment:
Revision 10 as of 2006-06-18 20:25:23
Size: 7313
Editor: dtm9-d9bbb443
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from AddingRepositoriesCliHowto

By default, Ubuntu does not enable the Universe and Multiverse repositories, nor the Backports. Repositories from other sources than ubuntu may also be added to your machine, though this is generally not recommended. Repositories can be added using graphical means by following the guide at ["AddingRepositoriesHowto"].

Adding Repositories Through Command Line

This article aims to guide you through the process of adding repositories through the console. This is useful when the graphical interface is not functioning correctly. It may be of value to learn this method as it works uniformly across all versions of ubuntu.

The requirements are the ability to use a terminal based text editor like nano (NanoHowto) . If you are more comfortable using another editor, you can use it instead of nano.

Background Information

The repositories are stored in a file /etc/apt/sources.list. By editing this file, we can add/remove repositories. The contents of the sources.list may be viewd by typing:

sudo nano /etc/apt/sources.list

Note: It's always a good idea to backup your sources.list before you edit it.

sudo cp /etc/apt/sources.list /etc/apt/sources.list_bak

Contents of the Default sources.list (with line numbers)

1  deb http://us.archive.ubuntu.com/ubuntu breezy main restricted
2  deb-src http://us.archive.ubuntu.com/ubuntu breezy main restricted
3 
4  ## Uncomment the following two lines to fetch major bug fix updates produced
5  ## after the final release of the distribution.
6  deb http://us.archive.ubuntu.com/ubuntu breezy-updates main restricted
7  deb-src http://us.archive.ubuntu.com/ubuntu breezy-updates main restricted
8 
9  ## Uncomment the following two lines to add software from the 'universe'
10 ## repository.
11 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
12 ## team, and may not be under a free licence. Please satisfy yourself as to
13 ## your rights to use the software. Also, please note that software in
14 ## universe WILL NOT receive any review or updates from the Ubuntu security
15 ## team.
16 # deb http://us.archive.ubuntu.com/ubuntu breezy universe multiverse
17 # deb-src http://us.archive.ubuntu.com/ubuntu breezy universe multiverse
18 
19 ## Uncomment the following two lines to add software from the 'backports'
20 ## repository.
21 ## N.B. software from this repository may not have been tested as
22 ## extensively as that contained in the main release, although it includes
23 ## newer versions of some applications which may provide useful features.
24 ## Also, please note that software in backports WILL NOT receive any review
25 ## or updates from the Ubuntu security team.
26 # deb http://us.archive.ubuntu.com/ubuntu breezy-backports main restricted universe
     multiverse
27 # deb-src http://us.archive.ubuntu.com/ubuntu breezy-backports main restricted universe 
     multiverse 
28 # deb http://security.ubuntu.com/ubuntu breezy-security main restricted
30 # deb-src http://security.ubuntu.com/ubuntu breezy-security main restricted

Explanation of the Repository Format

Shown below are lines 1 & 2 from the above example.

deb http://us.archive.ubuntu.com/ubuntu breezy main restricted
deb-src http://us.archive.ubuntu.com/ubuntu breezy main restricted

This line provides the following information:

  • deb: The repositories can be used for retrieving binaries or precompiled packages. Normally this is the default setting.

  • deb-src: The repositories can used to retrieve source packages if available. This is useful for developers.

  • http://us.archive.ubuntu.com/ubuntu: The URI (Uniform Resource Identifier), which means in this case the location. Other common repositories are in the form of ftp and cdrom mirrors.

  • breezy is the release name

  • main & restricted are the section names. There can be several section names, separated by spaces.

Adding the Universe and Multiverse Repositories

The universe and multiverse repositories may be enabled by uncommenting (deleting the '#' at the beginning of the line) the sources for those repos. In this case, it would be line 16 (this might be different on your system). If you wish to enable only the Universe repository, delete the word 'multiverse' from line 16. If you wish to retrieve source packages, also uncomment line 17. After editing, the line should appear as shown below.

16  deb http://us.archive.ubuntu.com/ubuntu breezy universe multiverse
17  deb-src http://us.archive.ubuntu.com/ubuntu breezy universe multiverse

Save the file by doing ctrl + X and retrieve the updated package lists from the newly added repositories by issuing the command below in a terminal.

sudo apt-get update

Now, your system is ready to install packages from the universe and multiverse repository. Other repositories can be added to this file, but it is not recommended as it might break your system.

Enabling these repositories within a script (non-interactive)

You may have a need to enable the extra repositories without any user input. An example would be if you are creating a custom install script for an application that needed the packages in these extra repositories.

Here is a very simple method to enable the extra repositories that are commented out on a default Ubuntu 6.06 LTS install.

First, save your original sources.list file.

sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig

Now make the changes to uncomment all respositories listed in the sources.list file.

sudo sed -i -e "s/# deb/deb/g" /etc/apt/sources.list

You need to run sudo apt-get update before attempting to install any applications in the new repositories.

Adding Outside Repositories

Sometimes other users will make repositories for packages they have.

Note: Some outside packages could break your Ubuntu installation. It may also be illegal to install a few packages, so please be careful while doing this.

Normally you find websites providing information about a repository in a form like the following example:

deb http://www.grawert.net/ubuntu/ breezy universe

Just copy the line at the end of your sources.list, and then save the file. Then, retrieve updated packages from the repository by issuing the command below in the terminal.

sudo apt-get update

Summary

  • Always back up your sources.list before editing

  • It is not recommended to enable other repositories as they may break your system. Be careful when you do this.
  • Please keep in mind that it may be illegal for you to enable some repositories.
  • If your sources.list becomes unusable, you can generate a custom sources.list at http://ubuntulinux.nl/source-o-matic

  • After editing the sources.list, remember to retrieve updated package lists by issuing a sudo apt-get update.


CategoryDocumentation

Repositories/CommandLine (last edited 2008-08-06 16:38:21 by localhost)