<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LinuxByte &#187; 精品文档</title>
	<atom:link href="http://www.linuxbyte.org/category/doc/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linuxbyte.org</link>
	<description>一个Linux Blog</description>
	<lastBuildDate>Thu, 26 Jan 2012 08:13:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>History 命令经典用法15例</title>
		<link>http://www.linuxbyte.org/history-ming-ling-jing-dian-yong-fa-15li.html</link>
		<comments>http://www.linuxbyte.org/history-ming-ling-jing-dian-yong-fa-15li.html#comments</comments>
		<pubDate>Wed, 16 Feb 2011 05:01:49 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[精品文档]]></category>
		<category><![CDATA[系统管理]]></category>
		<category><![CDATA[History]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=607</guid>
		<description><![CDATA[如果你经常使用 Linux 命令行，那么使用 history（历史）命令可以有效地提升你的效率。本文将通过实例的方式向你介绍 history 命令的 15 个用法。 使用 HISTTIMEFORMAT 显示时间戳 当你从命令行执行 ... ]]></description>
			<content:encoded><![CDATA[<p>如果你经常使用 Linux 命令行，那么使用 history（历史）命令可以有效地提升你的效率。本文将通过实例的方式向你介绍 history 命令的 15 个用法。</p>
<p><strong>使用 HISTTIMEFORMAT 显示时间戳</strong></p>
<p>当你从命令行执行 history 命令后，通常只会显示已执行命令的序号和命令本身。如果你想要查看命令历史的时间戳，那么可以执行：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># export HISTTIMEFORMAT='%F %T '</span>
<span style="color: #666666; font-style: italic;"># history | more</span>
<span style="color: #000000;">1</span>  <span style="color: #000000;">2008</span>-08-05 <span style="color: #000000;">19</span>:02:<span style="color: #000000;">39</span> service network restart
<span style="color: #000000;">2</span>  <span style="color: #000000;">2008</span>-08-05 <span style="color: #000000;">19</span>:02:<span style="color: #000000;">39</span> <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000;">3</span>  <span style="color: #000000;">2008</span>-08-05 <span style="color: #000000;">19</span>:02:<span style="color: #000000;">39</span> <span style="color: #c20cb9; font-weight: bold;">id</span>
<span style="color: #000000;">4</span>  <span style="color: #000000;">2008</span>-08-05 <span style="color: #000000;">19</span>:02:<span style="color: #000000;">39</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>redhat-release</pre></div></div>

<p><span id="more-607"></span><br />
<strong>注意</strong>：这个功能只能用在当 HISTTIMEFORMAT 这个环境变量被设置之后，之后的那些新执行的 bash 命令才会被打上正确的时间戳。在此之前的所有命令，都将会显示成设置 HISTTIMEFORMAT 变量的时间。[感谢 NightOwl 读者补充]</p>
<p><strong>使用 Ctrl+R 搜索历史</strong></p>
<p>Ctrl+R 是我经常使用的一个快捷键。此快捷键让你对命令历史进行搜索，对于想要重复执行某个命令的时候非常有用。当找到命令后，通常再按回车键就可以执行该命令。如果想对找到的命令进行调整后再执行，则可以按一下左或右方向键。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># [Press Ctrl+R from the command prompt, which will display the reverse-i-search prompt]</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span>reverse-i-search<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">red</span>‘: <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>redhat-release
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Note: Press enter when you see your <span style="color: #7a0874; font-weight: bold;">command</span>, <span style="color: #c20cb9; font-weight: bold;">which</span> will execute the <span style="color: #7a0874; font-weight: bold;">command</span> from the <span style="color: #7a0874; font-weight: bold;">history</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #666666; font-style: italic;"># cat /etc/redhat-release</span>
Fedora release <span style="color: #000000;">9</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>Sulphur<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p><strong>快速重复执行上一条命令</strong></p>
<p>有 4 种方法可以重复执行上一条命令：</p>
<ol>
<li>使用上方向键，并回车执行。</li>
<li>按 !! 并回车执行。</li>
<li>输入 !-1 并回车执行。</li>
<li>按 Ctrl+P 并回车执行。</li>
</ol>
<p><strong>从命令历史中执行一个指定的命令</strong></p>
<p>在下面的例子中，如果你想重复执行第 4 条命令，那么可以执行 !4：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># history | more</span>
<span style="color: #000000;">1</span>  service network restart
<span style="color: #000000;">2</span>  <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000;">3</span>  <span style="color: #c20cb9; font-weight: bold;">id</span>
<span style="color: #000000;">4</span>  <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>redhat-release
<span style="color: #666666; font-style: italic;"># !4</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>redhat-release
Fedora release <span style="color: #000000;">9</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>Sulphur<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p><strong>通过指定关键字来执行以前的命令</strong></p>
<p>在下面的例子，输入 !ps 并回车，将执行以 ps 打头的命令：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># !ps</span>
<span style="color: #c20cb9; font-weight: bold;">ps</span> aux <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> yp
root     <span style="color: #000000;">16947</span>  <span style="color: #000000;">0.0</span>  <span style="color: #000000;">0.1</span>  <span style="color: #000000;">36516</span>  <span style="color: #000000;">1264</span> ?        Sl   <span style="color: #000000;">13</span>:<span style="color: #000000;">10</span>   <span style="color: #000000;">0</span>:00 ypbind
root     <span style="color: #000000;">17503</span>  <span style="color: #000000;">0.0</span>  <span style="color: #000000;">0.0</span>   <span style="color: #000000;">4124</span>   <span style="color: #000000;">740</span> pts<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>    S+   <span style="color: #000000;">19</span>:<span style="color: #000000;">19</span>   <span style="color: #000000;">0</span>:00 <span style="color: #c20cb9; font-weight: bold;">grep</span> yp</pre></div></div>

<p><strong>使用 HISTSIZE 控制历史命令记录的总行数</strong></p>
<p>将下面两行内容追加到 .bash_profile 文件并重新登录 bash shell，命令历史的记录数将变成 450 条：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># vi ~/.bash_profile</span>
<span style="color: #007800;">HISTSIZE</span>=<span style="color: #000000;">450</span>
<span style="color: #007800;">HISTFILESIZE</span>=<span style="color: #000000;">450</span></pre></div></div>

<p><strong>使用 HISTFILE 更改历史文件名称</strong></p>
<p>默认情况下，命令历史存储在 ~/.bash<em>history 文件中。添加下列内容到 .bash</em>profile 文件并重新登录 bash shell，将使用 .commandline_warrior 来存储命令历史：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># vi ~/.bash_profile</span>
<span style="color: #007800;">HISTFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>.commandline_warrior</pre></div></div>

<p><strong>使用 HISTCONTROL 从命令历史中剔除连续重复的条目</strong></p>
<p>在下面的例子中，pwd 命令被连续执行了三次。执行 history 后你会看到三条重复的条目。要剔除这些重复的条目，你可以将 HISTCONTROL 设置为 ignoredups：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># pwd</span>
<span style="color: #666666; font-style: italic;"># pwd</span>
<span style="color: #666666; font-style: italic;"># pwd</span>
<span style="color: #666666; font-style: italic;"># history | tail -4</span>
<span style="color: #000000;">44</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
<span style="color: #000000;">45</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
<span style="color: #000000;">46</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Note that there are three <span style="color: #7a0874; font-weight: bold;">pwd</span> commands <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #7a0874; font-weight: bold;">history</span>, after executing <span style="color: #7a0874; font-weight: bold;">pwd</span> <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">times</span> <span style="color: #c20cb9; font-weight: bold;">as</span> shown above<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000;">47</span>  <span style="color: #7a0874; font-weight: bold;">history</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-4</span>
<span style="color: #666666; font-style: italic;"># export HISTCONTROL=ignoredups</span>
<span style="color: #666666; font-style: italic;"># pwd</span>
<span style="color: #666666; font-style: italic;"># pwd</span>
<span style="color: #666666; font-style: italic;"># pwd</span>
<span style="color: #666666; font-style: italic;"># history | tail -3</span>
<span style="color: #000000;">56</span>  <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=ignoredups
<span style="color: #000000;">57</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Note that there is only one <span style="color: #7a0874; font-weight: bold;">pwd</span> <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #000000; font-weight: bold;">in</span> the <span style="color: #7a0874; font-weight: bold;">history</span>, even after executing <span style="color: #7a0874; font-weight: bold;">pwd</span> <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">times</span> <span style="color: #c20cb9; font-weight: bold;">as</span> shown above<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000;">58</span>  <span style="color: #7a0874; font-weight: bold;">history</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-4</span></pre></div></div>

<p><strong>使用 HISTCONTROL 清除整个命令历史中的重复条目</strong></p>
<p>上例中的 ignoredups 只能剔除连续的重复条目。要清除整个命令历史中的重复条目，可以将 HISTCONTROL 设置成 erasedups：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># export HISTCONTROL=erasedups</span>
<span style="color: #666666; font-style: italic;"># pwd</span>
<span style="color: #666666; font-style: italic;"># service httpd stop</span>
<span style="color: #666666; font-style: italic;"># history | tail -3</span>
<span style="color: #000000;">38</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
<span style="color: #000000;">39</span>  service httpd stop
<span style="color: #000000;">40</span>  <span style="color: #7a0874; font-weight: bold;">history</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-3</span>
<span style="color: #666666; font-style: italic;"># ls -ltr</span>
<span style="color: #666666; font-style: italic;"># service httpd stop</span>
<span style="color: #666666; font-style: italic;"># history | tail -6</span>
<span style="color: #000000;">35</span>  <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=erasedups
<span style="color: #000000;">36</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
<span style="color: #000000;">37</span>  <span style="color: #7a0874; font-weight: bold;">history</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-3</span>
<span style="color: #000000;">38</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-ltr</span>
<span style="color: #000000;">39</span>  service httpd stop
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Note that the previous service httpd stop after <span style="color: #7a0874; font-weight: bold;">pwd</span> got erased<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000;">40</span>  <span style="color: #7a0874; font-weight: bold;">history</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-6</span></pre></div></div>

<p><strong>使用 HISTCONTROL 强制 history 不记住特定的命令</strong></p>
<p>将 HISTCONTROL 设置为 ignorespace，并在不想被记住的命令前面输入一个空格：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># export HISTCONTROL=ignorespace</span>
<span style="color: #666666; font-style: italic;"># ls -ltr</span>
<span style="color: #666666; font-style: italic;"># pwd</span>
<span style="color: #666666; font-style: italic;">#  service httpd stop [Note that there is a space at the beginning of service, to ignore this command from history]</span>
<span style="color: #666666; font-style: italic;"># history | tail -3</span>
<span style="color: #000000;">67</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-ltr</span>
<span style="color: #000000;">68</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
<span style="color: #000000;">69</span>  <span style="color: #7a0874; font-weight: bold;">history</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-3</span></pre></div></div>

<p><strong>使用 -c 选项清除所有的命令历史</strong></p>
<p>如果你想清除所有的命令历史，可以执行：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># history -c</span></pre></div></div>

<p><strong>命令替换</strong></p>
<p>在下面的例子里，!!:$ 将为当前的命令获得上一条命令的参数：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ls anaconda-ks.cfg</span>
anaconda-ks.cfg
<span style="color: #666666; font-style: italic;"># vi !!:$</span>
<span style="color: #c20cb9; font-weight: bold;">vi</span> anaconda-ks.cfg</pre></div></div>

<p><strong>补充</strong>：使用 !$ 可以达到同样的效果，而且更简单。[感谢 wanzigunzi 读者补充]</p>
<p>下例中，!^ 从上一条命令获得第一项参数：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cp anaconda-ks.cfg anaconda-ks.cfg.bak</span>
anaconda-ks.cfg
<span style="color: #666666; font-style: italic;"># vi -5 !^</span>
<span style="color: #c20cb9; font-weight: bold;">vi</span> anaconda-ks.cfg</pre></div></div>

<p><strong>为特定的命令替换指定的参数</strong></p>
<p>在下面的例子，!cp:2 从命令历史中搜索以 cp 开头的命令，并获取它的第二项参数：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cp ~/longname.txt /really/a/very/long/path/long-filename.txt</span>
<span style="color: #666666; font-style: italic;"># ls -l !cp:2</span>
<span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>really<span style="color: #000000; font-weight: bold;">/</span>a<span style="color: #000000; font-weight: bold;">/</span>very<span style="color: #000000; font-weight: bold;">/</span>long<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>long-filename.txt</pre></div></div>

<p>下例里，!cp:$ 获取 cp 命令的最后一项参数：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ls -l !cp:$</span>
<span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>really<span style="color: #000000; font-weight: bold;">/</span>a<span style="color: #000000; font-weight: bold;">/</span>very<span style="color: #000000; font-weight: bold;">/</span>long<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>long-filename.txt</pre></div></div>

<p><strong>使用 HISTSIZE 禁用 history</strong></p>
<p>如果你想禁用 history，可以将 HISTSIZE 设置为 0：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># export HISTSIZE=0</span>
<span style="color: #666666; font-style: italic;"># history</span>
<span style="color: #666666; font-style: italic;"># [Note that history did not display anything]</span></pre></div></div>

<p><strong>使用 HISTIGNORE 忽略历史中的特定命令</strong></p>
<p>下面的例子，将忽略 pwd、ls、ls -ltr 等命令：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># export HISTIGNORE=”pwd:ls:ls -ltr:”</span>
<span style="color: #666666; font-style: italic;"># pwd</span>
<span style="color: #666666; font-style: italic;"># ls</span>
<span style="color: #666666; font-style: italic;"># ls -ltr</span>
<span style="color: #666666; font-style: italic;"># service httpd stop</span>
<span style="color: #666666; font-style: italic;"># history | tail -3</span>
<span style="color: #000000;">79</span>  <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTIGNORE</span>=”<span style="color: #7a0874; font-weight: bold;">pwd</span>:<span style="color: #c20cb9; font-weight: bold;">ls</span>:<span style="color: #c20cb9; font-weight: bold;">ls</span> -ltr:”
<span style="color: #000000;">80</span>  service httpd stop
<span style="color: #000000;">81</span>  <span style="color: #7a0874; font-weight: bold;">history</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Note that <span style="color: #7a0874; font-weight: bold;">history</span> did not record <span style="color: #7a0874; font-weight: bold;">pwd</span>, <span style="color: #c20cb9; font-weight: bold;">ls</span> and <span style="color: #c20cb9; font-weight: bold;">ls</span> -ltr<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>原文地址：</p>
<p>http://www.javaeye.com/topic/835928</p>
<h2  class="related_post_title">与本文关系暧昧的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/unixshellbian-cheng-di-san-ban.html" title="Unix.Shell编程(第三版)">Unix.Shell编程(第三版)</a></li><li><a href="http://www.linuxbyte.org/yong-shc-jiami-shell.html" title="用shc 加密shell">用shc 加密shell</a></li><li><a href="http://www.linuxbyte.org/shel-fang-zhi-wu-cao-zuo.html" title="用 !$ 防止误操作">用 !$ 防止误操作</a></li><li><a href="http://www.linuxbyte.org/fun-unix-shell.html" title="一些奇怪的unix指令名字的由来">一些奇怪的unix指令名字的由来</a></li><li><a href="http://www.linuxbyte.org/fun-bash-shell.html" title="几个有用的bash shell组合">几个有用的bash shell组合</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2011<br />
Source: <a href="http://www.linuxbyte.org/history-ming-ling-jing-dian-yong-fa-15li.html">History 命令经典用法15例</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/history" rel="tag">History</a>, <a href="http://www.linuxbyte.org/tag/shell" rel="tag">shell</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/history" title="History" rel="tag">History</a>, <a href="http://www.linuxbyte.org/tag/shell" title="shell" rel="tag">shell</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/history-ming-ling-jing-dian-yong-fa-15li.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>服务器中swap 的划分</title>
		<link>http://www.linuxbyte.org/fu-wu-qi-zhong-swap-de-hua-fen.html</link>
		<comments>http://www.linuxbyte.org/fu-wu-qi-zhong-swap-de-hua-fen.html#comments</comments>
		<pubDate>Tue, 28 Jul 2009 07:24:22 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[服务器应用]]></category>
		<category><![CDATA[精品文档]]></category>
		<category><![CDATA[swap]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=461</guid>
		<description><![CDATA[RHEL的官方文档，这是针对服务器的： http://kbase.redhat.com/faq/docs/DOC-17162 目前RedHat推荐交换分区的大小应当与系统物理内存的大小保持线性比例关系。不过在小于2GB物理内存的系统中，交换分区... ]]></description>
			<content:encoded><![CDATA[<p>RHEL的官方文档，这是针对服务器的：</p>
<p>http://kbase.redhat.com/faq/docs/DOC-17162</p>
<p>目前RedHat推荐交换分区的大小应当与系统物理内存的大小保持线性比例关系。不过在小于2GB物理内存的系统中，交换分区大小应该设置为内存大小的两倍，如果内存大小多于2GB，交换分区大小应该是物理内存大小加上2GB。其原因在于，系统中的物理内存越大， 对于内存的负荷可能也越大。<br />
      但是，如果物理内存大小扩展到数百GB，这样做就没什么意义了。<span id="more-461"></span><br />
      实际上，系统中交换分区的大小并不取决于物理内存的量，而是取决于系统中内存的负荷。Red Hat Enterprise Linux5可以在这样的情况下工作：完全没有交换分区，而且系统中匿名内存页和共享内存页小于3/4的物理内存量。在这种情况下，系统会将匿名内存页和共享内存页锁定在物理内存中，而使用剩余的物理内存来缓冲文件系统数据(pagecache)，当内存耗尽时，系统内核只会回收利用这些 pagecache内存。<br />
      考虑到以下情况：<br />
      1）安装系统时难以确定内存的负荷，如何设置交换分区大小<br />
      2）系统中物理内存越大，所需交换分区就会越少<br />
      因此，在Red Hat Enterprise Linux 5中，以下是设置合适的交换分区大小的规则：<br />
          小于等于4G物理内存的系统，至少设置2GB的交换分区<br />
          4G～16G物理内存的系统，至少设置4GB的交换分区<br />
          16G～64G物理内存的系统，至少设置8GB的交换分区<br />
          16G～256G物理内存的系统，至少设置16GB的交换分区</p>
<h2  class="related_post_title">其他大家爱看的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/%e5%8d%87%e7%ba%a7squid-26-%e5%88%b027-%e7%9a%84%e5%86%a4%e6%9e%89%e8%b7%af.html" title="升级squid 2.6 到2.7 的冤枉路">升级squid 2.6 到2.7 的冤枉路</a></li><li><a href="http://www.linuxbyte.org/rang-wordpress-zi-dong-sheng-ji-shi-wu-xu-tian-jia-ftp.html" title="让Wordpress 自动升级时无需添加FTP">让Wordpress 自动升级时无需添加FTP</a></li><li><a href="http://www.linuxbyte.org/zhen-dui-webfu-wu-qi-zong-ti-you-hua.html" title="针对Web服务器总体优化">针对Web服务器总体优化</a></li><li><a href="http://www.linuxbyte.org/opensuse-111-anzhuang-peizhi.html" title="Opensuse 11.1 安装配置">Opensuse 11.1 安装配置</a></li><li><a href="http://www.linuxbyte.org/ubuntu-kao-lv-yong-lightdm-qu-dai-gdm.html" title="Ubuntu 考虑用 LightDM 取代 GDM ">Ubuntu 考虑用 LightDM 取代 GDM </a></li><li><a href="http://www.linuxbyte.org/kernel_arguments.html" title="Linux内核引导参数简介">Linux内核引导参数简介</a></li><li><a href="http://www.linuxbyte.org/amuse-player.html" title="在线音乐播放器-Amuse Player">在线音乐播放器-Amuse Player</a></li><li><a href="http://www.linuxbyte.org/apache-url-rewrite.html" title="Apache Url Rewrite(mod_rewrite)">Apache Url Rewrite(mod_rewrite)</a></li><li><a href="http://www.linuxbyte.org/jie-jue-ubuntu-10-04lucid-firefox-man-de-wen-ti.html" title="解决 ubuntu 10.04(Lucid) Firefox 慢的问题">解决 ubuntu 10.04(Lucid) Firefox 慢的问题</a></li><li><a href="http://www.linuxbyte.org/fun-bash-shell.html" title="几个有用的bash shell组合">几个有用的bash shell组合</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2009<br />
Source: <a href="http://www.linuxbyte.org/fu-wu-qi-zhong-swap-de-hua-fen.html">服务器中swap 的划分</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/swap" rel="tag">swap</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/swap" title="swap" rel="tag">swap</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/fu-wu-qi-zhong-swap-de-hua-fen.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>用Sysctl 调整Linux操作系统的性能</title>
		<link>http://www.linuxbyte.org/sysctl-minihowto.html</link>
		<comments>http://www.linuxbyte.org/sysctl-minihowto.html#comments</comments>
		<pubDate>Tue, 19 Aug 2008 08:52:30 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[精品文档]]></category>
		<category><![CDATA[系统管理]]></category>
		<category><![CDATA[Sysctl]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=222</guid>
		<description><![CDATA[Sysctl是一个允许您改变正在运行中的Linux系统的接口。它包含一些 TCP/IP 堆栈和虚拟内存系统的高级选项，这可以让有经验的管理员提高引人注目的系统性能。用sysctl可以读取设置超过五百个系... ]]></description>
			<content:encoded><![CDATA[<p>Sysctl是一个允许您改变正在运行中的Linux系统的接口。它包含一些 TCP/IP  堆栈和虚拟内存系统的高级选项，这可以让有经验的管理员提高引人注目的系统性能。用sysctl可以读取设置超过五百个系统变量。基于这点，sysctl(8)  提供两个功能：读取和修改系统设置。<br />
<span id="more-222"></span><br />
查看所有可读变量：</p>
<p>% sysctl -a</p>
<p>读一个指定的变量，例如  kern.maxproc：</p>
<p>% sysctl kern.maxproc kern.maxproc:  1044</p>
<p>要设置一个指定的变量，直接用 variable=value 这样的语法：</p>
<p># sysctl  kern.maxfiles=5000</p>
<p>kern.maxfiles: 2088 -&gt;  5000</p>
<p>您可以使用sysctl修改系统变量，也可以通过编辑sysctl.conf文件来修改系统变量。sysctl.conf 看起来很像  rc.conf。它用 variable=value  的形式来设定值。指定的值在系统进入多用户模式之后被设定。并不是所有的变量都可以在这个模式下设定。</p>
<p>sysctl  变量的设置通常是字符串、数字或者布尔型。 (布尔型用 1 来表示&#8217;yes&#8217;，用 0 来表示&#8217;no&#8217;)。</p>
<p>sysctl -w  kernel.sysrq=0</p>
<p>sysctl -w kernel.core_uses_pid=1</p>
<p>sysctl -w  net.ipv4.conf.default.accept_redirects=0</p>
<p>sysctl -w  net.ipv4.conf.default.accept_source_route=0</p>
<p>sysctl -w  net.ipv4.conf.default.rp_filter=1</p>
<p>sysctl -w  net.ipv4.tcp_syncookies=1</p>
<p>sysctl -w  net.ipv4.tcp_max_syn_backlog=2048</p>
<p>sysctl -w  net.ipv4.tcp_fin_timeout=30</p>
<p>sysctl -w  net.ipv4.tcp_synack_retries=2</p>
<p>sysctl -w  net.ipv4.tcp_keepalive_time=3600</p>
<p>sysctl -w  net.ipv4.tcp_window_scaling=1</p>
<p>sysctl -w  net.ipv4.tcp_sack=1</p>
<p>配置sysctl</p>
<p>编辑此文件：</p>
<p>vi  /etc/sysctl.conf</p>
<p>如果该文件为空，则输入以下内容，否则请根据情况自己做调整：</p>
<p># Controls source  route verification</p>
<p># Default should work for all  interfaces</p>
<p>net.ipv4.conf.default.rp_filter = 1</p>
<p>#  net.ipv4.conf.all.rp_filter = 1</p>
<p># net.ipv4.conf.lo.rp_filter = 1</p>
<p>#  net.ipv4.conf.eth0.rp_filter = 1</p>
<p># Disables IP source routing</p>
<p>#  Default should work for all  interfaces</p>
<p>net.ipv4.conf.default.accept_source_route = 0</p>
<p>#  net.ipv4.conf.all.accept_source_route = 0</p>
<p>#  net.ipv4.conf.lo.accept_source_route = 0</p>
<p>#  net.ipv4.conf.eth0.accept_source_route = 0</p>
<p># Controls the System Request  debugging functionality of the kernel</p>
<p>kernel.sysrq = 0</p>
<p># Controls  whether core dumps will append the PID to the core filename.</p>
<p># Useful for  debugging multi-threaded applications.</p>
<p>kernel.core_uses_pid = 1</p>
<p>#  Increase maximum amount of memory allocated to shm</p>
<p># Only uncomment if  needed!</p>
<p># kernel.shmmax = 67108864</p>
<p># Disable ICMP Redirect  Acceptance</p>
<p># Default should work for all  interfaces</p>
<p>net.ipv4.conf.default.accept_redirects = 0</p>
<p>#  net.ipv4.conf.all.accept_redirects = 0</p>
<p>#  net.ipv4.conf.lo.accept_redirects = 0</p>
<p>#  net.ipv4.conf.eth0.accept_redirects = 0</p>
<p># Enable Log Spoofed Packets,  Source Routed Packets, Redirect Packets</p>
<p># Default should work for all  interfaces</p>
<p>net.ipv4.conf.default.log_martians = 1</p>
<p>#  net.ipv4.conf.all.log_martians = 1</p>
<p># net.ipv4.conf.lo.log_martians =  1</p>
<p># net.ipv4.conf.eth0.log_martians = 1</p>
<p># Decrease the time  default value for tcp_fin_timeout connection</p>
<p>net.ipv4.tcp_fin_timeout =  25</p>
<p># Decrease the time default value for tcp_keepalive_time  connection</p>
<p>net.ipv4.tcp_keepalive_time = 1200</p>
<p># Turn on the  tcp_window_scaling</p>
<p>net.ipv4.tcp_window_scaling = 1</p>
<p># Turn on the  tcp_sack</p>
<p>net.ipv4.tcp_sack = 1</p>
<p># tcp_fack should be on because of  sack</p>
<p>net.ipv4.tcp_fack = 1</p>
<p># Turn on the  tcp_timestamps</p>
<p>net.ipv4.tcp_timestamps = 1</p>
<p># Enable TCP SYN Cookie  Protection</p>
<p>net.ipv4.tcp_syncookies = 1</p>
<p># Enable ignoring  broadcasts request</p>
<p>net.ipv4.icmp_echo_ignore_broadcasts = 1</p>
<p>#  Enable bad error message  Protection</p>
<p>net.ipv4.icmp_ignore_bogus_error_responses = 1</p>
<p># Make  more local ports available</p>
<p># net.ipv4.ip_local_port_range = 1024  65000</p>
<p># Set TCP Re-Ordering value in kernel to  ‘5′</p>
<p>net.ipv4.tcp_reordering = 5</p>
<p># Lower syn retry  rates</p>
<p>net.ipv4.tcp_synack_retries = 2</p>
<p>net.ipv4.tcp_syn_retries =  3</p>
<p># Set Max SYN Backlog to ‘2048′</p>
<p>net.ipv4.tcp_max_syn_backlog =  2048</p>
<p># Various Settings</p>
<p>net.core.netdev_max_backlog =  1024</p>
<p># Increase the maximum number of skb-heads to be  cached</p>
<p>net.core.hot_list_length = 256</p>
<p># Increase the tcp-time-wait  buckets pool size</p>
<p>net.ipv4.tcp_max_tw_buckets = 360000</p>
<p># This will  increase the amount of memory available for socket input/output  queues</p>
<p>net.core.rmem_default = 65535</p>
<p>net.core.rmem_max =  8388608</p>
<p>net.ipv4.tcp_rmem = 4096 87380  8388608</p>
<p>net.core.wmem_default = 65535</p>
<p>net.core.wmem_max =  8388608</p>
<p>net.ipv4.tcp_wmem = 4096 65535 8388608</p>
<p>net.ipv4.tcp_mem =  8388608 8388608 8388608</p>
<p>net.core.optmem_max = 40960</p>
<p>如果希望屏蔽别人 ping  你的主机，则加入以下代码：</p>
<p># Disable ping  requests</p>
<p>net.ipv4.icmp_echo_ignore_all =  1</p>
<p>编辑完成后，请执行以下命令使变动立即生效：</p>
<p>/sbin/sysctl -p</p>
<p>/sbin/sysctl -w  net.ipv4.route.flush=1</p>
<h2  class="related_post_title">其他大家爱看的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/magiclinux-21-zheng-shi-ban-fa-bu-tong-gao.html" title="MagicLinux 2.1 正式版发布通告">MagicLinux 2.1 正式版发布通告</a></li><li><a href="http://www.linuxbyte.org/linux-ide.html" title="两个 Linux 下的IDE">两个 Linux 下的IDE</a></li><li><a href="http://www.linuxbyte.org/vimperator-rang-ni-de-firefoxbian-cheng-vim.html" title="Vimperator-让你的Firefox变成Vim	">Vimperator-让你的Firefox变成Vim	</a></li><li><a href="http://www.linuxbyte.org/unixshellbian-cheng-di-san-ban.html" title="Unix.Shell编程(第三版)">Unix.Shell编程(第三版)</a></li><li><a href="http://www.linuxbyte.org/magiclinux-2-5-sp4-cd-xiu-zheng-fa-bu.html" title=" MagicLinux 2.5 SP4 CD 修正发布"> MagicLinux 2.5 SP4 CD 修正发布</a></li><li><a href="http://www.linuxbyte.org/2010-linuxquestionskai-yuan-ruan-jian-huo-jiang-ming-dan.html" title="2010  LinuxQuestions开源软件获奖名单">2010  LinuxQuestions开源软件获奖名单</a></li><li><a href="http://www.linuxbyte.org/refcontrol-tu-po-wai-lian-xian-zhi-li-qi.html" title="Refcontrol-突破外链限制利器">Refcontrol-突破外链限制利器</a></li><li><a href="http://www.linuxbyte.org/linux-kernel-map.html" title="linux 内核代码构架图 ">linux 内核代码构架图 </a></li><li><a href="http://www.linuxbyte.org/shi-yong-sshfs-diao-yong-ssh-fu-wu-qi-shang-de-nei-rong.html" title="使用 sshfs 调用 ssh 服务器上的内容">使用 sshfs 调用 ssh 服务器上的内容</a></li><li><a href="http://www.linuxbyte.org/qq-4-linux-2.html" title="QQ for Linux 2.0预计会在国庆前发布">QQ for Linux 2.0预计会在国庆前发布</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2008<br />
Source: <a href="http://www.linuxbyte.org/sysctl-minihowto.html">用Sysctl 调整Linux操作系统的性能</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/sysctl" rel="tag">Sysctl</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/sysctl" title="Sysctl" rel="tag">Sysctl</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/sysctl-minihowto.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux内核引导参数简介</title>
		<link>http://www.linuxbyte.org/kernel_arguments.html</link>
		<comments>http://www.linuxbyte.org/kernel_arguments.html#comments</comments>
		<pubDate>Tue, 22 Jul 2008 03:39:29 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[精品文档]]></category>
		<category><![CDATA[kernel]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=182</guid>
		<description><![CDATA[作者：金步国 概述 内核引导参数大体上可以分为两类：一类与设备无关、另一类与设备有关。内核源码树下的 Documentation/kernel-parameters.txt 文件列出了所有可用的引导参数，并指明了处理每个... ]]></description>
			<content:encoded><![CDATA[<h2>作者：<strong><a href="http://lamp.linux.gov.cn/jinbuguo_florilegium.html">金步国</a></strong></h2>
<h2>概述</h2>
<p>内核引导参数大体上可以分为两类：一类与设备无关、另一类与设备有关。内核源码树下的 Documentation/kernel-parameters.txt 文件列出了所有可用的引导参数，并指明了处理每个参数的具体文件。注意：对于模块而言，引导参数只能用于直接编译到核心里的模块，格式是使用”模块名.参 数=值”模式指定，比如：usbcore.blinkenlights=1 。动态加载的模块可以在 modprobe 命令行上指定相应的参数值，比如：modprobe usbcore blinkenlights=1 。<span id="more-182"></span></p>
<p>可以使用”modinfo -p ${modulename}”命令显示可加载模块的所有可用参数。已经加载到内核中的模块会在 /sys/module/${modulename}/parameters/ 中显示出其参数，并且某些参数的值还可以在运行时通过”echo -n ${value} &gt; /sys/module/${modulename}/parameters/${parm}”命令修改。</p>
<p>与设备有关的引导参数多如牛毛，需要你自己阅读内核中的相应驱动程序源码以获取其能够接受的引导参数。比如，如果你想知道可以向 AHA1542 SCSI 驱动程序传递哪些引导参数，那么就到 drivers/scsi 目录下寻找到 aha1542.c 文件，一般在前面 100 行注释里就可以找到所接受的引导参数说明。大多数参数是通过”__setup(&#8230; , &#8230;)”函数设置的，逗号前的部分就是引导参数的名称，后面的部分就是处理这些参数的函数名。[提示]你可以在源码树的根目录下试一试</p>
<pre>grep -r '\b__setup *(' *</pre>
<p>命令。</p>
<p>[注意]多个参数之间用空格分割，而每个参数的值中不能包含空白，参数值是一个逗号分割的列表。</p>
<pre>正确：ether=9,0x300,0xd0000,0xd4000,eth0  root=/dev/hda1
错误：ether = 9, 0x300, 0xd0000, 0xd4000, eth0  root = /dev/hda1</pre>
<p>在内核运行起来之后，可以通过 cat /proc/cmdline 命令查看当初使用的引导参数以及相应的值。</p>
<p>所有引导参数都是大小写敏感的！</p>
<h2>内核如何处理引导参数</h2>
<p>绝大部分的内核引导参数的格式如下(每个参数的值列表中最多只能有十项)：</p>
<pre>name[=value_1][,value_2]...[,value_10]</pre>
<p>如果”name”不能被识别并且满足”name=value”的格式，那么则被解译为一个环境变量(比如”TERM=linux”或”BOOT_IMAGE=vmlinuz.bak”)，否则将被原封不动的传递给 init 程序(比如”single”)。</p>
<p>内核可以接受的参数个数没有限制，但是整个命令行的总长度(参数/值/空格全部包含在内)却是有限制的，一般是 256-4096 之间，定义在 include/asm/setup.h 中的 COMMAND_LINE_SIZE 宏中。</p>
<h2>内核引导参数精选</h2>
<p>由于引导参数多如牛毛，本文不可能涉及全部，因此下面只列出精选出来的一些(基于 2.6.22 内核)，与设备有关的基本上都被忽略了。</p>
<h3>标记说明</h3>
<p>并不是所有的参数都是永远可用的，只有在特定的模块存在并且相应的硬件也存在的情况下才可用。引导参数上面的方括号说明了其依赖关系，其中使用的标记解释如下：</p>
<pre style="BACKGROUND: #eeddcc; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial">ACPI    高级配置与电源接口
APIC    高级可编程中断控制器
HW      相应的硬件设备存在
IA-32   IA-32(i386)体系结构
X86-64  X86-64体系结构，更多参数在 Documentation/x86_64/boot-options.txt 中描述
IOSCHED 启用了多个IO调度器
LIBATA  启用了Libata驱动
LOOP    启用了Loopback设备
NET     启用了网络支持
PCI     PCI总线支持
PNP     即插即用支持
PS2     PS/2支持
SCSI    许多SCSI设备的参数在 Documentation/scsi/ 中描述
SMP     对称多处理器
USB     USB支持
USBHID  USB人机界面设备
VT      虚拟终端(Virtual terminal)</pre>
<p>此外，下面的标记的含义与在逻辑上与上面的有所不同：</p>
<pre style="BACKGROUND: #eeddcc; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial">BUGS= 用于在特定的体系结构上解决某些CPU的bug
KNL     是一个内核启动参数
BOOT 是一个引导程序参数</pre>
<p>标记为”BOOT”的参数实际上由引导程序使用，对内核本身没有直接的意义。没有特别的需求，请不要修改此类参数的语法，更多信息请阅读 Documentation/i386/boot.txt 文档。</p>
<h3>控制台</h3>
<p>这些参数控制着控制台或内核日志，在何处显示内核调试信息和错误信息。</p>
<dl>
<dt>[KNL]<br />
console=tty&lt;N&gt; </dt>
<dd>设置输出控制台使用第N号虚拟控制台。 </dd>
<dt>[IA-32,X86-64]<br />
earlyprintk=vga </dt>
<dd>在传统的控制台初始化之前，在VGA上显示内核日志信息。如果不使用此参数那么这些信息你可用永远没机会看见。 </dd>
<dt>loglevel={0|1|2|3|4|5|6|7} </dt>
<dd>所有小于该数字的内核信息都将在控制台上显示出来。这个级别可以使用 klogd 程序或者修改 /proc/sys/kernel/printk 文件进行调整。取值范围是”0&#8243;(不显示任何信息)到”7&#8243;(显示所有级别的信息)。建议至少设为”4&#8243;。[提示]级别”7&#8243;要求编译时加入了调试支持。 </dd>
<dt>[KNL]<br />
initcall_debug </dt>
<dd>跟踪所有内核初始化过程中调用的函数。有助于诊断内核在启动过程中死在了那个函数上面。</dd>
</dl>
<h3>中断</h3>
<p>这些参数影响内核与处理中断的硬件之间的接口。常见的中断控制器有两种：传统的8259A和新式的APIC，前者也被称为”PIC”。8259A只 适合单CPU的场合，而APIC则能够把中断传递给系统中的每个CPU，从而充分挖掘SMP体系结构的并行性。所以8259A已经被淘汰了。</p>
<p>APIC系统由3部分组成：APIC总线、IO-APIC、本地APIC。</p>
<p>每个CPU中集成了一个本地APIC，负责传递中断信号到处理器。而IO-APIC是系统芯片组中一部分，负责收集来自I/O设备的中断信号并发送到本地APIC。APIC总线则是连接IO-APIC和各个本地APIC的桥梁。</p>
<dl>
<dt>[APIC,i386]<br />
apic={quiet|verbose|debug} </dt>
<dd>在初始化 APIC 和 IO-APIC 组件的时候，显示调试信息的详细程度。默认是”quiet”。 </dd>
<dt>[SMP,APIC]<br />
noapic </dt>
<dd>强制内核禁止使用IO-APIC(输入输出高级可编程输入控制器) </dd>
<dt>[IA-32,APIC]<br />
lapic </dt>
<dd>强制内核启用 local APIC ，即使 BIOS 已经禁用了。 </dd>
<dt>[IA-32,APIC]<br />
nolapic </dt>
<dd>强制内核禁用 local APIC ，即使 BIOS 已经启用了。 </dd>
<dt>[IA-32,SMP,KNL]<br />
noirqbalance </dt>
<dd>禁止使用内核中的中断平衡逻辑 </dd>
<dt>[HW]<br />
irqfixup </dt>
<dd>用于修复基本的中断问题：当一个中断没有被处理时搜索所有可用的中断处理器。用于解决某些firmware缺陷。 </dd>
<dt>[HW]<br />
irqpoll </dt>
<dd>用于修复更进一步的中断问题：当一个中断没有被处理时搜索所有可用的中断处理器，并且对每个时钟中断都进行搜索。用于解决某些严重的firmware缺陷。 </dd>
<dt>[IA-32]<br />
noirqdebug </dt>
<dd>默认情况下，内核将探测并且禁止未处理的中断源，以免引起内核其他部分的响应问题，这个选项禁止该功能。</dd>
</dl>
<h3>内存</h3>
<dl>
<dt>[KNL,BOOT]<br />
highmem=nn[KMG] </dt>
<dd>强制指定highmem区域的大小，甚至在默认没有 highmem的机器上也能工作。这个选项还可以用来在大内存的机器上强制减少highmem区域的大小。内核使用低于896M的”直接映射物理内存”很 方便，但使用大于896M的部分(highmem)却比较麻烦，所以系统在给用户进程分配内存时会优先使用highmem。对于小于等于 1G 内存的用户来说，则无需关心这个问题。 </dd>
<dt>[HW,IA-32]<br />
hugepages=&lt;NUM&gt; </dt>
<dd>指定 HugeTLB 页的最大数量，仅在内核启用了CONFIG_HUGETLBFS之后才有效。大多数现代计算机体系结构提供对多页面大小的支持，比如IA-32结构支持 4K和4M(PAE模式为2M)两种页面。因此Linux将物理内存划分成许多固定大小的页面(默认大小为 4k)，每个页对应一个page结构，这些结构组成一个mem_map[]数组。TLB(Translation Lookaside Buffer)是虚拟地址到物理地址的翻译缓冲区，这种缓冲区在处理器上是很宝贵的，操作系统总是尝试将有限的TLB资源发挥到极致。特别是能够轻松获得 若干G内存的时候(&gt;4G)，这种优化就显得尤为关键。而 HugeTLB 特性则允许将某些页的尺寸增大到 4MB 。用户可以使用mmap系统调用或者标准的SYSv共享内存调用(shmget,shmat)来使用hugepage。可以使用 grep Huge /proc/meminfo 命令查看是否开启了 hugepage 支持。 </dd>
<dt>[KNL]<br />
ihash_entries=&lt;NUM&gt; </dt>
<dd>内核会在内存中缓存一定数量的inode结构来加速文 件访问，每个inode对应一个文件(不同于文件系统中的inode概念)，包含文件访问权限/属主/组/大小/生成时间/访问时间/最后修改时间等信 息。这些inode保存在一个哈希表中。这个值用于指定这个哈希表的最大项数。比如 1G 内存推荐为 16384 ，4G 及以上内存推荐 131072 ，但你可以根据自己硬盘上可能被访问的文件数量对默认值进行调整(注意需要考虑哈希值的碰撞)。 </dd>
<dt>[KNL,BOOT]<br />
max_addr=nn[KMG] </dt>
<dd>内核将忽略在该物理地址以上的内存 </dd>
<dt>[KNL,BOOT]<br />
mem=nn[KMG] </dt>
<dd>强制指定内核使用多少数量的内存。缺乏远见设计的传统BIOS只能报告最 大64MB内存。新的e820规范则突破了这个限制，使得BIOS可以正确报告大于64MB的内存。如果你在老旧的机器上使用大内存就需要指定这个参数 (最保险的做法是在实际内存的总数上减掉1MB)。但有时候e820报告的数量并不准确，此时就需要使用下面的memmap参数精确指定内存映射(此时就 不要使用”mem=”了)。 </dd>
<dt>[KNL,IA-32,X86_64]<br />
memmap=exactmap </dt>
<dd>指定将要使用随后的”memmap=nn@ss”等参数进行精确的E820内存映射。比如对于一个4G内存的机器可能是：”memmap=exactmap memmap=640K@0 memmap=4095M@1M”。 </dd>
<dt>[KNL]<br />
memmap=nn[KMG]@ss[KMG] </dt>
<dd>强制内核只使用从ss开始的nn长度的特定内存区域。可以多次使用以指定多个区域。 </dd>
<dt>[IA-32,X86-64]<br />
noexec={on|off} </dt>
<dd>允许(on,默认)或禁止(off)内核将部分内存映射为”不可执行”区域。 </dd>
<dt>[KNL,BUGS]<br />
reserve=nn[KMG] </dt>
<dd>强制内核忽略(预留)一定量的IO内存区域 </dd>
<dt>[KNL,BOOT]<br />
vmalloc=nn[KMG] </dt>
<dd>强制指定vmalloc区域的大小。可用于增加vmalloc区域的最小尺寸(x86默认128MB)，也可以用于减少vmalloc的大小，增加更多的空间用于直接映射内核RAM。 </dd>
<dt>norandmaps </dt>
<dd>默认内核随机化程序启动的地址，该选项禁用该功能。该选项等价于”echo 0 &gt; /proc/sys/kernel/randomize_va_space”命令。</dd>
</dl>
<h3>CPU</h3>
<dl>
<dt>[BUGS=IA-32]<br />
cachesize=&lt;NUM&gt; </dt>
<dd>强制指定 CPU L2 cache 的大小，单位是字节。 </dd>
<dt>[KNL,BUGS=IA-32]<br />
nmi_watchdog={0|1|2|3} </dt>
<dd>设置非屏蔽中断(NMI)watchdog的特性。”0&#8243;表示禁用NMI watchdog；”1&#8243;表示使用APIC；”2&#8243;表示使用local APIC；”3&#8243;表示NMI watchdog有缺陷，因此被禁用。 </dd>
<dt>[IA-32]<br />
mce<br />
nomce </dt>
<dd>启用/禁用Machine Check Exception功能。 </dd>
<dt>[SMP]<br />
maxcpus=&lt;NUM&gt; </dt>
<dd>明确指定一个SMP内核能够使用的最大CPU数量。最好使用”maxcpus=0&#8243;而不是”maxcpus=1&#8243;来禁用SMP功能。</dd>
</dl>
<h3>Ramdisk</h3>
<dl>
<dt>[BOOT]<br />
initrd=&lt;filename&gt; </dt>
<dd>指定initial ramdisk的位置 </dd>
<dt>[RAM]<br />
noinitrd </dt>
<dd>禁止使用任何initial RAM disk </dd>
<dt>[RAM]<br />
ramdisk_blocksize=&lt;NUM&gt; </dt>
<dd>指定ramdisk的块尺寸，默认是”1024&#8243;。 </dd>
<dt>[RAM]<br />
ramdisk_size=&lt;NUM&gt; </dt>
<dd>RAM disks的大小(kB)，默认为4096(4MB)。</dd>
</dl>
<h3>根文件系统</h3>
<dl>
<dt>[KNL]<br />
root=XXxx </dt>
<dd>告诉核心启动时以那个设备作为根文件系统使用，默认为编译内核时使用的设备。设备名由16进制主设备号(XX)与16进制次设备号(xx)组成，比如：root=B401 相当于从 /dev/uba1 启动；root=0801 相当于从 /dev/sda1 启动。 </dd>
<dt>[KNL]<br />
rootdelay=&lt;NUM&gt; </dt>
<dd>挂载文件系统前延迟多少秒，当根文件系统在USB或FireWire设备上时常用。 </dd>
<dt>[KNL]<br />
rootflags= </dt>
<dd>设置根文件系统的挂载选项，比如”noatime,ro”。各种不同的文件系统所能使用的选项各不相同(比如 Documentation/filesystems/xfs.txt)，也可以参考 mount 程序的选项。 </dd>
<dt>[KNL]<br />
rootfstype= </dt>
<dd>根文件系统的类型，比如”xfs”。</dd>
</dl>
<h3>init</h3>
<dl>
<dt>[KNL]<br />
init=&lt;full_path&gt; </dt>
<dd>指定内核启动后运行的第一个程序的绝对路径。默认为”/sbin/init”。 </dd>
<dt>[KNL]<br />
rdinit=&lt;full_path&gt; </dt>
<dd>从ramdisk中运行的第一个程序的绝对路径，默认为”/init”。指定的文件必须是在ramdisk而不是在根文件系统中进行。 </dd>
<dt>[KNL]<br />
S </dt>
<dd>以单用户模式运行init，默认是多用户模式。</dd>
</dl>
<h3>ACPI</h3>
<dl>
<dt>[HW,ACPI,X86-64,i386]<br />
acpi={force|off|ht|strict|noirq} </dt>
<dd>ACPI的总开关。force表示强制启用；off表示强制禁用；noirq表示不要将ACPI用于IRQ路由；ht表示只运行足够的ACPI来支持超线程；strict表示降低对不严格遵循ACPI规格的平台的兼容性。 </dd>
<dt>acpi_sleep={s3_bios,s3_mode} </dt>
<dd>ACPI休眠选项。在从S3状态(挂起到内存)恢复的时候，硬件需 要被正确的初始化。这对大多数硬件都不成问题，除了显卡之外，因为显卡是由BIOS初始化的，内核无法获取必要的恢复信息(仅存在于BIOS中，内核无法 读取)。这个选项允许内核以两种方式尝试使用ACPI子系统来恢复显卡的状态。 </dd>
<dt>[HW,ACPI]<br />
acpi_sci={level|edge|high|low} </dt>
<dd>ACPI系统控制终端触发器模式(System Control Interrupt trigger mode)。 </dd>
<dt>[HW,ACPI]<br />
acpi_irq_balance </dt>
<dd>使ACPI对中断请求进行平衡，在APIC模式下为默认值 </dd>
<dt>[HW,ACPI]<br />
acpi_irq_nobalance </dt>
<dd>ACPI不对中断请求进行平衡(默认)，PIC模式下为默认值 </dd>
<dt>[HW,ACPI]<br />
acpi_irq_pci=&lt;irq&gt;,&lt;irq&gt;&#8230; </dt>
<dd>如果启用了irq_balance则将列出的中断号标记为已经被PCI子系统使用，可用于屏蔽某些中断。 </dd>
<dt>[HW,ACPI]<br />
acpi_os_name= </dt>
<dd>告诉ACPI BIOS操作系统的名称。常常用来哄骗某些老旧的BIOS以为运行的是Windows系统。比如”Microsoft 2001&#8243;表示WinXP，”Microsoft Windows”表示Win98。 </dd>
<dt>[HW,ACPI]<br />
acpi_serialize </dt>
<dd>强制串行化ACPI机器语言(ACPI Machine Language)方法，操作系统使用这种语言与BIOS打交道。 </dd>
<dt>[HW,ACPI]<br />
acpi_use_timer_override </dt>
<dd>对于某些有毛病的 Nvidia NF5 主板需要使用此选项才能正常使用，不过此时 HPET 将失效。 </dd>
<dt>[IA-32,X86-64]<br />
acpi_pm_good </dt>
<dd>跳过pmtimer的bug检测，强制内核假设这台机器的pmtimer没有毛病。用于解决某些有缺陷的BIOS。 </dd>
<dt>[KNL,ACPI]<br />
memmap=nn[KMG]#ss[KMG] </dt>
<dd>将从ss开始的nn长度的内存区域标记为ACPI数据。 </dd>
<dt>[KNL,ACPI]<br />
memmap=nn[KMG]$ss[KMG] </dt>
<dd>将从ss开始的nn长度的内存区域标记为”保留”。 </dd>
<dt>[ACPI]<br />
pnpacpi=off </dt>
<dd>禁用ACPI的即插即用功能，而使用PNPBIOS来代替。 </dd>
<dt>[HW,ACPI]<br />
processor.max_cstate={0|1|2|3|4|5|6|7|8|9} </dt>
<dd>无视 ACPI表报告的值，强制制定CPU的最大C-state值。这里的数字必须是一个有效的C-state值，比如Yonah处理器支持”0-4&#8243;五个级 别：C0为正常状态，其他则为不同的省电模式(数字越大表示CPU休眠的程度越深/越省电)。”9&#8243;表示超越所有的DMI黑名单限制。你的CPU的95% 的时间应该处于最深度的idle状态。 </dd>
<dt>processor.nocst </dt>
<dd>不使用_CST方法来侦测C-state值，而是使用传统的FADT方法。</dd>
</dl>
<h3>SCSI</h3>
<p>这里只列出了SCSI子系统的通用参数。其他特定于某一种SCSI驱动的参数并未列出，请在 Documentation 目录下的 kernel-parameters.txt 文件中和 scsi 目录下寻找它们。</p>
<dl>
<dt>[SCSI]<br />
max_luns= </dt>
<dd>限制SCSI的最大逻辑单元号(LUN,logical unit number)。取值范围在1到2^32-1之间。 </dd>
<dt>[SCSI]<br />
max_report_luns= </dt>
<dd>限制系统能够接受的最大逻辑单元号(LUN)。取值范围在1到16384之间。</dd>
</dl>
<h3>PCI</h3>
<dl>
<dt>[PCI]<br />
pci=option[,option...] </dt>
<dd>
<dl>
<dt>off </dt>
<dd>[IA-32]不检测PCI总线，也就是关闭所有PCI设备。 </dd>
<dt>bios </dt>
<dd>[IA-32]强制使用PCI BIOS而不是直接访问硬件，这表示内核完全信任BIOS(大多数情况下它并不可信)。仅在你的机器有一个不标准的PCI host bridge的时候才用。 </dd>
<dt>nobios </dt>
<dd>[IA-32]强制直接访问硬件而不使用PCI BIOS，2.6.13之后这是默认值。如果你确定在内核引导时的崩溃是由BIOS所致就可以使用它。 </dd>
<dt>conf1 </dt>
<dd>[IA-32]强制硬件设备使用PCI Configuration Mechanism 1访问PCI Memory以与内核中的驱动程序进行通信。 </dd>
<dt>conf2 </dt>
<dd>[IA-32]强制硬件设备使用PCI Configuration Mechanism 2访问PCI Memory以与内核中的驱动程序进行通信。 </dd>
<dt>nommconf </dt>
<dd>[IA-32,X86_64]禁止为 PCI Configuration 使用 MMCONFIG 表。 </dd>
<dt>nomsi </dt>
<dd>[MSI]如果启用了PCI_MSI内核配置选项，那么可以使用这个参数在系统范围内禁用MSI中断。 </dd>
<dt>nosort </dt>
<dd>[IA-32]不在检测阶段根据PCI BIOS给出的顺序对PCI设备进行排序。进行这样的排序是为了以与早期内核兼容的方式获取设备序号。 </dd>
<dt>biosirq </dt>
<dd>[IA-32]使用PCI BIOS调用来获取中断路由表。这些调用在不少机器上都有缺陷，会导致系统在使用过程中挂起。但是在某些机器上却是唯一获取中断路由表的手段。如果内核无法分配IRQ或者发现了第二个PCI总线，就可以尝试使用这个选项解决问题。 </dd>
<dt>rom </dt>
<dd>[IA-32]为扩展ROM分配地址空间。使用此选项要小心，因为某些设备在ROM与其它资源之间共享地址解码器。 </dd>
<dt>pirqaddr=0xAAAAA </dt>
<dd>[IA-32]指定物理地址位于F0000h-100000h范围之外的PIRQ表(通常由BIOS产生)的物理地址。 </dd>
<dt>lastbus=N </dt>
<dd>[IA-32]扫描所有总线，直到第N个总线。如果内核找不到第二条总线的时候，你就需要使用这个选项明确告诉它。 </dd>
<dt>assign-busses </dt>
<dd>[IA-32]总是使用你自己指定的PCI总线号(而不是firmware提供的)。 </dd>
<dt>usepirqmask </dt>
<dd>[IA-32]优先使用可能存在于BIOS $PIR表中的IRQ掩码。某些有缺陷的BIOS需要这个选项，特别是在HP Pavilion N5400和Omnibook XE3笔记本上。如果启用了ACPI IRQ路由的话，将不会考虑这个选项的设置。 </dd>
<dt>noacpi </dt>
<dd>[IA-32]不为IRQ路由或者PCI扫描使用ACPI。 </dd>
<dt>routeirq </dt>
<dd>为所有PCI设备执行IRQ路由。这个通常在pci_enable_device()中执行，所有这是一个解决不调用此函数的bug驱动程序的临时解决方法。 </dd>
<dt>bfsort </dt>
<dd>按照宽度优先的顺序对PCI设备进行排序。进行这样的排序是为了以与2.4内核兼容的方式获取设备序号。 </dd>
<dt>nobfsort </dt>
<dd>不按照宽度优先的顺序对PCI设备进行排序。 </dd>
<dt>cbiosize=nn[KMG] </dt>
<dd>从CardBus bridge 的 IO 窗口接受的固定长度的总线空间(bus space)，默认值是256字节。 </dd>
<dt>cbmemsize=nn[KMG] </dt>
<dd>从CardBus bridge 的 memory 窗口接受的固定长度的总线空间(bus space)，默认值是64MB。</dd>
</dl>
</dd>
</dl>
<h3>网络</h3>
<dl>
<dt>[NET]<br />
netdev=&lt;irq&gt;,&lt;io&gt;,&lt;mem_start&gt;,&lt;mem_end&gt;,&lt;name&gt; </dt>
<dd>网络设备参数。具体细节取决于不同的驱动程序，请参考各自的驱动程序文档。该选项通常不用于PCI/USB等即插即用网卡。 </dd>
<dt>[KNL,NET]<br />
rhash_entries= </dt>
<dd>设置内核路由缓冲区哈希表的大小，仅供内核网络专家使用。 </dd>
<dt>[NET]<br />
shapers= </dt>
<dd>设置内核允许使用的最大网络Shaper(限制网络速率的虚拟网络设备)。 </dd>
<dt>[KNL,NET]<br />
thash_entries= </dt>
<dd>设置内核允许使用的TCP链接哈希表的大小。</dd>
</dl>
<h3>硬件</h3>
<dl>
<dt>[USB]<br />
nousb </dt>
<dd>禁用USB子系统。</dd>
</dl>
<h3>定时器</h3>
<dl>
<dt>[i386,x86-64]<br />
enable_timer_pin_1<br />
disable_timer_pin_1 </dt>
<dd>启用/禁用APIC定时器的PIN1，可以用于解决某些有bug的芯片组(特别是ATI芯片组)。内核将尽可能自动探测正确的值。 </dd>
<dt>[IA32/X86_64]<br />
enable_8254_timer<br />
disable_8254_timer </dt>
<dd>启用/禁用 在通过IO-APIC对IRQ0(时钟中断)进行路由之外，还通过8254进行路由。内核将尽可能通过检测来选择正确的值。 </dd>
<dt>[IA-32,HPET]<br />
hpet=disable </dt>
<dd>禁用HPET，转而使用PIT。 </dd>
<dt>[GENERIC_TIME,IA-32,X86-64,ACPI]<br />
clocksource={hpet|pit|tsc|acpi_pm} </dt>
<dd>强制指定clocksource来取代默认值。</dd>
</dl>
<h3>其他杂项</h3>
<dl>
<dt>[VT]<br />
default_utf8={0|1} </dt>
<dd>在系统范围内为将所有tty默认设置为UTF-8模式。”1&#8243;表示UTF-8模式，默认值为”0&#8243;。 </dd>
<dt>[IOSCHED]<br />
elevator={“anticipatory”|”cfq”|”deadline”|”noop”} </dt>
<dd>指定默认IO调度器 </dd>
<dt>[LOOP]<br />
max_loop=&lt;1-256&gt; </dt>
<dd>最大允许挂载的loopback设备数。 </dd>
<dt>[KNL]<br />
panic=&lt;seconds&gt; </dt>
<dd>在内核发生panic之后reboot之前等候的秒数。默认值”0&#8243;表示不重启而停顿在那里。</dd>
</dl>
<h2  class="related_post_title">与本文关系暧昧的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/linux-kernel-wenjian-qubie.html" title="几种linux内核文件的区别">几种linux内核文件的区别</a></li><li><a href="http://www.linuxbyte.org/linux-kernel-map.html" title="linux 内核代码构架图 ">linux 内核代码构架图 </a></li><li><a href="http://www.linuxbyte.org/howto-do-linux-kernel-development.html" title="HOWTO do Linux kernel development ">HOWTO do Linux kernel development </a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2008<br />
Source: <a href="http://www.linuxbyte.org/kernel_arguments.html">Linux内核引导参数简介</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/kernel" rel="tag">kernel</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/kernel" title="kernel" rel="tag">kernel</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/kernel_arguments.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>几种linux内核文件的区别</title>
		<link>http://www.linuxbyte.org/linux-kernel-wenjian-qubie.html</link>
		<comments>http://www.linuxbyte.org/linux-kernel-wenjian-qubie.html#comments</comments>
		<pubDate>Tue, 17 Jun 2008 14:42:01 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[精品文档]]></category>
		<category><![CDATA[kernel]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=164</guid>
		<description><![CDATA[vmlinux  编译出来的最原始的内核文件，未压缩。 zImage   是vmlinux经过gzip压缩后的文件。 bzImage bz表示“big zImage”，不是用bzip2压缩的。两者的不同之处在于，zImage解压缩内核到低端内存(第一... ]]></description>
			<content:encoded><![CDATA[<p><strong>vmlinux  </strong>编译出来的最原始的内核文件，未压缩。<br />
<strong>zImage   </strong>是vmlinux经过gzip压缩后的文件。<br />
<strong>bzImage </strong>bz表示“big zImage”，不是用bzip2压缩的。两者的不同之处在于，zImage解压缩内核到低端内存(第一个640K)，bzImage解压缩内核到高端内存(1M以上)。如果内核比较小，那么采用zImage或bzImage都行，如果比较大应该用bzImage。<span id="more-164"></span><br />
<strong>uImage</strong>   U-boot专用的映像文件，它是在zImage之前加上一个长度为0&#215;40的tag。<br />
<strong>vmlinuz  </strong>是bzImage/zImage文件的拷贝或指向bzImage/zImage的链接。<br />
<strong>initrd   </strong>是“initial ramdisk”的简写。一般被用来临时的引导硬件到实际内核vmlinuz能够接管并继续引导的状态</p>
<h2  class="related_post_title">与本文关系暧昧的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/kernel_arguments.html" title="Linux内核引导参数简介">Linux内核引导参数简介</a></li><li><a href="http://www.linuxbyte.org/linux-kernel-map.html" title="linux 内核代码构架图 ">linux 内核代码构架图 </a></li><li><a href="http://www.linuxbyte.org/howto-do-linux-kernel-development.html" title="HOWTO do Linux kernel development ">HOWTO do Linux kernel development </a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2008<br />
Source: <a href="http://www.linuxbyte.org/linux-kernel-wenjian-qubie.html">几种linux内核文件的区别</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/kernel" rel="tag">kernel</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/kernel" title="kernel" rel="tag">kernel</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/linux-kernel-wenjian-qubie.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>针对Web服务器总体优化</title>
		<link>http://www.linuxbyte.org/zhen-dui-webfu-wu-qi-zong-ti-you-hua.html</link>
		<comments>http://www.linuxbyte.org/zhen-dui-webfu-wu-qi-zong-ti-you-hua.html#comments</comments>
		<pubDate>Sat, 07 Jun 2008 13:08:12 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[服务器应用]]></category>
		<category><![CDATA[精品文档]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[优化]]></category>
		<category><![CDATA[服务器]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=162</guid>
		<description><![CDATA[作者：killua 方法有些比较激进，做个保存方便以后自己查阅。 一、文件系统 在fstab里加入noatime，如 #cat /etc/fstab /dev/sda1          /home                  ext3    noatime,defaults        1 2 r... ]]></description>
			<content:encoded><![CDATA[<p>作者：<span style="font-family: Fixedsys;">killua<br />
<em>方法有些比较激进，做个保存方便以后自己查阅。</em></span><span><a href="http://bbs.chinaunix.net/profile-uid-51562.html" target="_blank"><span style="font-family: Fixedsys;"></span></a></span></p>
<p>一、文件系统<br />
在fstab里加入noatime，如<br />
#cat /etc/fstab<br />
/dev/sda1          /home                  ext3    noatime,defaults        1 2<br />
reboot或者重新mount生效</p>
<p><span id="more-162"></span><br />
二、Tcp优化<br />
在/etc/sysctl.conf里加入<br />
net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_recv = 3<br />
net.ipv4.tcp_syncookies = 1                                #启用syncookies<br />
net.ipv4.tcp_max_syn_backlog = 8192                #定义backlog队列容纳的最大半连接数<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 1800<br />
net.ipv4.tcp_window_scaling = 0<br />
net.ipv4.tcp_sack = 0<br />
net.ipv4.tcp_timestamps = 0<br />
<span style="color: blue;">老实说，对于sysctl.conf究竟能不能用起来还真不知道，因为我是没用起来，虽然内核里面是支持的 = =b</span><br />
三、虚拟内存优化<br />
/etc/sysctl.conf<br />
vm.lower_zone_protection = 100<br />
四、I/O调度器<br />
在grub.conf的相应启动选项里加入elevator=deadline，如：<br />
kernel /vmlinuz-2.6.6 ro root=/dev/sda6 elevator=deadline<br />
这里用了Deadline的I/O调度器,它比系统默认的AnticipatoryI/O调度器更为小巧,在数据吞吐量非常大的数据库系统中表现得更有优势。<br />
五、内核源代码参数修改<br />
修改/usr/src/linux/include/linux/posix_types.h<br />
#define __FD_SETSIZE 1024 � 65536<br />
设置fd_set支持的最大数量</p>
<p>修改/usr/src/linux/include/linux/fs.h<br />
#define INR_OPEN 1024 � 65536<br />
#define NR_FILE 8192 � 65536<br />
#define NR_RESERVED_FILES 10 � 128<br />
设置最大打开文件数量（TCP连接数量）</p>
<p>修改/usr/src/linux/include/net/tcp.h<br />
#define TCP_TIMEWAIT_LEN (60*HZ) � 1*HZ<br />
#define TCP_SYNACK_RETRIES  5 � 3<br />
设置在backlog队列里的半连接的重试次数，每次都会花相应的时间，本质上<br />
也是减少重试时间</p>
<p>make menuconfig中，去掉没用的选项，打开以下选项的开关：<br />
High Memory Support (支持4GB以上内存)<br />
Symmetric multi-processing support (支持多CPU)<br />
TCP syncookie support (可以防DOS)<br />
设置文件打开数等的其他方法(好处就是可以不重新编译内核)<br />
在 /etc/init.d/sshd里加入(统一加在. /etc/rc.d/init.d/functions行后面)</p>
<div class="msgbody">
<div id="code0" class="msgborder" style="padding-left: 30px;">ulimit -n 65535 &gt;;/dev/null 2&gt;;&amp;1<br />
ulimit -u 16384 &gt;;/dev/null 2&gt;;&amp;1</div>
</div>
<p>重起sshd：nohup /etc/init.d/sshd restart &amp;<br />
BTW：其实limits.conf不好，因为他需要root su &#8211; user遗传给普通用户<br />
如果直接远程登陆是没效果的<br />
六、apache<br />
1、安装:采用worker线程工作模式</p>
<div class="msgbody">
<div class="msgheader">
</div>
<div id="code1" class="msgborder" style="padding-left: 30px;">./configure &#8211;prefix=/prefix<br />
&#8211;enable-mods-shared=all<br />
&#8211;enable-deflate<br />
&#8211;with-mpm=worker</div>
</div>
<p><span style="color: blue;">chmod +s /prefix/bin/httpd </span>#允许普通用户也可以启动apache<br />
2、配置：httpd.conf</p>
<div class="msgbody">
<div id="code2" class="msgborder">Timeout 60<br />
KeepAlive On<br />
MaxKeepAliveRequests 150<br />
KeepAliveTimeout   5</p>
<p>StartServers         3<br />
MaxClients         3200   #支持3200个客户端哦<br />
ServerLimit        32<br />
MinSpareThreads     50<br />
MaxSpareThreads     250<br />
ThreadLimit   200<br />
ThreadsPerChild     100<br />
MaxRequestsPerChild 0</p>
<p>#上面的几个参数对机器要求比较高，如果是比较差的机器，每台机1000个连接最多了，你可能要重新设置参数，我的机器是DELL 2850</p>
<p>UseCanonicalName Off<br />
HostnameLookups Off<br />
ServerSignature Off</p></div>
</div>
<h2  class="related_post_title">与本文关系暧昧的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/guan-yu-squid-de-yi-xie-ji-lu.html" title="关于squid的一些记录">关于squid的一些记录</a></li><li><a href="http://www.linuxbyte.org/ubuntu-904-an-zhuang-pei-zhi-you-hua-quan-ji-lu.html" title="ubuntu 9.04 安装配置优化全记录">ubuntu 9.04 安装配置优化全记录</a></li><li><a href="http://www.linuxbyte.org/ubuntu-8_04-software-optimization.html" title="Ubuntu 8.04 下软件设置和优化">Ubuntu 8.04 下软件设置和优化</a></li><li><a href="http://www.linuxbyte.org/ubuntu-804-de-she-zhi-he-you-hua.html" title="ubuntu 8.04 的设置和优化">ubuntu 8.04 的设置和优化</a></li><li><a href="http://www.linuxbyte.org/openoffice-optimization-tips.html" title="使 OpenOffice.org 运行更快的技巧">使 OpenOffice.org 运行更快的技巧</a></li><li><a href="http://www.linuxbyte.org/optimization-mysql-database-under-high-load-server.html" title="linux高负载下彻底优化mysql数据库">linux高负载下彻底优化mysql数据库</a></li><li><a href="http://www.linuxbyte.org/nginx-install.html" title="Nginx 安装">Nginx 安装</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2008<br />
Source: <a href="http://www.linuxbyte.org/zhen-dui-webfu-wu-qi-zong-ti-you-hua.html">针对Web服务器总体优化</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/web" rel="tag">web</a>, <a href="http://www.linuxbyte.org/tag/%e4%bc%98%e5%8c%96" rel="tag">优化</a>, <a href="http://www.linuxbyte.org/tag/%e6%9c%8d%e5%8a%a1%e5%99%a8" rel="tag">服务器</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/web" title="web" rel="tag">web</a>, <a href="http://www.linuxbyte.org/tag/%e4%bc%98%e5%8c%96" title="优化" rel="tag">优化</a>, <a href="http://www.linuxbyte.org/tag/%e6%9c%8d%e5%8a%a1%e5%99%a8" title="服务器" rel="tag">服务器</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/zhen-dui-webfu-wu-qi-zong-ti-you-hua.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sed 总结</title>
		<link>http://www.linuxbyte.org/sed-tips.html</link>
		<comments>http://www.linuxbyte.org/sed-tips.html#comments</comments>
		<pubDate>Tue, 13 May 2008 10:09:05 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[精品文档]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=144</guid>
		<description><![CDATA[作者：zleil ################################################################ #[0]:  基础                                                                                            # ###... ]]></description>
			<content:encoded><![CDATA[<p>作者：zleil<br />
################################################################<br />
#[0]:  基础                                                                                            #<br />
################################################################<br />
**sed执行过程:<br />
   a. 如果已到达文件尾,goto e;否则,用当前行内容替换模式空间的内容(即缓冲区,还有一个缓冲区:后备空间);<br />
   b. 执行命令序列,命令只对模式空间有效;<br />
   c. 当前行号加1<br />
   d. goto a;<br />
   e. 退出<br />
注: 当前行号可由命令N或n更改,当前行号最初为第1行<br />
    执行命令时,如果该命令有地址前缀,那么看*当前行号*是否与地址前缀相符,相符则执行,否则不执行<br />
<span id="more-144"></span><br />
例子:<br />
$sed -e &#8216;p;p;i \<br />
my-inserted-text<br />
p;<br />
a \<br />
my-appended-text<br />
p;&#8217; filename<br />
这个例子中有6条命令:4个p命令,1个i命令,1个a命令;<br />
$sed -e &#8217;2p;3,5p;6~10i \<br />
my-inserted-text<br />
p;<br />
7a \<br />
my-appended-text<br />
/AA/p;&#8217; filename<br />
这个例子类似上个,仅加入了地址前缀<br />
((详情请参考下文))</p>
<p>**常用方法:<br />
命令:<br />
sed &#8216;commands&#8217; targetfile<br />
echo “string” |sed &#8216;commands&#8217;<br />
脚本:<br />
#!/bin/sed -f<br />
command1<br />
command2<br />
&#8230;</p>
<p>**选项:<br />
-V<br />
&#8211;version<br />
          提示版本信息<br />
-h<br />
&#8211;help<br />
          提示帮助信息<br />
-n<br />
&#8211;quite<br />
&#8211;silent<br />
          默认情形,sed在执行完用户提交的命令列表后,会执行p命令,这3个选项能屏蔽这个默认功能<br />
-e<br />
&#8211;exception=script<br />
          增加script命令列表到当前命令列表<br />
-f<br />
&#8211;file=script-file<br />
          增加script-file文件内的命令列表到当前命令列表<br />
初始时,当前命令列表为空;如果没有-e,&#8211;exception,-f,&#8211;file选项,那么命令行的第一个非选项参数被<br />
当作命令列表添加到当前命令列表中</p>
<p>**常见命令:<br />
可带范围地址前缀的命令(11个):<br />
d         删除模式空间的内容,goto c<br />
D         删除模式空间内的第一行,如果模式空间内还有内容,goto b,否则,goto c<br />
p         将模式空间中的内容输出到标准输出<br />
P         将模式空间中的第一行内容输出到标准输出<br />
N         读入下一行,将其*追加*到模式空间尾,当前行号加1,如果没有可读的行了,goto e<br />
n         读入下一行,用它*替换*模式空间内容,当前行好加1,如果没有可读的行了,goto e<br />
h         用模式空间内容*替换*后备空间内容<br />
H         将模式空键内容*追加*到后备空间尾<br />
g/G       同h/H,但方向相反,后备空间-&gt;模式空间<br />
x         交换模式空间和后备空间内容<br />
l         输出模式空间内容到标准输出,以更人性话的方式输出<br />
          例子:<br />
          $echo -ne “AA BBBB\nCCCDDDD\nFDSAFDSA\n”|sed -n &#8216;l&#8217;<br />
          AA BBBB$<br />
          CCCDDDD$<br />
          FDSAFDSA$<br />
{         命令块的开始,以 } 结束<br />
b label   跳转到标签label处,如同c语言的goto语句<br />
t label   从最近一次从标准输入读入一行开始 到 现在,如果执行了替换命令,且替换成功了,<br />
          那么跳转到label处,继续执行;否则执行下一条命令.<br />
          相当于条件跳转<br />
s/regexp/replacement/<br />
          对模式空间内容进行替换,只替换与regexp匹配的部分;<br />
          只对第一次匹配的进行替换<br />
s/regexp/replacement/g<br />
          对模式空间内容          对模式空间内容进行全局替换<br />
y/source/dest/<br />
          逐个字符替换,其中source的长度必须与dest相等<br />
          如:source为ABC,dest为abc,那么模式空间内的所有A字符被换成a,B换成b,C换成c<br />
          以最后一对替换为标准,<br />
          如:source为ABA,dest为abc,那么模式空间内的所有A字符被换成c(而不是a),B换成b<br />
          例子:<br />
          $echo ABCD |sed -n &#8216;y/ABA/abc/;p&#8217;<br />
          cbCD<br />
w file    把模式空间的内容写到file文件内<br />
          sed在它开始执行前,如果在当前命令序列中发现了这条命令,先将文件file清空(如果存在的话;不存在则创建),<br />
          之后所有的写入都是被追加到文件file尾</p>
<p>不带地址前缀的命令(3个):<br />
#comments 注释<br />
: label   设置标签<br />
}         与}匹配</p>
<p>最多能带一个地址的命令(5个):<br />
=         输出当前行号到标准输出<br />
a \<br />
text      执行完所有命令后,输出text到标准输出<br />
i \<br />
text      输出text到标准输出<br />
q         如果没有 -n 选项,则goto e;否则,先输出模式空间内容到标准输出,然后goto e;<br />
r file    file表示一个文件,如果这是最后一条命令,则输出文件file的内容到标准输出,然后goto c;<br />
          否则,goto c;</p>
<p>**地址格式(数字代表行号,从1开始):<br />
例子:<br />
单地址:   1   第一行<br />
          /string/   与string匹配的行<br />
          $   最后一行<br />
范围地址: 单地址,单地址<br />
          例子：<br />
          1,2     或     1~2<br />
          1,$  所有行<br />
多行:     /regexp/      代表与正则表达式regexp匹配的行<br />
          \cregexpc     代表与正则表达式regexp匹配的行,其中c可为任意字符</p>
<p>**带地址前缀的命令:<br />
例子:<br />
1p<br />
1,3p    或     1~3p</p>
<p>################################################################<br />
#[1]:  元字符 * + ? { } ( )  &lt; &gt;                                                                   #<br />
################################################################<br />
* 在当前模式内*前有匹配字符时,表示个数(&gt;=0个);<br />
例子:<br />
$echo &#8216;aaabbbbcdddd&#8217; |sed &#8216;s/\(a*\)/|\1|/&#8217;<br />
|aaa|bbbbcdddd</p>
<p>* 在当前模式内*前无匹配字符时,表示字符&#8217;*';<br />
例子:<br />
$echo &#8216;a*abbbbcdddd&#8217; |sed &#8216;s/a\(*\)/|\1|/&#8217;<br />
|*|abbbbcdddd<br />
$echo &#8216;a*abbbbcdddd&#8217; |sed &#8216;s/*/|z|/&#8217;<br />
a|z|abbbbcdddd</p>
<p>\* 表示字符&#8217;*';<br />
例子:<br />
$echo &#8216;a*abbbbcdddd&#8217; |sed &#8216;s/\(a\*\)/|\1|/&#8217;<br />
|a*|abbbbcdddd</p>
<p>? 表示字符&#8217;?';<br />
例子:<br />
$echo &#8216;a?abbbbcdddd&#8217; |sed &#8216;s/?/|z|/&#8217;<br />
a|z|abbbbcdddd</p>
<p>\? 在当前模式内?前有匹配字符时,表示个数(0或者1个);<br />
例子:<br />
$echo &#8216;aa?bbbbcdddd&#8217; |sed &#8216;s/\(a\?\)/|\1|/&#8217;<br />
|a|a?bbbbcdddd</p>
<p>\? 在当前模式内?前无匹配字符时,表示字符&#8217;?';<br />
例子:<br />
$echo &#8216;aa?bbbbcdddd&#8217; |sed &#8216;s/\(\?\)/|\1|/&#8217;<br />
aa|?|bbbbcdddd</p>
<p>+ \+ 的意义类似 ? \?,只不过表示数字时为&gt;=1个</p>
<p>{ 表示字符&#8217;{&#8216;<br />
} 表示字符&#8217;}&#8217;</p>
<p>\{ \} 用于表示出现次数,出现\{时,必须出现\}.<br />
单个\}出现时,表示字符&#8217;}&#8217;<br />
例子:<br />
$echo &#8216;({(aabbb}d&#8217; |sed &#8216;s/b\{1,\}\}/|z|/&#8217;<br />
({(aa|z|d<br />
成对\{ \}的3种格式: \{1\}   \{1,\}   \{1,9\}, 如上例</p>
<p>( 表示字符&#8217;(&#8216;<br />
) 表示字符&#8217;)&#8217;</p>
<p>\( \) 必须成对出现,表示子模式<br />
例子:<br />
$echo &#8216;a*abbbbcdddd&#8217; |sed &#8216;s/\(a\*\)/|\1|/&#8217;<br />
|a*|abbbbcdddd</p>
<p>\&lt; \&gt; 表示完全匹配一个单词<br />
[zleil@ZLEIL shApp]$ echo “abc” | sed &#8216;/b/s/\&lt;ab\&gt;/AB/g&#8217;<br />
abc<br />
[zleil@ZLEIL shApp]$ echo “ab c” | sed &#8216;/b/s/\&lt;ab\&gt;/AB/g&#8217;<br />
AB c</p>
<p>&lt; &gt; 表示普通字符 &lt; &gt;</p>
<p>**关于label的例子<br />
这有几个关于label的例子，<br />
[zleil@ZLEIL shApp]$ echo “aBBbc” | sed -n &#8216;p;b label;p;:label;p&#8217;;<br />
aBBbc<br />
aBBbc<br />
[zleil@ZLEIL shApp]$ echo “aBBbc” | sed -n &#8216;s/B/k/;t label;p;:label;p&#8217;;<br />
akBbc<br />
[zleil@ZLEIL shApp]$ echo “aBBbc” | sed -n &#8216;s/D/k/;t label;p;:label;p&#8217;;<br />
aBBbc<br />
aBBbc</p>
<h2  class="related_post_title">与本文关系暧昧的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/sed-mini-howto.html" title="Sed学习笔记">Sed学习笔记</a></li><li><a href="http://www.linuxbyte.org/sedsi-wei-dao-tu.html" title="sed思维导图">sed思维导图</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2008<br />
Source: <a href="http://www.linuxbyte.org/sed-tips.html">sed 总结</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/sed" rel="tag">sed</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/sed" title="sed" rel="tag">sed</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/sed-tips.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sed学习笔记</title>
		<link>http://www.linuxbyte.org/sed-mini-howto.html</link>
		<comments>http://www.linuxbyte.org/sed-mini-howto.html#comments</comments>
		<pubDate>Mon, 05 May 2008 01:50:46 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[精品文档]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/sed-mini-howto</guid>
		<description><![CDATA[1. Sed简介 sed 是一种在线编辑器，它一次处理一行内容。处理时，把当前处理的行存储在临时缓冲区中，称为“模式空间”（pattern space），接着用sed命令处理缓冲区中的内容，处理完成后，把... ]]></description>
			<content:encoded><![CDATA[<h2 class="title" style="clear: both">1. Sed简介</h2>
<p>sed 是一种在线编辑器，它一次处理一行内容。处理时，把当前处理的行存储在临时缓冲区中，称为“模式空间”（pattern space），接着用sed命令处理缓冲区中的内容，处理完成后，把缓冲区的内容送往屏幕。接着处理下一行，这样不断重复，直到文件末尾。文件内容并没有 改变，除非你使用重定向存储输出。Sed主要用来自动编辑一个或多个文件；简化对文件的反复操作；编写转换程序等。以下介绍的是Gnu版本的Sed 3.02。</p>
<p><span id="more-128"></span></p>
<h2 class="title" style="clear: both">2. 定址</h2>
<p>可以通过定址来定位你所希望编辑的行，该地址用数字构成，用逗号分隔的两个行数表示以这两行为起止的行的范围（包括行数表示的那两行）。如1，3表示1，2，3行，美元符号($)表示最后一行。范围可以通过数据，正则表达式或者二者结合的方式确定 			。</p>
<p class="sect1" lang="en">&nbsp;</p>
<h2 class="title" style="clear: both">3. Sed命令</h2>
<p>调用sed命令有两种形式：</p>
<ul type="disc">
<li>sed [options] &#8216;command&#8217; file(s)</li>
<li>sed [options] -f scriptfile file(s)</li>
</ul>
<dl>
<dt><span class="term">a\</span></dt>
<dd>在当前行后面加入一行文本。 </dd>
<dt><span class="term">b lable</span></dt>
<dd>分支到脚本中带有标记的地方，如果分支不存在则分支到脚本的末尾。 </dd>
<dt><span class="term">c\</span></dt>
<dd>用新的文本改变本行的文本。 </dd>
<dt><span class="term">d</span></dt>
<dd>从模板块（Pattern space）位置删除行。 </dd>
<dt><span class="term">D</span></dt>
<dd>删除模板块的第一行。 </dd>
<dt><span class="term">i\</span></dt>
<dd>在当前行上面插入文本。 </dd>
<dt><span class="term">h</span></dt>
<dd>拷贝模板块的内容到内存中的缓冲区。 </dd>
<dt><span class="term">H</span></dt>
<dd>追加模板块的内容到内存中的缓冲区 </dd>
<dt><span class="term">g</span></dt>
<dd>获得内存缓冲区的内容，并替代当前模板块中的文本。 </dd>
<dt><span class="term">G</span></dt>
<dd>获得内存缓冲区的内容，并追加到当前模板块文本的后面。 </dd>
<dt><span class="term">l</span></dt>
<dd>列表不能打印字符的清单。 </dd>
<dt><span class="term">n</span></dt>
<dd>读取下一个输入行，用下一个命令处理新的行而不是用第一个命令。 </dd>
<dt><span class="term">N</span></dt>
<dd>追加下一个输入行到模板块后面并在二者间嵌入一个新行，改变当前行号码。 </dd>
<dt><span class="term">p</span></dt>
<dd>打印模板块的行。 </dd>
<dt><span class="term">P（大写）</span></dt>
<dd>打印模板块的第一行。 </dd>
<dt><span class="term">q</span></dt>
<dd>退出Sed。 </dd>
<dt><span class="term">r file</span></dt>
<dd>从file中读行。 </dd>
<dt><span class="term">t label</span></dt>
<dd>if分支，从最后一行开始，条件一旦满足或者T，t命令，将导致分支到带有标号的命令处，或者到脚本的末尾。 </dd>
<dt><span class="term">T label</span></dt>
<dd>错误分支，从最后一行开始，一旦发生错误或者T，t命令，将导致分支到带有标号的命令处，或者到脚本的末尾。 </dd>
<dt><span class="term">w file</span></dt>
<dd>写并追加模板块到file末尾。 </dd>
<dt><span class="term">W file</span></dt>
<dd>写并追加模板块的第一行到file末尾。 </dd>
<dt><span class="term">!</span></dt>
<dd>表示后面的命令对所有没有被选定的行发生作用。 </dd>
<dt><span class="term">s/re/string</span></dt>
<dd>用string替换正则表达式re。 </dd>
<dt><span class="term">=</span></dt>
<dd>打印当前行号码。 </dd>
<dt><span class="term">#</span></dt>
<dd>把注释扩展到下一个换行符以前。 </dd>
<dt><span class="term">以下的是替换标记</span></dt>
<dd>
<ul type="disc">
<li>g表示行内全面替换。</li>
<li>p表示打印行。</li>
<li>w表示把行写入一个文件。</li>
<li>x表示互换模板块中的文本和缓冲区中的文本。</li>
<li>y表示把一个字符翻译为另外的字符（但是不用于正则表达式）</li>
</ul>
</dd>
</dl>
<h2 class="title" style="clear: both">4. 选项</h2>
<dl>
<dt><span class="term">-e command, </span><span class="term">&#8211;expression=command</span></dt>
<dd>允许多台编辑。 </dd>
<dt><span class="term">-h, &#8211;help</span></dt>
<dd>打印帮助，并显示bug列表的地址。 </dd>
<dt><span class="term">-n, &#8211;quiet, &#8211;silent</span></dt>
<dd>取消默认输出。 </dd>
<dt><span class="term">-f, &#8211;filer=script-file</span></dt>
<dd>引导sed脚本文件名。 </dd>
<dt><span class="term">-V, &#8211;version</span></dt>
<dd>打印版本和版权信息。</dd>
<dd> </dd>
</dl>
<h2 class="title" style="clear: both">5. 元字符集</h2>
<dl>
<dt><span class="term">^</span></dt>
<dd>锚定行的开始  如：/^sed/匹配所有以sed开头的行。 </dd>
<dt><span class="term">$</span></dt>
<dd>锚定行的结束 如：/sed$/匹配所有以sed结尾的行。 </dd>
<dt><span class="term">.</span></dt>
<dd>匹配一个非换行符的字符 如：/s.d/匹配s后接一个任意字符，然后是d。 </dd>
<dt><span class="term">*</span></dt>
<dd>匹配零或多个字符 如：/*sed/匹配所有模板是一个或多个空格后紧跟sed的行。 </dd>
<dt><span class="term">[]</span></dt>
<dd>匹配一个指定范围内的字符，如/[Ss]ed/匹配sed和Sed。 </dd>
<dt><span class="term">[^]</span></dt>
<dd>匹配一个不在指定范围内的字符，如：/[^A-RT-Z]ed/匹配不包含A-R和T-Z的一个字母开头，紧跟ed的行。 </dd>
<dt><span class="term">\(..\)</span></dt>
<dd>保存匹配的字符，如s/\(love\)able/\1rs，loveable被替换成lovers。 </dd>
<dt><span class="term">&amp;</span></dt>
<dd>保存搜索字符用来替换其他字符，如s/love/**&amp;**/，love这成**love**。 </dd>
<dt><span class="term">\&lt;</span></dt>
<dd>锚定单词的开始，如:/\&lt;love/匹配包含以love开头的单词的行。 </dd>
<dt><span class="term">\&gt;</span></dt>
<dd>锚定单词的结束，如/love\&gt;/匹配包含以love结尾的单词的行。 </dd>
<dt><span class="term">x\{m\}</span></dt>
<dd>重复字符x，m次，如：/0\{5\}/匹配包含5个o的行。 </dd>
<dt><span class="term">x\{m,\}</span></dt>
<dd>重复字符x,至少m次，如：/o\{5,\}/匹配至少有5个o的行。 </dd>
<dt><span class="term">x\{m,n\}</span></dt>
<dd>重复字符x，至少m次，不多于n次，如：/o\{5,10\}/匹配5&#8211;10个o的行。 </dd>
</dl>
<p class="sect1" lang="en">&nbsp;</p>
<p class="titlepage">&nbsp;</p>
<h2 class="title" style="clear: both">6. 实例</h2>
<dl>
<dt><span class="term">删除：d命令</span></dt>
<dd> </dd>
<dd>
<ul type="disc">
<li>$ sed &#8217;2d&#8217; example&#8212;&#8211;删除example文件的第二行。</li>
<li>$ sed &#8217;2,$d&#8217; example&#8212;&#8211;删除example文件的第二行到末尾所有行。</li>
<li>$ sed &#8216;$d&#8217; example&#8212;&#8211;删除example文件的最后一行。</li>
<li>$ sed &#8216;/test/&#8217;d example&#8212;&#8211;删除example文件所有包含test的行。</li>
</ul>
</dd>
<dt> </dt>
<dt><span class="term">替换：s命令</span></dt>
<dd>
<ul type="disc">
<li>$ sed &#8216;s/test/mytest/g&#8217; example&#8212;&#8211;在整行范围内把test替换为mytest。如果没有g标记，则只有每行第一个匹配的test被替换成mytest。</li>
<li>$ sed -n &#8216;s/^test/mytest/p&#8217; example&#8212;&#8211;(-n)选项和p标志一起使用表示只打印那些发生替换的行。也就是说，如果某一行开头的test被替换成mytest，就打印它。</li>
<li>$ sed &#8216;s/^192.168.0.1/&amp;localhost/&#8217; example&#8212;&#8211;&amp;符号表示替换换字符串中被找到的部份。所有以192.168.0.1开头的行都会被替换成它自已加 localhost，变成192.168.0.1localhost。</li>
<li>$ sed -n &#8216;s/\(love\)able/\1rs/p&#8217; example&#8212;&#8211;love被标记为1，所有loveable会被替换成lovers，而且替换的行会被打印出来。</li>
<li>$ sed &#8216;s#10#100#g&#8217; example&#8212;&#8211;不论什么字符，紧跟着s命令的都被认为是新的分隔符，所以，“#”在这里是分隔符，代替了默认的“/”分隔符。表示把所有10替换成100。</li>
</ul>
</dd>
<dt> </dt>
<dt><span class="term">选定行的范围：逗号</span></dt>
<dt> </dt>
<dd>
<ul type="disc">
<li>$ sed -n &#8216;/test/,/check/p&#8217; example&#8212;&#8211;所有在模板test和check所确定的范围内的行都被打印。</li>
<li>$ sed -n &#8217;5,/^test/p&#8217; example&#8212;&#8211;打印从第五行开始到第一个包含以test开始的行之间的所有行。</li>
<li>$ sed &#8216;/test/,/check/s/$/sed test/&#8217; example&#8212;&#8211;对于模板test和west之间的行，每行的末尾用字符串sed test替换。</li>
</ul>
</dd>
<dt> </dt>
<dt><span class="term">多点编辑：e命令</span></dt>
<dd> </dd>
<dd>
<ul type="disc">
<li>$ sed -e &#8217;1,5d&#8217; -e &#8216;s/test/check/&#8217; example&#8212;&#8211;(-e)选项允许在同一行里执行多条命令。如例子所示，第一条命令删除1至5行，第二条命令用check替换test。命令的执 行顺序对结果有影响。如果两个命令都是替换命令，那么第一个替换命令将影响第二个替换命令的结果。</li>
<li>$ sed &#8211;expression=&#8217;s/test/check/&#8217; &#8211;expression=&#8217;/love/d&#8217; example&#8212;&#8211;一个比-e更好的命令是&#8211;expression。它能给sed表达式赋值。</li>
</ul>
</dd>
<dt> </dt>
<dt><span class="term">从文件读入：r命令</span></dt>
<dd> </dd>
<dd>
<ul type="disc">
<li>$ sed &#8216;/test/r file&#8217; example&#8212;&#8211;file里的内容被读进来，显示在与test匹配的行后面，如果匹配多行，则file的内容将显示在所有匹配行的下面。</li>
</ul>
</dd>
<dt> </dt>
<dt><span class="term">写文件：w命令</span></dt>
<dd> </dd>
<dd>
<ul type="disc">
<li>$ sed -n &#8216;/test/w file&#8217; example&#8212;&#8211;在example中所有包含test的行都被写入file里。</li>
</ul>
</dd>
<dt> </dt>
<dt><span class="term">追加命令：a命令</span>  </dt>
<dt> </dt>
<dd>
<ul type="disc">
<li>$ sed &#8216;/^test/a\\&#8212;&gt;this is a example&#8217; example&lt;&#8212;&#8211;&#8217;this is a example&#8217;被追加到以test开头的行后面，sed要求命令a后面有一个反斜杠。</li>
</ul>
</dd>
<dt> </dt>
<dt><span class="term">插入：i命令</span></dt>
<dd>$ sed &#8216;/test/i\\new line&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8217; example如果test被匹配，则把反斜杠后面的文本插入到匹配行的前面。 </dd>
<dt><span class="term">下一个：n命令</span>  </dt>
<dt> </dt>
<dd>
<ul type="disc">
<li>$ sed &#8216;/test/{ n; s/aa/bb/; }&#8217; example&#8212;&#8211;如果test被匹配，则移动到匹配行的下一行，替换这一行的aa，变为bb，并打印该行，然后继续。</li>
</ul>
</dd>
<dt> </dt>
<dt><span class="term">变形：y命令</span></dt>
<dt> </dt>
<dd>
<ul type="disc">
<li>$ sed &#8217;1,10y/abcde/ABCDE/&#8217; example&#8212;&#8211;把1&#8211;10行内所有abcde转变为大写，注意，正则表达式元字符不能使用这个命令。</li>
</ul>
</dd>
<dt> </dt>
<dt><span class="term">退出：q命令</span></dt>
<dd> </dd>
<dd>
<ul type="disc">
<li>$ sed &#8217;10q&#8217; example&#8212;&#8211;打印完第10行后，退出sed。</li>
</ul>
</dd>
<dt> </dt>
<dt><span class="term">保持和获取：h命令和G命令</span>  </dt>
<dt> </dt>
<dd>
<ul type="disc">
<li>$ sed -e &#8216;/test/h&#8217; -e &#8216;$G example&#8212;&#8211;在sed处理文件的时候，每一行都被保存在一个叫模式空间的临时缓冲区中，除非行被删除或者输出被取消，否则所有被处理的行都将 打印在屏幕上。接着模式空间被清空，并存入新的一行等待处理。在这个例子里，匹配test的行被找到后，将存入模式空间，h命令将其复制并存入一个称为保 持缓存区的特殊缓冲区内。第二条语句的意思是，当到达最后一行后，G命令取出保持缓冲区的行，然后把它放回模式空间中，且追加到现在已经存在于模式空间中 的行的末尾。在这个例子中就是追加到最后一行。简单来说，任何包含test的行都被复制并追加到该文件的末尾。</li>
</ul>
</dd>
<dt> </dt>
<dt><span class="term">保持和互换：h命令和x命令</span>  </dt>
<dt> </dt>
<dd>
<ul type="disc">
<li>$ sed -e &#8216;/test/h&#8217; -e &#8216;/check/x&#8217; example &#8212;&#8211;互换模式空间和保持缓冲区的内容。也就是把包含test与check的行互换</li>
</ul>
</dd>
</dl>
<h2 class="title" style="clear: both">7. 脚本</h2>
<p class="titlepage">Sed脚本是一个sed的命令清单，启动Sed时以-f选项引导脚本文件名。Sed对于脚本中输入的命令非常挑剔，在命令的末尾不能有任何空白或文本，如果在一行中有多个命令，要用分号分隔。以#开头的行为注释行，且不能跨行。</p>
<h2 class="title" style="clear: both">8. 小技巧</h2>
<ul type="disc">
<li>在sed的命令行中引用shell变量时要使用双引号，而不是通常所用的单引号。下面是一个根据name变量的内容来删除named.conf文件中zone段的脚本：
<pre class="screen">name='zone\ "localhost"'sed "/$name/,/};/d" named.conf</pre>
</li>
</ul>
<p><span class="firstname">作者：Jims of <a href="http://www.ringkee.com/" target="_top">肥肥世家</a></span></p>
<p class="address"><tt class="email">&lt;<a href="mailto:jims.yang@gmail.com">jims.yang@gmail.com</a>&gt;</tt></p>
<p class="copyright">Copyright © 2004，2005, 本文遵从GNU 的自由文档许可证(Free Document License)的条款，欢迎转载、修改、散布。</p>
<p class="pubdate">发布时间:2004年09月20日</p>
<p class="pubdate">最近更新:2005年12月22日，增加小技巧章节。</p>
<h2  class="related_post_title">与本文关系暧昧的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/sed-tips.html" title="sed 总结">sed 总结</a></li><li><a href="http://www.linuxbyte.org/sedsi-wei-dao-tu.html" title="sed思维导图">sed思维导图</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2008<br />
Source: <a href="http://www.linuxbyte.org/sed-mini-howto.html">Sed学习笔记</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/sed" rel="tag">sed</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/sed" title="sed" rel="tag">sed</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/sed-mini-howto.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GNU 和 Linux</title>
		<link>http://www.linuxbyte.org/gnulinux.html</link>
		<comments>http://www.linuxbyte.org/gnulinux.html#comments</comments>
		<pubDate>Thu, 17 Apr 2008 14:03:48 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[精品文档]]></category>
		<category><![CDATA[gnu linux]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/gnulinux</guid>
		<description><![CDATA[作者：Christian Schaller 翻译: 杨继张 像Slashdot这样的论坛上常常有人在攻击GNU，他们的观点在我看来完全是缺乏历史知识和不尊重历史。当GNU倡导称Linux为GNU/Linux时，这些人声称GNU企图从 Linus Torva... ]]></description>
			<content:encoded><![CDATA[<p>作者：Christian Schaller 翻译: 杨继张</p>
<p>像Slashdot这样的论坛上常常有人在攻击GNU，他们的观点在我看来完全是缺乏历史知识和不尊重历史。当GNU倡导称Linux为GNU/Linux时，这些人声称GNU企图从 Linus Torvalds 身上窃取荣誉，或者宣称GNU的所作所为有反商业的可疑动机。我最后决定写下这篇文章，以避免出现更多的疑惑。</p>
<p><span id="more-117"></span></p>
<p>下面是这些为数不多但大喊大叫的分裂分子必须牢记的一些简单事实：</p>
<p>我们从GNU与Linux内核的关系开始说起：</p>
<p>GNU 的问世比Linus Torvalds开始从事后来成为Linux内核的工作要早得多，那时GNU早已创立构造OS所必需的一长列工具，包括像编译器、系统函数库之类的开发工具，像emacs 之类的编辑器，等等。像grep、ls和find等许多系统工具和命令也是源自GNU，至少它们当前的新生版本是这样。GNU项目的目标之一是替换常用的 Unix工具，这儿所提的命令就属于这些工具。所有这些工具构成的代码量远比内核本身的代码量大，而内核则体现了GNU项目对于现在大家熟知的Linux 现象的重要性。分裂分子应记住的另一个事实是，主动调整内核以配合GNU系统工作的正是Linus本人。而与GNU的紧密联系对于该内核在各方面的发展来说一直是相当重要的。Alan Cox这位最有前途的内核黑客之一说过，他开始钻研Linux内核而不是其他内核的原因之一在于Linux使用GPL许可证，他认为这要比BSD风格的许可证好。</p>
<p>现在说说分裂分子宣称的GNU带共产主义性质并且反商业的问题。这个说法错得不能再错了。GNU几乎从一开始就通过销售作为 GNU软件介质的磁带和CD-ROM以及印刷版的手册，基于自己开发的软件从事商业活动。他们还非书面地支持和鼓励以支持和/或开发自由软件为生的公司的创立，包括VA Research、Cygnus和Redhat。(最近RedHat和Cygnus宣布相互兼并。)以GNU许可证形式发行的软件改变了软件公司的商业运作方式，但并没有使得不可能做生意。从许多方面看，自由的GPL许可证形式的软件占主导地位的软件市场更体现了资本主义精神，因为它让善于做生意并且真正关心客户的公司受益，而不是让在技术的象牙塔上盘踞垄断地位的公司受益。后者与其说是现代资本主义的新生儿，到不如说是陈旧的重商主义体系的残余物。</p>
<p>第三个批评的根据来自GNU不懈地大力提倡使用GNU许可证。这也许是在“开放源代码” 保护伞下推出的新的许可证近来引发的冲突的根源，但是我们看到，BSD倡导者正因强烈反对GNU许可证导致自己的系统缺乏群众基础而焦头烂额。</p>
<p>GNU 的批评者看问题的角度之一是，坚决强调GNU许可证会给自由软件引入太多的政治因素。对于他们我只能说，如果你对GNU许可证所体现的理想抱有怀疑，那就应该使用不是 Linux的另外某个OS，因为要不是这些许可证，也许不会诞生Linux OS，或者至少像她目前经历地那样得以广泛使用。不少公司正在尝试引入新类型的软件，这些软件的许可证将给当今遵循GPL的Linux系统以特殊的权力或优先考虑。有了这么多的尝试后，我可以相当自信地说，要是Linux使用像BSD许可证这样更为自由的许可证，商业公司就可能不会通过增加自己的专属特性来进行尝试，并在Unix取得竞争优势上取得成功。而我们都知道这已在市场上给Unix造成多大的危害。另一方面，要是Linux系统使用更为严格且不是 copyleft的许可证，例如QPL或可怕的Sun许可证，那么对于大的软件开放者造成的限制就会更高，因为他们会感到自己不是在倡导一个给任何人以一定层次把玩平台的系统，而是在从一个发号施令者改换成另一个发号施令者，结果只能是另一个OS/2的命运。此外，这会使得Linux 的另一个成功因素即源代码共享几乎不可能。有些人看来忘记了，跟GNU许可证使得源代码可自由获取这一事实同样重要的是这些许可证所体现的 copyleft原则。这与试图在Linux软件开发中作为一个大问题重新引入版权(copyright)的新出现的“开放源代码”许可证是背道而驶的。</p>
<p>这么说来我是在积极倡导称这个OS为GNU/Linux了？不，实际上我个人并不称她为GNU/ Linux。我简单地称她为Linux，就像称Microsoft Windows为Windows一样。因此Stallman 和别人提倡使用GNU/Linux的说法时，你不应该攻击他们，相反应该像我那样把它作为警示物看待——它提醒大家GNU在让我们进入当今这个大家所期待的境界的过程中扮演着重要的角色。</p>
<p>明白地说，我并不赞同Richard Stallman关于理想境界是所有软件都按照GPL原则发行的观点。我的观点是，我并不期待大家在任何细节上都赞同GNU和Stallman，确实如此，但是我的确期望乐意使用Linux的人们尊重并承认GNU在Linux社群中已扮演的而且将继续扮演的不可替代的角色。</p>
<h2  class="related_post_title">其他大家爱看的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/mei-ruan-jian-gong-si-cheng-lv-ba-geng-xin-yao-jing-guo-ta-men-de-fu-wu-qi.html" title="美软件公司称绿坝更新要经过他们的服务器 ">美软件公司称绿坝更新要经过他们的服务器 </a></li><li><a href="http://www.linuxbyte.org/install-magiclinux21-from-harddisk.html" title="硬盘安装Magic Linux 2.1">硬盘安装Magic Linux 2.1</a></li><li><a href="http://www.linuxbyte.org/mozilla-public-license.html" title="MOZILLA PUBLIC LICENSE">MOZILLA PUBLIC LICENSE</a></li><li><a href="http://www.linuxbyte.org/ubuntu-linux-xia-ying-pan-huai-dao-de-jian-ce-yu-xiu-fu.html" title="ubuntu linux 下硬盘坏道的检测与修复">ubuntu linux 下硬盘坏道的检测与修复</a></li><li><a href="http://www.linuxbyte.org/my-firefox-addons.html" title="我的firefox 插件">我的firefox 插件</a></li><li><a href="http://www.linuxbyte.org/yong-ppa-zhuang-shang-libreoffice.html" title="用ppa装上LibreOffice">用ppa装上LibreOffice</a></li><li><a href="http://www.linuxbyte.org/shel-fang-zhi-wu-cao-zuo.html" title="用 !$ 防止误操作">用 !$ 防止误操作</a></li><li><a href="http://www.linuxbyte.org/kde-359-announce.html" title="KDE 3.5.9发布公告">KDE 3.5.9发布公告</a></li><li><a href="http://www.linuxbyte.org/linux-syn-attack-defense.html" title="LINUX下的SYN攻击防御">LINUX下的SYN攻击防御</a></li><li><a href="http://www.linuxbyte.org/wang-ba-mei-ip-xian-su-bu-chong-squid-xian-su.html" title="网吧每IP 限速补充（squid 限速）">网吧每IP 限速补充（squid 限速）</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2008<br />
Source: <a href="http://www.linuxbyte.org/gnulinux.html">GNU 和 Linux</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/gnu-linux" rel="tag">gnu linux</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/gnu-linux" title="gnu linux" rel="tag">gnu linux</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/gnulinux.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SMTP 错误代码大全</title>
		<link>http://www.linuxbyte.org/smtp-error-codes.html</link>
		<comments>http://www.linuxbyte.org/smtp-error-codes.html#comments</comments>
		<pubDate>Thu, 03 Apr 2008 09:16:33 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[精品文档]]></category>
		<category><![CDATA[SMTP]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/smtp-error-code</guid>
		<description><![CDATA[421 Service not available, closing transmission channel (This may be a reply to any command if the service knows it must shut down) 450 Requested mail action not taken: mailbox unavailable (E.g., mailbox busy) 451 Requested action aborted: local error in... ]]></description>
			<content:encoded><![CDATA[<p><strong>421</strong> Service not available, closing transmission channel (This may be a reply to any command if the service knows it must shut down)<br />
<strong>450</strong> Requested mail action not taken: mailbox unavailable (E.g., mailbox busy)<br />
<strong>451</strong> Requested action aborted: local error in processing<br />
<strong>452</strong> Requested action not taken: insufficient system storage</p>
<p><span id="more-96"></span><br />
<strong>500</strong> Syntax error, command unrecognized (This may include errors such as command line too long)<br />
<strong>501</strong> Syntax error in parameters or arguments<br />
<strong>502</strong> Command not implemented<br />
<strong>503</strong> Bad sequence of commands<br />
<strong>504</strong> Command parameter not implemented<br />
<strong>550</strong> Requested action not taken: mailbox unavailable (E.g., mailbox not found, no access)<br />
<strong>551</strong> User not local; please try<br />
<strong>552</strong> Requested mail action aborted: exceeded storage allocation<br />
<strong>553</strong> Requested action not taken: mailbox name not allowed (E.g., mailbox syntax incorrect)<br />
<strong>554</strong> Transaction failedThe other codes that provide you with helpful information about what&#8217;s happening with your messages are:</p>
<p><strong>211</strong> System status, or system help reply<br />
<strong>214</strong> Help message (Information on how to use the receiver or the meaning of a particular non-standard command; this reply is useful<br />
only to the human user)<br />
<strong>220</strong> Service ready<br />
<strong>221</strong> Service closing transmission channel<br />
<strong>250</strong> Requested mail action okay, completed<br />
<strong>251</strong> User not local; will forward to<br />
<strong>354</strong> Start mail input; end with . (a dot)</p>
<p>&#8216;*************************  <br />
  &#8216;*   邮件服务返回代码含义  <br />
  &#8216;*   500   格式错误，命令不可识别（此错误也包括命令行过长）  <br />
  &#8216;*   501   参数格式错误  <br />
  &#8216;*   502   命令不可实现  <br />
  &#8216;*   503   错误的命令序列  <br />
  &#8216;*   504   命令参数不可实现  <br />
  &#8216;*   211   系统状态或系统帮助响应  <br />
  &#8216;*   214   帮助信息  <br />
  &#8216;*   220     服务就绪  <br />
  &#8216;*   221     服务关闭传输信道  <br />
  &#8216;*   421     服务未就绪，关闭传输信道（当必须关闭时，此应答可以作为对任何命令的响应）  <br />
  &#8216;*   250   要求的邮件操作完成  <br />
  &#8216;*   251   用户非本地，将转发向  <br />
  &#8216;*   450   要求的邮件操作未完成，邮箱不可用（例如，邮箱忙）  <br />
  &#8216;*   550   要求的邮件操作未完成，邮箱不可用（例如，邮箱未找到，或不可访问）  <br />
  &#8216;*   451   放弃要求的操作；处理过程中出错  <br />
  &#8216;*   551   用户非本地，请尝试  <br />
  &#8216;*   452   系统存储不足，要求的操作未执行  <br />
  &#8216;*   552   过量的存储分配，要求的操作未执行  <br />
  &#8216;*   553   邮箱名不可用，要求的操作未执行（例如邮箱格式错误）  <br />
  &#8216;*   354   开始邮件输入，以.结束  <br />
  &#8216;*   554   操作失败  <br />
  &#8216;*   535   用户验证失败  <br />
  &#8216;*   235   用户验证成功  <br />
  &#8216;*   334   等待用户输入验证信息</p>
<h2  class="related_post_title">其他大家爱看的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/magiclinux-2-5-8-yi-jing-wan-cheng-ji-hua-zheng-zai-shou-wei-diao-shi-dang-zhong.html" title="MagicLinux 2.5.8 已经完成计划正在收尾调试当中">MagicLinux 2.5.8 已经完成计划正在收尾调试当中</a></li><li><a href="http://www.linuxbyte.org/bash-remove-operating-system.html" title="dell 的 Remove Operating System 代码">dell 的 Remove Operating System 代码</a></li><li><a href="http://www.linuxbyte.org/opensuse-11-4-rc2-fa-bu.html" title="openSUSE 11.4 RC2 发布">openSUSE 11.4 RC2 发布</a></li><li><a href="http://www.linuxbyte.org/nginx-shixian-gzip-jingtai-wenjian-yasuo.html" title="Nginx下实现gzip静态文件压缩">Nginx下实现gzip静态文件压缩</a></li><li><a href="http://www.linuxbyte.org/help-fun-input-toy.html" title="致Linux开发者社区：新输入法Fitx开发需要大家帮忙">致Linux开发者社区：新输入法Fitx开发需要大家帮忙</a></li><li><a href="http://www.linuxbyte.org/ubuntu-10-04-beta-1-fabu.html" title="Ubuntu 10.04 Beta 1 发布">Ubuntu 10.04 Beta 1 发布</a></li><li><a href="http://www.linuxbyte.org/sysctl-minihowto.html" title="用Sysctl 调整Linux操作系统的性能">用Sysctl 调整Linux操作系统的性能</a></li><li><a href="http://www.linuxbyte.org/squid-max_filedesc.html" title="高负载情况下的squid 最大可打开文件数">高负载情况下的squid 最大可打开文件数</a></li><li><a href="http://www.linuxbyte.org/magiclinux-2-5-12-xiu-zheng-fa.html" title="MagicLinux 2.5.12 修正发布">MagicLinux 2.5.12 修正发布</a></li><li><a href="http://www.linuxbyte.org/lenny-dedicated-to-thiemo_seufer.html" title="向Thiemo Seufer致敬">向Thiemo Seufer致敬</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2008<br />
Source: <a href="http://www.linuxbyte.org/smtp-error-codes.html">SMTP 错误代码大全</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/smtp" rel="tag">SMTP</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/smtp" title="SMTP" rel="tag">SMTP</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/smtp-error-codes.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

