我知道在 Ubuntu 中有一个 GUISoftware & Updates来启用更新通道
- 更新
- 建议的
- 向后移植
- 安全
如此屏幕截图所示:
我正在寻找一种简单的方法在终端内使用诸如以下的命令来执行此操作
sudo apt-add-update enable updates
sudo apt-add-update enable proposed
sudo apt-add-update enable backports
sudo apt-add-update enable security
sudo apt-add-update disable updates
sudo apt-add-update disable proposed
sudo apt-add-update disable backports
sudo apt-add-update disable security
还有一件事
sudo apt-add-update enable default
sudo apt-add-update disable default
一些例子可以更好地理解
一个空
sources.list
cat /etc/apt/sources.list
<empty>
sudo apt-add-update enable security
<empty>
一个启用的存储库 (
main
)cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu wily main
sudo apt-add-update enable security
deb http://archive.ubuntu.com/ubuntu wily main deb http://archive.ubuntu.com/ubuntu wily-security main
一行或两行中的两个或多个已启用的存储库
cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu wily main universe
或者
deb http://archive.ubuntu.com/ubuntu wily main deb http://archive.ubuntu.com/ubuntu wily universe
sudo apt-add-update enable security
deb http://archive.ubuntu.com/ubuntu wily main universe deb http://archive.ubuntu.com/ubuntu wily-security main universe
或者
deb http://archive.ubuntu.com/ubuntu wily main deb http://archive.ubuntu.com/ubuntu wily-security main deb http://archive.ubuntu.com/ubuntu wily universe deb http://archive.ubuntu.com/ubuntu wily-security universe
有
deb-src
条目cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu wily main universe deb-src http://archive.ubuntu.com/ubuntu wily main universe
sudo apt-add-update enable security
deb http://archive.ubuntu.com/ubuntu wily main universe deb-src http://archive.ubuntu.com/ubuntu wily main universe deb http://archive.ubuntu.com/ubuntu wily-security main universe deb-src http://archive.ubuntu.com/ubuntu wily-security main universe
有无效
deb-src
条目cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu wily main universe # deb-src http://archive.ubuntu.com/ubuntu wily main universe
sudo apt-add-update enable security
deb http://archive.ubuntu.com/ubuntu wily main universe # deb-src http://archive.ubuntu.com/ubuntu wily main universe deb http://archive.ubuntu.com/ubuntu wily-security main universe
default
事情_cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu wily-security universe
sudo apt-add-update enable default
deb http://archive.ubuntu.com/ubuntu wily universe deb http://archive.ubuntu.com/ubuntu wily-security universe
只有一个条目和
disable
动作cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu wily-security universe
sudo apt-add-update disable security
<empty>
不同或相同的存储库的不同或相同的服务器,尊重每个服务器
cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu wily universe deb http://us.archive.ubuntu.com/ubuntu wily main
sudo apt-add-update enable security
deb http://archive.ubuntu.com/ubuntu wily universe deb http://us.archive.ubuntu.com/ubuntu wily main deb http://archive.ubuntu.com/ubuntu wily-security universe deb http://us.archive.ubuntu.com/ubuntu wily-security main
不同存储库的不同 Ubuntu 版本,尊重每个版本
cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu wily main universe deb http://archive.ubuntu.com/ubuntu trusty main
sudo apt-add-update enable security
deb http://archive.ubuntu.com/ubuntu wily main universe deb http://archive.ubuntu.com/ubuntu trusty main deb http://archive.ubuntu.com/ubuntu wily-security main universe deb http://archive.ubuntu.com/ubuntu trusty-security main
中的 PPA 或其他包源(非规范)
sources.list
?忽视!
不要更改协议,例如
https
,http
,tor
, ...
2015 年 11 月 27 日更新:
脚本的第二个版本仍然让我对源代码的臃肿和我不得不使用几种不同工具的事实感到不满。因此我试图只用 AWK 重写脚本。
新脚本使用纯 AWK,更符合要求。本质上它会在
/etc/apt/sources.list
每次运行时重写。脚本运行
sudo apt-get update
后需要更新,所以脚本退出成功后再运行。该文件必须启用可执行权限
chmod +x add-update.awk
并保存在$PATH
变量中包含的任何目录中。特别建议将脚本保存到$HOME/bin
文件夹(也必须附加到$PATH
变量)。/etc/apt/sources.list
不需要备份原始文件,但强烈建议备份。要备份文件,请执行sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
用法:
来源在github
演示:
源代码
--
之前的版本
github 上的版本#1(带有 AWK 和 SED 的 bash 脚本)
github 上的版本#2(也是 bash 脚本)
I analysed the source of Ubuntu Software Center that written in
python
.After, I wrote following code runs well.
aptsources
is a python module used by Ubuntu Software Center to manage/etc/apt/sources.list
and/etc/apt/sources.list.d
.Save this code with the file name,
/usr/local/bin/apt-add-update
. And then run as following.I updated it for the multi distro support, e.g.
trusty
andwily
.Reference URL is https://github.com/dupingping/apt-add-update/tree/master
Usage:
Here main points:
I parsed the file because I was looking for some other options myself.
Checks if any is a mirror, either official including (old-releases, ports) or other mirrors provided by community loaded from
python-apt
package (it contains a file with all mirrors).Always keep the official URI in the file. So even with all disabled, it will keep a commented line for a persistence setting. It resolves the lines to the minimum with alphabetic sorting type, url, dist, comp.
Prints to the stdout if it get an input file as 3rd argument or no permission to write
/etc/apt/sources.list
[ options ]
like[ arch=amd64 ]
.disable default
了我要求用户指定要禁用的内容。下载:带有完整的测试集。
https://github.com/sneetsher/au_700860_apt_channels
脚本:
您可以使用
add-apt-repository
.例如,您可以
proposed
添加它将添加
deb
和deb-src
行到/etc/apt/sources.list
. 但源代码行将被注释。If you run
add-apt-repository
with-s
parameter, it will not comment outdeb-src
.You can enable
security
byThis does exactly what has been asked;
I'll update this from time to time if necessary;
The bleeding edge version can be found at this GitHub repository;
To install from the GitHub repository:
git
:sudo apt-get install git
git clone https://github.com/kos0/addRemoveDistribution.git
Synopsis: