如何在/etc/apt/sources.list中添加一行?
我在Ubuntu上更新我的Tor并且它声明:
不要在Ubuntu的Universe中使用这些包。 在获取Tor之前,您需要设置我们的软件包存储库。
然后它声明我必须将此行添加到/etc/apt/sources.list
文件中:
deb http://deb.torproject.org/torproject.org main
我不确定如何在/etc/apt/sources.list
添加一行。
制作当前sources.list
文件的备份副本
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
在当前sources.list
文件中附加new line of text
-
CLI
echo "new line of text" | sudo tee -a /etc/apt/sources.list
-
GUI(文本编辑器)
sudo gedit /etc/apt/sources.list
-
在文本编辑器中当前
sources.list
文本文件末尾的新行上粘贴new line of text
行。 - 保存并关闭
sources.list
不要忘记更新以使用新存储库
sudo apt-get update
为了添加第三方存储库,首先需要此存储库的公钥,在这种情况下,您可以从Ubuntu密钥服务器获取:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 886DDD89
现在,您可以使用add-apt-repository在/etc/apt/sources.list.d/中添加存储库 :
sudo add-apt-repository "deb http://deb.torproject.org/torproject.org $(lsb_release -s -c) main"
添加任何存储库后,始终需要执行
sudo apt-get update
现在您可以为Tor本身安装软件包。 有关如何正确安装Tor的完整说明,请参阅如何安装Tor?
此过程也可以颠倒过来 。
在Ubuntu上最简单的方法:
转到Ubuntu软件中心>编辑>软件源>添加
将Tor网站上的行粘贴到APT行框中。
您也可以手动编辑/etc/apt/sources.list
,但最简单的方法是通过软件中心。
确保也正确输入线,例如
deb http://deb.torproject.org/torproject.org precise main
如果您使用的是12.04。 如果出现问题,请编辑/etc/apt/sources.list
来修复它。
首先,做一个备份。 您可以这样做:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
在终端。 输入密码,然后按Enter键。 它不会显示,甚至不会显示星号。 然后运行:
gksudo gedit /etc/apt/sources.list
并提供您的密码。
添加行:
deb http://deb.torproject.org/torproject.org main
到文件的底部并使用File-> Save来保存它。
然后,返回终端并运行:
sudo apt-get update
然后继续按照说明操作。 这个命令和从sudo apt-get install
开始的sudo apt-get install
可能需要一段时间。 另外,install命令可能会给出:
Do you want to continue[y/n]?
提示,您必须在其中键入y并按Enter继续。
你不需要编辑默认的/etc/apt/sources.list
,你最好将你的Ubuntu升级到Saucy 。 Tor在官方存储库中。
请参阅我的/etc/apt/sources.list
:
deb http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ saucy main restricted universe multiverse deb http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ saucy-updates main restricted universe multiverse deb http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ saucy-backports main restricted universe multiverse deb http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ saucy-security main restricted universe multiverse
只有4行。
我可以下载并安装Tor包:
# aptitude download tor Get: 1 http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ saucy/universe tor amd64 0.2.3.25-1 [953 kB] 84% [1 tor 799 kB/953 kB 84%]201 URI Done: http://us-west-2.ec2.archive.ubuntu.com/ubuntu/pool/universe/t/tor/tor_0.2.3.25-1_amd64.deb RecivedHash: MD5Sum:1cb3ed029c169c3a5e528dd7d28cc60f ExpectedHash: MD5Sum:1cb3ed029c169c3a5e528dd7d28cc60f Fetched 953 kB in 4s (198 kB/s)
根据Tor 0.2.3.25 on Linux
上的http://torstatus.blutmagie.de Tor 0.2.3.25 on Linux
,这是常见的安装之一。
基本上sources.list是您要编辑的文本文件。 Linux是关于文件的,您可以通过更改文件来自定义您的ubuntu。 所以编辑文件(添加或删除文本)的基本方法是使用一些文本编辑器,如:
- emacs,gedit(基于gui)
- nano,vi,vim(基于cli)
您可以通过键入sudo apt-get install text_editor_name来安装它们。
输入man text_editor_name以读取他们的手册页。
-
如果状态是您没有权限,请使用:
chmod 777文件名
查看此video链接,了解如何解决问题
使用终端文本编辑器程序’nano’,我们可以编辑文件’/etc/apt/sources.list’。
打开终端并输入:
‘sudo nano /etc/apt/sources.list’
进行必要的更改后,使用键盘组合’ctrl + o’,然后按’Enter’将文件保存到当前位置。
使用键盘组合’ctrl + x’退出nano。