特殊:Badtitle/NS100:Repositories/CommandLine:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
(未显示4个用户的29个中间版本) | |||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/Repositories/CommandLine}} | {{From|https://help.ubuntu.com/community/Repositories/CommandLine}} | ||
{{Languages| | {{Languages|UbuntuHelp:Repositories/CommandLine}} | ||
#title Repositories Using the Command Line | |||
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]]. | |||
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> | 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> | /etc/apt/sources.list</nowiki></pre> | ||
By editing this file from the command line, we can add, remove, or temporarily disable software repositories. | 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 | sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup | ||
</nowiki></pre> | </nowiki></pre> | ||
<<BR>> | |||
< | Typically, the contents of the ''/etc/apt/sources.list'' looks like this: | ||
Typically, the contents of the ''/etc/apt/sources.list'' | |||
<pre><nowiki> | <pre><nowiki> | ||
# sources.list | |||
# deb cdrom:[Ubuntu 8.04.1 _Hardy Heron_ - Release amd64 (20080701)]/ hardy main restricted | |||
# deb | #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 | |||
=== Explanation of the Repository Format === | deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates main restricted | ||
</nowiki></pre> | |||
https://help.ubuntu.com/community/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. | * 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 | * The lines without hashes are ''apt repository lines''. The first two apt lines in our example are | ||
<pre><nowiki> | |||
deb http://archive.ubuntu.com/ubuntu | deb http://us.archive.ubuntu.com/ubuntu/ hardy main restricted | ||
deb-src http://archive.ubuntu.com/ubuntu | deb-src http://us.archive.ubuntu.com/ubuntu/ hardy main restricted | ||
</nowiki></pre> | </nowiki></pre> | ||
* Here's what they say: | * 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 [https://launchpad.net/ubuntu/+archivemirrors official mirror list] or the self-maintained [[UbuntuWiki:Archive|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 ==== | |||
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 | |||
=== Adding the Universe and Multiverse Repositories === | deb-src http://us.archive.ubuntu.com/ubuntu/ intrepid main restricted | ||
</nowiki></pre> | |||
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: | === 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://archive.ubuntu.com/ubuntu | <pre><nowiki> | ||
deb-src http://archive.ubuntu.com/ubuntu | 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> | </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 | |||
</nowiki></pre> | </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. | |||
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: | 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><nowiki> | |||
sudo apt-get update | sudo apt-get update | ||
</nowiki></pre> | </nowiki></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 ==== | |||
You can add the partner repositories by uncommenting the following lines in your /etc/apt/sources.list file: | |||
<pre><nowiki> | |||
deb http://archive.canonical.com/ubuntu hardy partner | |||
deb-src http://archive.canonical.com/ubuntu hardy partner | |||
</nowiki></pre> | |||
Then update as before: | |||
=== Adding Other Repositories === | <pre><nowiki> | ||
sudo apt-get update | |||
</nowiki></pre> | |||
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 ==== | |||
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 something 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 | <pre><nowiki> | ||
deb http://mirror3.ubuntulinux.nl/ hardy-seveas freenx | |||
deb http://mirror3.ubuntulinux.nl/ | |||
</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. | ||
* Next, make apt aware of the new software repositories by issuing the following command: | * Next, make apt aware of the new software repositories by issuing the following command: | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo apt-get update | |||
</nowiki></pre> | |||
* '''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 | |||
<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. | |||
<pre><nowiki> | |||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup | |||
</nowiki></pre> | |||
* Now make the changes to uncomment all repositories listed in the sources.list file. | |||
<pre><nowiki> | |||
sudo sed -i -e "s/# deb/deb/g" /etc/apt/sources.list | |||
</nowiki></pre> | |||
* Make apt aware of the new software repositories by issuing the following command: | |||
<pre><nowiki> | |||
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. | ||
'''Problem:''' You are looking for a way to enable a repository which you provide for users of your software. | |||
'''Problem:''' You are looking for a way to enable | |||
* First, save your original sources.list file. | * First, save your original sources.list file. | ||
<pre><nowiki> | |||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig | sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig | ||
</nowiki></pre> | </nowiki></pre> | ||
* Now create a new file ending in 'sources.list' in the '/etc/apt/sources.list.d' directory | |||
* Now | <pre><nowiki> | ||
echo 'deb http://www.yourdomain.com/packages/ubuntu /' >> /etc/apt/sources.list.d/yourdomain.sources.list | |||
</nowiki></pre> | </nowiki></pre> | ||
* Make apt aware of the new software repositories by issuing the following command: | * Make apt aware of the new software repositories by issuing the following command: | ||
<pre><nowiki> | |||
sudo apt-get update | sudo apt-get update | ||
</nowiki></pre> | </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. | |||
* 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. | ||
* You may be asked enter a security key when adding a non-Ubuntu repository to your sources. See [[UbuntuHelp:Repositories/Ubuntu?action=show#head-589d9639c60888f17e3d660b375340777b436077|Managing Authentication Keys]] for instructions. | * You may be asked enter a security key when adding a non-Ubuntu repository to your sources. See [[UbuntuHelp: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'''. | * Remember to retrieve updated package lists by issuing a '''sudo apt-get update''' when you're done editing '''sources.list'''. | ||
=== Further Reading === | === Further Reading === | ||
* [http://www.debian.org/doc/manuals/apt-howto/index.en.html The Debian Apt User Manual] | * [http://www.debian.org/doc/manuals/apt-howto/index.en.html The Debian Apt User Manual] | ||
* [[UbuntuHelp:AptGetHowto|Apt-get]] | * [[UbuntuHelp:AptGetHowto|Apt-get]] | ||
* [[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的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/Repositories/CommandLine }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/af | • {{#if: UbuntuHelp:Repositories/CommandLine|Afrikaans| [[::Repositories/CommandLine/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ar | • {{#if: UbuntuHelp:Repositories/CommandLine|العربية| [[::Repositories/CommandLine/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/az | • {{#if: UbuntuHelp:Repositories/CommandLine|azərbaycanca| [[::Repositories/CommandLine/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/bcc | • {{#if: UbuntuHelp:Repositories/CommandLine|جهلسری بلوچی| [[::Repositories/CommandLine/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/bg | • {{#if: UbuntuHelp:Repositories/CommandLine|български| [[::Repositories/CommandLine/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/br | • {{#if: UbuntuHelp:Repositories/CommandLine|brezhoneg| [[::Repositories/CommandLine/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ca | • {{#if: UbuntuHelp:Repositories/CommandLine|català| [[::Repositories/CommandLine/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/cs | • {{#if: UbuntuHelp:Repositories/CommandLine|čeština| [[::Repositories/CommandLine/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/de | • {{#if: UbuntuHelp:Repositories/CommandLine|Deutsch| [[::Repositories/CommandLine/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/el | • {{#if: UbuntuHelp:Repositories/CommandLine|Ελληνικά| [[::Repositories/CommandLine/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/es | • {{#if: UbuntuHelp:Repositories/CommandLine|español| [[::Repositories/CommandLine/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/fa | • {{#if: UbuntuHelp:Repositories/CommandLine|فارسی| [[::Repositories/CommandLine/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/fi | • {{#if: UbuntuHelp:Repositories/CommandLine|suomi| [[::Repositories/CommandLine/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/fr | • {{#if: UbuntuHelp:Repositories/CommandLine|français| [[::Repositories/CommandLine/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/gu | • {{#if: UbuntuHelp:Repositories/CommandLine|ગુજરાતી| [[::Repositories/CommandLine/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/he | • {{#if: UbuntuHelp:Repositories/CommandLine|עברית| [[::Repositories/CommandLine/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/hu | • {{#if: UbuntuHelp:Repositories/CommandLine|magyar| [[::Repositories/CommandLine/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/id | • {{#if: UbuntuHelp:Repositories/CommandLine|Bahasa Indonesia| [[::Repositories/CommandLine/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/it | • {{#if: UbuntuHelp:Repositories/CommandLine|italiano| [[::Repositories/CommandLine/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ja | • {{#if: UbuntuHelp:Repositories/CommandLine|日本語| [[::Repositories/CommandLine/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ko | • {{#if: UbuntuHelp:Repositories/CommandLine|한국어| [[::Repositories/CommandLine/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ksh | • {{#if: UbuntuHelp:Repositories/CommandLine|Ripoarisch| [[::Repositories/CommandLine/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/mr | • {{#if: UbuntuHelp:Repositories/CommandLine|मराठी| [[::Repositories/CommandLine/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ms | • {{#if: UbuntuHelp:Repositories/CommandLine|Bahasa Melayu| [[::Repositories/CommandLine/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/nl | • {{#if: UbuntuHelp:Repositories/CommandLine|Nederlands| [[::Repositories/CommandLine/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/no | • {{#if: UbuntuHelp:Repositories/CommandLine|norsk| [[::Repositories/CommandLine/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/oc | • {{#if: UbuntuHelp:Repositories/CommandLine|occitan| [[::Repositories/CommandLine/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/pl | • {{#if: UbuntuHelp:Repositories/CommandLine|polski| [[::Repositories/CommandLine/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/pt | • {{#if: UbuntuHelp:Repositories/CommandLine|português| [[::Repositories/CommandLine/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ro | • {{#if: UbuntuHelp:Repositories/CommandLine|română| [[::Repositories/CommandLine/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ru | • {{#if: UbuntuHelp:Repositories/CommandLine|русский| [[::Repositories/CommandLine/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/si | • {{#if: UbuntuHelp:Repositories/CommandLine|සිංහල| [[::Repositories/CommandLine/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/sq | • {{#if: UbuntuHelp:Repositories/CommandLine|shqip| [[::Repositories/CommandLine/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/sr | • {{#if: UbuntuHelp:Repositories/CommandLine|српски / srpski| [[::Repositories/CommandLine/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/sv | • {{#if: UbuntuHelp:Repositories/CommandLine|svenska| [[::Repositories/CommandLine/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/th | • {{#if: UbuntuHelp:Repositories/CommandLine|ไทย| [[::Repositories/CommandLine/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/tr | • {{#if: UbuntuHelp:Repositories/CommandLine|Türkçe| [[::Repositories/CommandLine/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/vi | • {{#if: UbuntuHelp:Repositories/CommandLine|Tiếng Việt| [[::Repositories/CommandLine/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/yue | • {{#if: UbuntuHelp:Repositories/CommandLine|粵語| [[::Repositories/CommandLine/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/zh | • {{#if: UbuntuHelp:Repositories/CommandLine|中文| [[::Repositories/CommandLine/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/zh-hans | • {{#if: UbuntuHelp:Repositories/CommandLine|中文(简体)| [[::Repositories/CommandLine/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/zh-hant | • {{#if: UbuntuHelp:Repositories/CommandLine|中文(繁體)| [[::Repositories/CommandLine/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:Repositories/CommandLine|:Repositories/CommandLine|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :Repositories/CommandLine/zh | | {{#ifexist: Repositories/CommandLine/zh | | {{#ifeq: {{#titleparts:Repositories/CommandLine|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:Repositories/CommandLine|1|-1|}} | zh | | }}
- title Repositories Using the Command Line
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. 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. 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
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
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
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
Be aware that the software contained within this repository is NOT open source.
Adding Other Repositories
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
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
- The Debian Apt User Manual
- Apt-get
- Software Management
- Secure Apt on the Debian Wiki