开发者

Append to /etc/apt/sources.list

开发者 https://www.devze.com 2022-12-09 06:48 出处:网络
I\'m creating some scripts to streamline application installations and I need to append to the end of /etc/apt/sources.list

I'm creating some scripts to streamline application installations and I need to append to the end of /etc/apt/sources.list

This code below append to files in ~ but not in /etc/apt/

echo "deb http://ppa.launchpad.net/person/ppa/ubuntu karmic main" >> /etc/apt/sources.list

@meder

I have tried these following commands with no luck:

sudo echo "deb http://ppa.launchpad.net/person/ppa/ubuntu karmic main" >> /etc/apt/sources.list
#===---
sudo sh "echo 'deb http://ppa.lau开发者_Python百科nchpad.net/person/ppa/ubuntu karmic main' >> /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


make sure to have a backup file

echo "foo" | sudo tee -a /etc/apt/sources.list

However, I would really recommend you create a new .list and then use this method to append, store it in /etc/apt/sources.list.d/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号