个人工具

“UbuntuHelp:AutomaticSecurityUpdates”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/AutomaticSecurityUpdates}}
 
{{From|https://help.ubuntu.com/community/AutomaticSecurityUpdates}}
 
{{Languages|UbuntuHelp:AutomaticSecurityUpdates}}
 
{{Languages|UbuntuHelp:AutomaticSecurityUpdates}}
=== Information ===
+
#title Automatic Security Updates
This is a simple instructional that will teach you to create a script/cron job to go out and locate security updates and install them automatically in the background. There is always some security risks involved in running software upgrades without supervision, but if you consider those irrelevant for you, then you could follow this simple tutorial.
+
 
 +
=== Introduction ===
 +
This is a simple tutorial that will teach you to create a script and a cron job to go out and automatically install security updates without requiring you to do anything. There are always some security risks involved in running software upgrades without supervision, but there are also benefits.  If you believe it's important to stay up to date with the latest security patches, then you should follow this simple tutorial.
  
 
=== Instructions ===
 
=== Instructions ===
Create a new file by using your favorite text editor. For Ubuntu/Gnome users you can use gedit, and for Kubuntu/KDE users you can use Kate. Also available via the command line are various other text editors that you can use. The file you create, name it ~-apt-security-updates-~ and place it in the directory ~-/etc/cron.weekly/-~. Enter the following text into the ~-apt-security-updates-~ files:
+
To begin, press Alt+F2 and create a new file:
 +
<pre><nowiki>
 +
gksudo gedit /etc/cron.weekly/apt-security-updates
 +
</nowiki></pre>
 +
If you're using KDE, use this command instead:
 +
<pre><nowiki>
 +
kdesu kate /etc/cron.weekly/apt-security-updates
 +
</nowiki></pre>
 +
Copy the following text into this new file, save, and exit:
 
<pre><nowiki>
 
<pre><nowiki>
 
#! /bin/sh
 
#! /bin/sh
第11行: 第21行:
 
date >> /var/log/apt-security-updates
 
date >> /var/log/apt-security-updates
 
aptitude update >> /var/log/apt-security-updates
 
aptitude update >> /var/log/apt-security-updates
aptitude upgrade -o Aptitude::Delete-Unused=false --assume-yes --target-release dapper-security >> /var/log/apt-security-updates
+
aptitude 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"
 
echo "Security updates (if any) installed"
 
</nowiki></pre>
 
</nowiki></pre>
Depending on your Ubuntu release, replace "dapper" with your release, for example "edgy".
 
  
Once you are complete, you want to make the file executable for root. So via the command line/terminal type the following line:
+
Once you are complete, you want to make the file executable. So, via the terminal, type the following line:
 +
<pre><nowiki>
 +
sudo chmod +x /etc/cron.weekly/apt-security-updates
 +
</nowiki></pre>
 +
 
 +
=== Post-Install Setup and Execution Information ===
 +
This script will run once weekly and it installs all available packages from the security repository. It also generates a log in ~-/var/log/apt-security-updates-~ for later inspection in case something goes wrong.
 +
 
 +
This script will output information to a log file, so to prevent this log file from getting too large we need to make sure it gets rotated out.  To do this, we'll use the ~-logrotate-~ utility, which comes with Ubuntu.  Press Alt+F2 and type this command:
 +
<pre><nowiki>
 +
gksudo gedit /etc/logrotate.d/apt-security-updates
 +
</nowiki></pre>
 +
For KDE, use this command instead:
 +
<pre><nowiki>
 +
kdesu kate /etc/logrotate.d/apt-security-updates
 +
</nowiki></pre>
 +
Paste this into the editor, save, and exit:
 
<pre><nowiki>
 
<pre><nowiki>
sudo chmod u=rwx,g=rx,o=rx /etc/cron.weekly/apt-security-updates
+
/var/log/apt-security-updates {
 +
rotate 2
 +
weekly
 +
size 250k
 +
compress
 +
notifempty
 +
}
 
</nowiki></pre>
 
</nowiki></pre>
 +
This will rotate the log file every week (`weekly`), or if it's over 250kB in size (`size 250k`), compressing old versions (`compress`).  The previous two log files will be kept (`rotate 2`), and no rotation will occur if the file is empty (`notifempty`).
  
=== Post Install/Setup/Execution Information ===
+
=== Using cron-apt to handle automatic updating ===
This script will run weekly and it installs all available packages from the security repository. It also generates a log in ~-/var/log/apt-security-updates-~ for later inspection in case something goes wrong.
+
Updating can be also done automatically by using package called [http://packages.ubuntu.com/feisty/admin/cron-apt cron-apt]. Please read man page before doing anything.
  
 
----
 
----
[[category:CategorySecurity]] [[category:CategoryCleanup]]
+
[[category:CategorySecurity]]  
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2007年11月22日 (四) 12:03的版本


  1. title Automatic Security Updates

Introduction

This is a simple tutorial that will teach you to create a script and a cron job to go out and automatically install security updates without requiring you to do anything. There are always some security risks involved in running software upgrades without supervision, but there are also benefits. If you believe it's important to stay up to date with the latest security patches, then you should follow this simple tutorial.

Instructions

To begin, press Alt+F2 and create a new file:

gksudo gedit /etc/cron.weekly/apt-security-updates

If you're using KDE, use this command instead:

kdesu kate /etc/cron.weekly/apt-security-updates

Copy the following text into this new file, save, and exit:

#! /bin/sh
echo "**************" >> /var/log/apt-security-updates
date >> /var/log/apt-security-updates
aptitude update >> /var/log/apt-security-updates
aptitude 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"

Once you are complete, you want to make the file executable. So, via the terminal, type the following line:

sudo chmod +x /etc/cron.weekly/apt-security-updates

Post-Install Setup and Execution Information

This script will run once weekly and it installs all available packages from the security repository. It also generates a log in ~-/var/log/apt-security-updates-~ for later inspection in case something goes wrong.

This script will output information to a log file, so to prevent this log file from getting too large we need to make sure it gets rotated out. To do this, we'll use the ~-logrotate-~ utility, which comes with Ubuntu. Press Alt+F2 and type this command:

gksudo gedit /etc/logrotate.d/apt-security-updates

For KDE, use this command instead:

kdesu kate /etc/logrotate.d/apt-security-updates

Paste this into the editor, save, and exit:

/var/log/apt-security-updates {
rotate 2
weekly
size 250k
compress
notifempty
}

This will rotate the log file every week (`weekly`), or if it's over 250kB in size (`size 250k`), compressing old versions (`compress`). The previous two log files will be kept (`rotate 2`), and no rotation will occur if the file is empty (`notifempty`).

Using cron-apt to handle automatic updating

Updating can be also done automatically by using package called cron-apt. Please read man page before doing anything.