How can I append text to /etc/apt/sources.list from the command line?
In Karmic, you can just use the add-apt-repository
command, at least for PPAs.
For example:
sudo add-apt-repository ppa:docky
Append to /etc/apt/sources.list
This will work:
sudo sh -c "echo 'deb http://ppa.launchpad.net/person/ppa/ubuntu karmic main' >> /etc/apt/sources.list"
However, instead of editing /etc/apt/sources.list
, it is simpler to add a new *.list
file to /etc/apt/sources.list.d
.
For example,
echo 'deb http://ppa.launchpad.net/person/ppa/ubuntu karmic main' >/tmp/myppa.list
sudo cp /tmp/myppa.list /etc/apt/sources.list.d/
rm /tmp/myppa.list
what is the function of /etc/apt/sources.list.d?
The function of the /etc/apt/sources.list.d
directory is as follows:
Using the directory you can easily add new repositories without the need to edit the central /etc/apt/sources.list
file. I.e. you can just put a file with a unique name and the same format as /etc/apt/sources.list
into this folder and it is used by apt.
In order to remove this source again you can just remove that specific file without the need for handling side effects, parsing or mangling with /etc/apt/sources.list
. It's mainly for scripts or other packages to put their repositories there automatically - if you manually add repositories you could add them to /etc/apt/sources.list
manually.
This answers your question, however, it won't solve your problem. APT is complaining about a missing GPG key which you have to manually import before you can use your newly added repository (GPG verifies all data cryptographically and needs the public keys of the owners for this).
This can be done calling sudo apt-key add public-key-file
or wget -qO - http://example.com/archive.key | sudo apt-key add -
where http://example.com/archive.key
is the URL for the public key (which you should verify before using).
In case of llvm, you could issue wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add -
(according to http://llvm.org/apt/)
Fore more details see
- How to add a GPG key to the apt sources keyring?
add debian repository with sed command
sed -i '$ a\\ndeb http://packages.dotdeb.org wheezy all\ndeb-src http://packages.dotdeb.org wheezy all' /etc/apt/sources.list
Related Topics
Extract Lines When Column K Is Empty with Awk/Perl
How to Disable Non-Breaking Space with Altgr+Space
(13)Permission Denied: Access to /Cgi-Bin/Test.Cgi Denied
Can a Pipe in Linux Ever Lose Data
How to Clean Only Target in Buildroot
How to Build Git with Static Linking
Bash - How to Print Multi Line Strings (With '\N') Using Printf
How to Tell Binary from Text Files in Linux
Unix Bash Shell Programming If Directory Exists
How to Diff Two Sections of The Same File
Alternatives to Make for Linux/Freebsd
Top 'Xterm': Unknown Terminal Type
Can Not Connect to Google Compute Engine via Ssh
Cloudera Manager Failed to Authenticate: Exhausted Available Authentication Methods