CommandLine

Differences between revisions 11 and 12
Revision 11 as of 2006-06-19 00:57:29
Size: 10558
Editor: dtm9-d9bbb443
Comment: cleaned up
Revision 12 as of 2006-06-19 01:00:06
Size: 10568
Editor: dtm9-d9bbb443
Comment:
Deletions are marked like this. Additions are marked like this.
Line 74: Line 74:
 * The lines without hashes are '''apt repository lines'''. The first two apt lines in our example are  * The lines without hashes are ''apt repository lines''. The first two apt lines in our example are
Line 129: Line 129:
 * Done! The new software repositories should now be available for use.  * '''Done!''' The new software repositories should now be available for use.
Line 156: Line 156:
 * Done! The new software repositories should now be available for use.  * '''Done!''' The new software repositories should now be available for use.

Anchor(what)

What are Repositories?

There are thousands of programs available to install on Ubuntu. These programs are stored in software archives (repositories) and are available for installation over the Internet. This makes it very easy to install new programs. It is also very secure, because each program you install is thoroughly tested and built specifically for Ubuntu.

The Ubuntu software repository is organised into four components, on the basis of the level of support Ubuntu can offer them, and whether or not they comply with Ubuntu's [http://www.ubuntu.com/ubuntu/philosophy Free Software Philosophy]. The components are called Main (officially supported software), Restricted (supported software that is not available under a completely free license), Universe (community-maintained, i.e. not officially supported software) and Multiverse (software that is "not free"). You can find more information about the Ubuntu Repositories [http://www.ubuntu.com/ubuntu/components here].

The Ubuntu Install CDs contain software from the Main and Restricted components. Once your system is made aware of the Internet-based locations for these repositories, many more software programs are made available for installation. Using the software package management tools already installed on your system, you can search for, install and update any piece of software directly over the Internet, without the need for the CD.

Managing Repositories from the Command line

attachment:IconsPage/terminal.png This page describes how to manage software repositories from the command line. This is useful if you prefer not to use (or are unable to access) a graphical user interface. Also, it may come in handy as it works uniformly across all versions of Ubuntu.

attachment:IconsPage/eyes.png The instructions on this page assume that you are comfortable using a text editor like gedit or [:NanoHowto:nano]. If you prefer to use a graphical interface to manage software repositories, see [:../Ubuntu:Managing Repositories in Ubuntu] or [:../Kubuntu:Kubuntu] instead.

BR

Background Information

Ubuntu uses [http://www.debian.org/doc/user-manuals#apt-howto 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.

  • attachment:IconsPage/eyes.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:

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

BR Typically, the contents of the /etc/apt/sources.list file may look something like this:

## sources.list
## General comments about the sources.list file
 deb http://archive.ubuntu.com/ubuntu dapper main restricted
 deb-src http://archive.ubuntu.com/ubuntu dapper main restricted
 
## Comment about the 'Update' repositories
## Comments about the role of the updates
 deb http://archive.ubuntu.com/ubuntu dapper-updates main restricted
 deb-src http://archive.ubuntu.com/ubuntu dapper-updates main restricted
 
## Comment on the 'Universe' repositories
## Comment about the support limitations of Universe & Multiverse
## repositories as well as licence restrictions and update policies.
## Please satisfy yourself as to your rights to use the software.
# deb http://archive.ubuntu.com/ubuntu dapper universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu dapper universe multiverse

## Comment on the 'Backports' repository
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Comment about update and security update limitations
# deb http://archive.ubuntu.com/ubuntu dapper-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu dapper-backports main restricted universe multiverse 
# deb http://security.ubuntu.com/ubuntu breezy-security main restricted
# deb-src http://security.ubuntu.com/ubuntu breezy-security main restricted

BR

Explanation of the Repository Format

  • 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 http://archive.ubuntu.com/ubuntu dapper main restricted
    deb-src http://archive.ubuntu.com/ubuntu dapper main restricted
  • Here's what they say:
    • 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.

    • http://archive.ubuntu.com/ubuntu: The URI (Uniform Resource Identifier), in this case a location on the internet. See [:https//wiki.ubuntu.com/Repositories/Ubuntu?action=show#head-8a18d4250a1c368b58239ba0d6fcc4e5639fa42f:this page] for other repository locations.

    • dapper is the release name or version of your distribution.

    • main & restricted are the section names or [#what components]. There can be several section names, separated by spaces.

BR

Adding the Universe and Multiverse Repositories

Additional software repositories such as [#what 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:

  • deb http://archive.ubuntu.com/ubuntu dapper universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu dapper universe multiverse

attachment:IconsPage/eyes.png If you want to enable only Universe but not Multiverse, delete the word 'multiverse' from the line.

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:

  • sudo apt-get update

Done! Your system is ready to install packages from the Universe and Multiverse repositories.

BR

Adding Other Repositories

attachment: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 somehting like this:
    deb http://mirror3.ubuntulinux.nl/ dapper-seveas freenx
  • 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:
    sudo apt-get update
  • Done! The new software repositories should now be available for use.

BR

Enabling Repositories with a (non-interactive) Script

attachment:IconsPage/eyes.png This section is directed at advanced users.

Problem: You are looking for a way to enable the extra repositories without any user input. BR Example: You are creating a custom install script for an application that needs software packages from the Universe or Multiverse repositories. BR What follows is a simple script that enables the extra repositories that are commented out on a default install of Ubuntu 6.06 LTS.

  • 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
  • Make apt aware of the new software repositories by issuing the following command:
    sudo apt-get update
  • Done! The new software repositories should now be available for use.

BR

Suggestions & Recommendations

BR

  • 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 things go badly wrong, head over to http://www.ubuntulinux.nl/source-o-matic and let the script create a new sources.list file for you.

  • 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 [:Repositories/Ubuntu?action=show#head-589d9639c60888f17e3d660b375340777b436077: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.

BR

Further Reading

BR


CategoryDocumentation

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