“UbuntuHelp:AutomaticSecurityUpdates/zh”的版本间的差异
来自Ubuntu中文
第45行: | 第45行: | ||
sudo chmod +x /etc/cron.weekly/apt-security-updates | sudo chmod +x /etc/cron.weekly/apt-security-updates | ||
</nowiki></pre> | </nowiki></pre> | ||
− | ==== | + | ==== 配置之后的信息 ==== |
− | + | 这个脚本每星期运行一次,它安装安全仓库中的全部可用包。它还在 /var/log/apt-security-updates 生成日志,这个日志记录最近检查出来的错误。 | |
− | + | 这个脚本将输出信息到日志文件,为了防止日志文件太大,我们需要让它进行轮换。我们将使用Ubuntu 自带的 logrotate 功能。按 Alt+F2 并输入以下命令: | |
<pre><nowiki> | <pre><nowiki> | ||
gksudo gedit /etc/logrotate.d/apt-security-updates | gksudo gedit /etc/logrotate.d/apt-security-updates | ||
</nowiki></pre> | </nowiki></pre> | ||
− | + | 如果是 KDE, 用下面的命令代替: | |
<pre><nowiki> | <pre><nowiki> | ||
kdesudo kate /etc/logrotate.d/apt-security-updates | kdesudo kate /etc/logrotate.d/apt-security-updates | ||
</nowiki></pre> | </nowiki></pre> | ||
− | + | 粘贴这些到编辑器,保存并退出: | |
<pre><nowiki> | <pre><nowiki> | ||
/var/log/apt-security-updates { | /var/log/apt-security-updates { | ||
第65行: | 第65行: | ||
} | } | ||
</nowiki></pre> | </nowiki></pre> | ||
− | + | 这将轮换日志文件,每周(`weekly`)或者当它超过 250kB(`size 250k`) 时压缩(`compress`)旧的版本。保留之前的两个日志文件(`rotate 2`),并且如果日志文件是空(`notifempty`)的话将不会进行轮换。 | |
− | ==== | + | ==== 使用 cron-apt 去处理自动更新 ==== |
Updating can be also done automatically by using package called [http://packages.ubuntu.com/intrepid/cron-apt cron-apt]. Please read man page before doing anything. | Updating can be also done automatically by using package called [http://packages.ubuntu.com/intrepid/cron-apt cron-apt]. Please read man page before doing anything. | ||
---- | ---- |
2009年9月14日 (一) 00:56的版本
点击翻译: |
English • 中文 |
- title 自动进行安全更新
简介
这是一个简单的指导,它教你创建一个脚本或cron任务而获得本地或外部的安全更新,并安装,他会自动在后台执行。在运行一个没有超级版本时总会有安全隐患,但如果你认为这些对你无关,那么你能按照以下的指导。
使用 apt.conf.d
当你在使用 GNOME ,在“系统”菜单,“系统管理”,“软件源”中,打开“更新”选项卡并选择“自动更新”,也把“安装安全更新时不需确认”。
你也可以通过命令行来配置 unattended-upgrades
包,简单的改变你的/etc/apt/apt.conf.d/10periodic :
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Download-Upgradeable-Packages "1"; APT::Periodic::AutocleanInterval "0"; APT::Periodic::Unattended-Upgrade "1";
和 /etc/apt/apt.conf.d/50unattended-upgrades:
// Automatically upgrade packages from these (origin, archive) pairs Unattended-Upgrade::Allowed-Origins { "Ubuntu intrepid-security"; };
Note: 使用这个方法需要你每次更新系统到新版本时都要修改 /etc/apt/apt.conf.d/10periodic 和 /etc/apt/apt.conf.d/50unattended-upgrades 。务必确认用当前系统的代号去替换 intrepid !
使用 cron
操作指南
首先,按 Alt+F2 并创建一个新文件:
gksudo gedit /etc/cron.weekly/apt-security-updates
如果你是用 KDE, 用下面的命令代替:
kdesudo kate /etc/cron.weekly/apt-security-updates
复制以下文本到这个新文件,保存并退出:
#! /bin/sh echo "**************" >> /var/log/apt-security-updates date >> /var/log/apt-security-updates aptitude update >> /var/log/apt-security-updates aptitude safe-upgrade -o Aptitude::Delete-Unused=false --assume-yes --target-release `lsb_release -cs`-security >> /var/log/apt-security-updates echo "Security updates (if any) installed"
最近(从 Ubuntu 7.10 以来),不推荐使用 aptitude 的 'upgrade' 操作。有两中方法去升级,其中安全的一种(传统的,如果有一个更新需要添加或删除依赖,它将不更新)和另一种全部更新(它将总是升级,甚至添加它或删除它会影响到其他包的,之前称为'dist-upgrade' )。这些操作现在是'safe-upgrade' 或 'full-upgrade'。详细请查看 aptitude (man aptitude
) 的帮助。
当你完成前面的步骤,你还要让这个文件有执行权限。在终端输入下面一行:
sudo chmod +x /etc/cron.weekly/apt-security-updates
配置之后的信息
这个脚本每星期运行一次,它安装安全仓库中的全部可用包。它还在 /var/log/apt-security-updates 生成日志,这个日志记录最近检查出来的错误。 这个脚本将输出信息到日志文件,为了防止日志文件太大,我们需要让它进行轮换。我们将使用Ubuntu 自带的 logrotate 功能。按 Alt+F2 并输入以下命令:
gksudo gedit /etc/logrotate.d/apt-security-updates
如果是 KDE, 用下面的命令代替:
kdesudo kate /etc/logrotate.d/apt-security-updates
粘贴这些到编辑器,保存并退出:
/var/log/apt-security-updates { rotate 2 weekly size 250k compress notifempty }
这将轮换日志文件,每周(`weekly`)或者当它超过 250kB(`size 250k`) 时压缩(`compress`)旧的版本。保留之前的两个日志文件(`rotate 2`),并且如果日志文件是空(`notifempty`)的话将不会进行轮换。
使用 cron-apt 去处理自动更新
Updating can be also done automatically by using package called cron-apt. Please read man page before doing anything.