个人工具

“UbuntuHelp:Repositories/CommandLine”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
 
(未显示3个用户的11个中间版本)
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/Repositories/CommandLine}}
 
{{From|https://help.ubuntu.com/community/Repositories/CommandLine}}
 
{{Languages|UbuntuHelp:Repositories/CommandLine}}
 
{{Languages|UbuntuHelp:Repositories/CommandLine}}
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=terminal.png This page describes how to manage software [[UbuntuHelp:Repositories|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.
+
#title Repositories Using the Command Line
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=eyes.png The instructions on this page assume that you are comfortable using a text editor like GEdit or [[UbuntuHelp:NanoHowto|nano]].
+
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=terminal.png This page describes how to manage software [[UbuntuHelp:Repositories|repositories]] from the command line. This is necessary if you are running a minimal installation, server install (w/Ubuntu|Managing Repositories in Ubuntu]] or [[UbuntuHelp:Repositories/Kubuntu|Kubuntu]].
'''Using the graphical interface to manage software repositories is recommended''', see [[UbuntuHelp:../Ubuntu|Managing Repositories in Ubuntu]] or [[UbuntuHelp:../Kubuntu|Kubuntu]] instead.
+
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=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 [[UbuntuHelp:NanoHowto|nano]]. If you are using a GUI install you can use Nano or GEdit.
=== 背景信息 ===
+
=== The Basics ===
 +
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 <pre><nowiki>
 +
/etc/apt/sources.list</nowiki></pre>
 +
By editing this file from the command line, we can add, remove, or temporarily disable software repositories.
 +
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=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:
 +
<pre><nowiki>
 +
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
 +
</nowiki></pre>
 +
<<BR>>
 +
Typically, the contents of the ''/etc/apt/sources.list'' looks like this:
 +
<pre><nowiki>
 +
# sources.list
 +
# deb cdrom:[Ubuntu 8.04.1 _Hardy Heron_ - Release amd64 (20080701)]/ hardy main restricted
  
Ubuntu 用[http://www.debian.org/doc/user-manuals#apt-howto apt] 包进行管理. Apt在文件中存储了一系列知识仓库或软件信道<br>
+
#deb cdrom:[Ubuntu 8.04.1 _Hardy Heron_ - Release amd64 (20080701)]/ hardy main restricted
<pre>/etc/apt/sources.list</pre>
+
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
在命令行编辑这些文件,我们可以添加, 移动, 活临时使软件的知识仓库无效. https://help.ubuntu.com/community/IconsPage?action=AttachFile&amp;do=get&amp;target=eyes.png '''注意:''' 在编辑它们之前备份一个配置文件是一个好的编辑方式如 '''sources.list''' . 为做到这些,键入以下命令:
+
# newer versions of the distribution.
<pre>sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
+
</pre>
+
<br> 一般来说 ,''/etc/apt/sources.list'' 文件包含的信息如下所示:
+
<pre>deb http://archive.ubuntu.com/ubuntu dapper main restricted
+
deb-src http://archive.ubuntu.com/ubuntu dapper main restricted
+
  
deb http://archive.ubuntu.com/ubuntu dapper-updates main restricted
+
deb http://us.archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://archive.ubuntu.com/ubuntu dapper-updates main restricted
+
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy main restricted
  
# deb http://archive.ubuntu.com/ubuntu dapper universe multiverse
+
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates main restricted
# deb-src http://archive.ubuntu.com/ubuntu dapper universe multiverse
+
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates main restricted
 
+
</nowiki></pre>
# deb http://archive.ubuntu.com/ubuntu dapper-backports main restricted universe multiverse
+
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=important.png the above is not a complete sources.list
# deb-src http://archive.ubuntu.com/ubuntu dapper-backports main restricted universe multiverse
+
==== Explanation of the Repository Format ====
# deb http://security.ubuntu.com/ubuntu breezy-security main restricted
+
* 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.
# deb-src http://security.ubuntu.com/ubuntu breezy-security main restricted
+
* The lines without hashes are ''apt repository lines''. The first two apt lines in our example are
</pre>
+
<pre><nowiki>
 
+
deb http://us.archive.ubuntu.com/ubuntu/ hardy main restricted
=== 解说知识仓库的结构<br> ===
+
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy main restricted
 
+
</nowiki></pre>
* 每一方都由一个或两个hashes (#) 开始注解 andapt 或它的 front-ends apt-get, Synaptic, 没有准备好于 Adept.
+
* 在没有hashes的这一行是 ''apt的注解行''. 首先两个 apt 行在我们的例子中如下<br>
+
<pre>deb http://archive.ubuntu.com/ubuntu dapper main restricted
+
deb-src http://archive.ubuntu.com/ubuntu dapper main restricted
+
</pre>  
+
 
* Here's what they say:
 
* Here's what they say:
* '''deb''': 这些注解包过二进制活前期编译包。许多的用户需要这些注解。<br>
+
* '''deb''': These repositories contain binaries or precompiled packages. These repositories are required for most users.
* '''deb-src''': 这些注解包过包中的源代码。对开发者是很有帮助的。<br>
+
* '''deb-src''': These repositories contain the source code of the packages. Useful for developers.
* '''http://archive.ubuntu.com/ubuntu''': URI (Uniform Resource Identifier),在这种情况下英特网上的地址. 参照 [https://launchpad.net/ubuntu/+archivemirrors official mirror list] 或者到自我修复 [[UbuntuWiki:Archive|mirror list]] 来寻找别的映像.
+
* '''http://archive.ubuntu.com/ubuntu''': The URI (Uniform Resource Identifier), in this case a location on the internet. See the [https://launchpad.net/ubuntu/+archivemirrors official mirror list] or the self-maintained [[UbuntuWiki:Archive|mirror|list]] to find other mirrors.
* '''dapper''' 是在你的分类中发布你的名字或版本。<br>
+
* '''hardy''' is the release name or version of your distribution.
* '''main''' &amp; '''restricted''' 都是一个部分的名字 或者 [[What components|what components]]. 这些按位置来分类可以用几个段名。<br>
+
* '''main''' & '''restricted''' are the section names or [[UbuntuHelp:[what|components]]]. There can be several section names, separated by spaces.
 +
==== Future Versions ====
 +
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=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:
 +
<pre><nowiki>
 +
deb http://us.archive.ubuntu.com/ubuntu/ intrepid main restricted
 +
deb-src http://us.archive.ubuntu.com/ubuntu/ intrepid main restricted
 +
</nowiki></pre>
 +
=== Adding Repositories ===
 +
==== Adding the Universe and Multiverse Repositories ====
 +
Additional software repositories such as [[UbuntuHelp:[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 for the Universe:
 +
<pre><nowiki>
 +
deb http://us.archive.ubuntu.com/ubuntu/ hardy universe
 +
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy universe
 +
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
 +
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
 +
</nowiki></pre>
 +
For the Multiverse:
 +
<pre><nowiki>
 +
deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse
 +
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy multiverse
 +
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
 +
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
  
=== 添加领域和多元的注解<br> ===
+
</nowiki></pre>
 
+
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png It is important to add the hardy-updates part of both the universe and the multiverse to ensure you get updates.
添加软件的注解如 [[What Universe and Multiverse|什么是领域和多元]] 可以不注释相应的apt行 (如 删除 '#' 在起始行). 在我们的例子中,我们不注释以下行:
+
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:
<pre>deb http://archive.ubuntu.com/ubuntu dapper universe multiverse
+
<pre><nowiki>
deb-src http://archive.ubuntu.com/ubuntu dapper universe multiverse
+
sudo apt-get update
</pre>  
+
</nowiki></pre>
然而,如果安全稳定和升级被将被主群组和限制 and updates are enabled for Main and Restricted, we'd also add the following lines, to make sure we get upgrades for our Universe and Multiverse packages (not doing so '''may result in version mismatch''' when installing or upgrading packages):
+
<pre>deb http://archive.ubuntu.com/ubuntu dapper-security universe multiverse
+
deb-src http://archive.ubuntu.com/ubuntu dapper-security universe multiverse
+
deb http://archive.ubuntu.com/ubuntu dapper-updates universe multiverse
+
deb-src http://archive.ubuntu.com/ubuntu dapper-updates universe multiverse
+
</pre>  
+
https://help.ubuntu.com/community/IconsPage?action=AttachFile&amp;do=get&amp;target=eyes.png If you want to enable only Universe but not Multiverse, delete the word 'multiverse' from the lines. 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:
+
<pre>sudo apt-get update
+
</pre>  
+
 
'''Done!''' Your system is ready to install packages from the Universe and Multiverse repositories.
 
'''Done!''' Your system is ready to install packages from the Universe and Multiverse repositories.
 
+
==== Adding Partner Repositories ====
=== Adding Commercial Repository ===
+
You can add the partner repositories by uncommenting the following lines in your /etc/apt/sources.list file:
With Feisty (7.04) there is now a repository specially for commercial software.  You can add it with following line in your /etc/apt/sources.list file:
+
 
<pre><nowiki>
 
<pre><nowiki>
deb http://archive.canonical.com/ubuntu feisty-commercial main
+
deb http://archive.canonical.com/ubuntu hardy partner
 +
deb-src http://archive.canonical.com/ubuntu hardy partner
 +
 
 
</nowiki></pre>
 
</nowiki></pre>
 
Then update as before:
 
Then update as before:
第67行: 第82行:
 
sudo apt-get update
 
sudo apt-get update
 
</nowiki></pre>
 
</nowiki></pre>
Be aware that the software contained within this repository is NOT open source.
+
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=important.png Be aware that the software contained within this repository is NOT open source.
=== Adding Other Repositories ===
+
==== Adding Other Repositories ====
 
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=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 [[UbuntuHelp:RestrictedFormats|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.
 
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=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 [[UbuntuHelp:RestrictedFormats|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:
+
* 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:
 
<pre><nowiki>
 
<pre><nowiki>
deb http://mirror3.ubuntulinux.nl/ dapper-seveas freenx
+
deb http://mirror3.ubuntulinux.nl/ hardy-seveas freenx
 
</nowiki></pre>
 
</nowiki></pre>
 
* Add the line at the end of your '''sources.list''' and save the file.  
 
* Add the line at the end of your '''sources.list''' and save the file.  
第80行: 第95行:
 
sudo apt-get update
 
sudo apt-get update
 
</nowiki></pre>
 
</nowiki></pre>
* '''Done!''' The new software repositories should now be available for use.  
+
* '''Done!''' The new software repositories should now be available for use.
=== Enabling Repositories with a (non-interactive) Script ===
+
==== Adding Launchpad PPA Repositories ====
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=eyes.png This section is directed at advanced users.
+
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.
'''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.
+
* 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).
 +
* If a public key is required and available it is automatically downloaded and registered.
 +
* You must install python-software-properties first
 +
<pre><nowiki>
 +
sudo apt-get install python-software-properties
 +
</nowiki></pre>
 +
<pre><nowiki>
 +
sudo add-apt-repository ppa:<repository-name>
 +
</nowiki></pre>
 +
'''Example:''' sudo add-apt-repository ppa:nhandler
 +
==== Enabling Repositories with a (non-interactive) Script ====
 +
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.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 8.04 LTS.
 
* First, save your original sources.list file.
 
* First, save your original sources.list file.
 
<pre><nowiki>
 
<pre><nowiki>
sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
+
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
 
</nowiki></pre>
 
</nowiki></pre>
* Now make the changes to uncomment all respositories listed in the sources.list file.
+
* Now make the changes to uncomment all repositories listed in the sources.list file.
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo sed -i -e "s/# deb/deb/g" /etc/apt/sources.list
 
sudo sed -i -e "s/# deb/deb/g" /etc/apt/sources.list
第97行: 第124行:
 
</nowiki></pre>
 
</nowiki></pre>
 
* '''Done!''' The new software repositories should now be available for use.  
 
* '''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.
 +
* First, save your original sources.list file.
 +
<pre><nowiki>
 +
sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
 +
</nowiki></pre>
 +
* Now create a new file ending in 'sources.list' in the '/etc/apt/sources.list.d' directory
 +
<pre><nowiki>
 +
echo 'deb http://www.yourdomain.com/packages/ubuntu /' >> /etc/apt/sources.list.d/yourdomain.sources.list
 +
</nowiki></pre>
 +
* Make apt aware of the new software repositories by issuing the following command:
 +
<pre><nowiki>
 +
sudo apt-get update
 +
</nowiki></pre>
 +
* Please be aware that you should sign your packages and ask your users to import your PGP key. Otherwise they will have to confirm that they want to install untrusted packages from your repository.
 
=== Suggestions & Recommendations ===
 
=== Suggestions & Recommendations ===
* 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.
+
* 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!
 
* 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.
 
* Please keep in mind that it may not be legal to enable some ''non-Ubuntu'' software repositories in some countries.
第108行: 第149行:
 
* [[UbuntuHelp:SoftwareManagement|Software Management]]
 
* [[UbuntuHelp:SoftwareManagement|Software Management]]
 
* [http://wiki.debian.org/SecureApt Secure Apt] on the Debian Wiki
 
* [http://wiki.debian.org/SecureApt Secure Apt] on the Debian Wiki
 +
----
 +
[[category:CategoryCommandLine]] [[category:CategoryPackageManagement]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月20日 (四) 00:03的最新版本


  1. title Repositories Using the Command Line

IconsPage?action=AttachFile&do=get&target=terminal.png This page describes how to manage software repositories from the command line. This is necessary if you are running a minimal installation, server install (w/Ubuntu|Managing Repositories in Ubuntu]] or Kubuntu. IconsPage?action=AttachFile&do=get&target=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?action=AttachFile&do=get&target=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:

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

<
> Typically, the contents of the /etc/apt/sources.list looks like this:

# 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
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

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

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

IconsPage?action=AttachFile&do=get&target=important.png the above is not a complete sources.list

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://us.archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy 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 the official mirror list or the self-maintained mirror|list to find other mirrors.
  • hardy is the release name or version of your distribution.
  • main & restricted are the section names or [[UbuntuHelp:[what|components]]]. There can be several section names, separated by spaces.

Future Versions

IconsPage?action=AttachFile&do=get&target=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:

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

Adding Repositories

Adding the Universe and Multiverse Repositories

Additional software repositories such as [[UbuntuHelp:[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 for the Universe:

deb http://us.archive.ubuntu.com/ubuntu/ hardy universe
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy universe
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe

For the Multiverse:

deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy multiverse
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse

IconsPage?action=AttachFile&do=get&target=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:

sudo apt-get update

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

Adding Partner 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
deb-src http://archive.canonical.com/ubuntu hardy partner

Then update as before:

sudo apt-get update

IconsPage?action=AttachFile&do=get&target=important.png Be aware that the software contained within this repository is NOT open source.

Adding Other Repositories

IconsPage?action=AttachFile&do=get&target=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:
deb http://mirror3.ubuntulinux.nl/ hardy-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.

Adding Launchpad PPA Repositories

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).
  • If a public key is required and available it is automatically downloaded and registered.
  • You must install python-software-properties first
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:<repository-name>

Example: sudo add-apt-repository ppa:nhandler

Enabling Repositories with a (non-interactive) Script

IconsPage?action=AttachFile&do=get&target=IconNote.png This section is directed at advanced users. 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.

  • First, save your original sources.list file.
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
  • 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:
sudo apt-get update
  • 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.

  • First, save your original sources.list file.
sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
  • Now create a new file ending in 'sources.list' in the '/etc/apt/sources.list.d' directory
echo 'deb http://www.yourdomain.com/packages/ubuntu /' >> /etc/apt/sources.list.d/yourdomain.sources.list
  • Make apt aware of the new software repositories by issuing the following command:
sudo apt-get update
  • Please be aware that you should sign your packages and ask your users to import your PGP key. Otherwise they will have to confirm that they want to install untrusted packages from your repository.

Suggestions & Recommendations

  • 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