<?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>ls /proc &#187; linux</title>
	<atom:link href="http://www.lsproc.com/blog/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lsproc.com/blog</link>
	<description>lsproc.com</description>
	<lastBuildDate>Fri, 21 May 2010 14:29:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>bash if条件判断参数</title>
		<link>http://www.lsproc.com/blog/bash_if_parameters/</link>
		<comments>http://www.lsproc.com/blog/bash_if_parameters/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 06:10:44 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.lsproc.com/blog/?p=348</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/bash_if_parameters/
[ -a FILE ] 如果 FILE 存在则为真。
[ -b FILE ] 如果 FILE 存在且是一个块特殊文件则为真。
[ -c FILE ] 如果 FILE 存在且是一个字特殊文件则为真。
[ -d FILE ] 如果 FILE 存在且是一个目录则为真。
[ -e FILE ] 如果 FILE 存在则为真。
[ -f FILE ] 如果 FILE 存在且是一个普通文件则为真。
[ -g FILE ] 如果 FILE 存在且已经设置了SGID则为真。
[ -h FILE ] 如果 FILE 存在且是一个符号连接则为真。
[ -k FILE ] 如果 [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/bash_if_parameters/">http://www.lsproc.com/blog/bash_if_parameters/</a></p>
<p>[ -a FILE ] 如果 FILE 存在则为真。</p>
<p>[ -b FILE ] 如果 FILE 存在且是一个块特殊文件则为真。</p>
<p>[ -c FILE ] 如果 FILE 存在且是一个字特殊文件则为真。</p>
<p>[ -d FILE ] 如果 FILE 存在且是一个目录则为真。</p>
<p>[ -e FILE ] 如果 FILE 存在则为真。</p>
<p>[ -f FILE ] 如果 FILE 存在且是一个普通文件则为真。</p>
<p>[ -g FILE ] 如果 FILE 存在且已经设置了SGID则为真。</p>
<p>[ -h FILE ] 如果 FILE 存在且是一个符号连接则为真。</p>
<p>[ -k FILE ] 如果 FILE 存在且已经设置了粘制位则为真。</p>
<p>[ -p FILE ] 如果 FILE 存在且是一个名字管道(F如果O)则为真。</p>
<p>[ -r FILE ] 如果 FILE 存在且是可读的则为真。</p>
<p>[ -s FILE ] 如果 FILE 存在且大小不为0则为真。</p>
<p>[ -t FD ] 如果文件描述符 FD 打开且指向一个终端则为真。</p>
<p>[ -u FILE ] 如果 FILE 存在且设置了SUID (set user ID)则为真。</p>
<p>[ -w FILE ] 如果 FILE 如果 FILE 存在且是可写的则为真。</p>
<p>[ -x FILE ] 如果 FILE 存在且是可执行的则为真。</p>
<p>[ -O FILE ] 如果 FILE 存在且属有效用户ID则为真。</p>
<p>[ -G FILE ] 如果 FILE 存在且属有效用户组则为真。</p>
<p>[ -L FILE ] 如果 FILE 存在且是一个符号连接则为真。</p>
<p>[ -N FILE ] 如果 FILE 存在 and has been mod如果ied since it was last read则为真。</p>
<p>[ -S FILE ] 如果 FILE 存在且是一个套接字则为真。</p>
<p>[ FILE1 -nt FILE2 ] 如果 FILE1 has been changed more recently than FILE2, or 如果 FILE1FILE2 does not则为真。</p>
<p>exists and [ FILE1 -ot FILE2 ] 如果 FILE1 比 FILE2 要老, 或者 FILE2 存在且 FILE1 不存在则为真。</p>
<p>[ FILE1 -ef FILE2 ] 如果 FILE1 和 FILE2 指向相同的设备和节点号则为真。</p>
<p>[ -o OPTIONNAME ] 如果 shell选项 “OPTIONNAME” 开启则为真。</p>
<p>[ -z STRING ] “STRING” 的长度为零则为真。</p>
<p>[ -n STRING ] or [ STRING ] “STRING” 的长度为非零 non-zero则为真。</p>
<p>[ STRING1 == STRING2 ] 如果2个字符串相同。 “=” may be used instead of “==” for strict POSIX compliance则为真。</p>
<p>[ STRING1 != STRING2 ] 如果字符串不相等则为真。</p>
<p>[ STRING1 < STRING2 ] 如果 “STRING1” sorts before “STRING2” lexicographically in the current locale则为真。</p>
<p>[ STRING1 > STRING2 ] 如果 “STRING1” sorts after “STRING2” lexicographically in the current locale则为真。</p>
<p><del datetime="2010-01-15T06:10:51+00:00">原文(已失效): http://hi.baidu.com/starlotus/blog/item/5707aeca34af14f753664f38.html </del>
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2010-01-09 -- <a href="http://www.lsproc.com/blog/linux_timeline/" title="linux timeline">linux timeline</a> (2)</li><li>2008-12-16 -- <a href="http://www.lsproc.com/blog/linux_webserver_cmd/" title="Webserver 维护常用命令">Webserver 维护常用命令</a> (9)</li><li>2008-11-10 -- <a href="http://www.lsproc.com/blog/useful_linux_command/" title="一些 linux 命令">一些 linux 命令</a> (0)</li><li>2008-08-31 -- <a href="http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/" title="ubuntu 安装Intel PRO100/1000系列网卡驱动">ubuntu 安装Intel PRO100/1000系列网卡驱动</a> (0)</li><li>2008-03-18 -- <a href="http://www.lsproc.com/blog/configure_lamp/" title="lamp 相关配置 [Debian]">lamp 相关配置 [Debian]</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/bash_if_parameters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>linux timeline</title>
		<link>http://www.lsproc.com/blog/linux_timeline/</link>
		<comments>http://www.lsproc.com/blog/linux_timeline/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 05:45:42 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[timeline]]></category>

		<guid isPermaLink="false">http://www.lsproc.com/blog/?p=335</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/linux_timeline/
-- EOF --
Related Posts2010-01-15 -- bash if条件判断参数 (0)2008-12-16 -- Webserver 维护常用命令 (9)2008-11-10 -- 一些 linux 命令 (0)2008-08-31 -- ubuntu 安装Intel PRO100/1000系列网卡驱动 (0)2008-03-18 -- lamp 相关配置 [Debian] (2)]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/linux_timeline/">http://www.lsproc.com/blog/linux_timeline/</a></p>
<p><div id="attachment_341" class="wp-caption alignnone" style="width: 488px"><a href="http://www.lsproc.com/blog/wp-content/uploads/2010/01/linux-timeline1.png"><img src="http://www.lsproc.com/blog/wp-content/uploads/2010/01/linux-timeline1-478x800.png" alt="linux timeline" title="linux-timeline" width="478" height="800" class="size-medium wp-image-341" /></a><p class="wp-caption-text">linux timeline</p></div>
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2010-01-15 -- <a href="http://www.lsproc.com/blog/bash_if_parameters/" title="bash if条件判断参数">bash if条件判断参数</a> (0)</li><li>2008-12-16 -- <a href="http://www.lsproc.com/blog/linux_webserver_cmd/" title="Webserver 维护常用命令">Webserver 维护常用命令</a> (9)</li><li>2008-11-10 -- <a href="http://www.lsproc.com/blog/useful_linux_command/" title="一些 linux 命令">一些 linux 命令</a> (0)</li><li>2008-08-31 -- <a href="http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/" title="ubuntu 安装Intel PRO100/1000系列网卡驱动">ubuntu 安装Intel PRO100/1000系列网卡驱动</a> (0)</li><li>2008-03-18 -- <a href="http://www.lsproc.com/blog/configure_lamp/" title="lamp 相关配置 [Debian]">lamp 相关配置 [Debian]</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/linux_timeline/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Webserver 维护常用命令</title>
		<link>http://www.lsproc.com/blog/linux_webserver_cmd/</link>
		<comments>http://www.lsproc.com/blog/linux_webserver_cmd/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 02:13:39 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[webserver]]></category>
		<category><![CDATA[命令]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/?p=129</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/linux_webserver_cmd/
实时查看正在执行的sql语句
/usr/sbin/tcpdump -i eth0 -s 0 -l -w - dst port 3306 &#124; strings &#124; egrep -i &#039;SELECT&#124;UPDATE&#124;DELETE&#124;INSERT&#124;SET&#124;COMMIT&#124;ROLLBACK&#124;CREATE&#124;DROP&#124;ALTER&#124;CALL&#039;
查看http连接
netstat -n &#124; awk &#039;/^tcp/ {++state[$NF]} END {for(key in state) print key,&#34;\t&#34;,state[key]}&#039;
查看SYN状态的http连接
netstat -an &#124; grep SYN &#124; awk &#039;{print $5}&#039; &#124; awk -F: &#039;{print $1}&#039; &#124; sort &#124; uniq -c &#124; sort -nr &#124; more
查看TIME_WAIT状态的http连接
netstat -tna &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/linux_webserver_cmd/">http://www.lsproc.com/blog/linux_webserver_cmd/</a></p>
<p><strong>实时查看正在执行的sql语句</strong></p>
<pre class="brush: bash">/usr/sbin/tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | egrep -i &#039;SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL&#039;</pre>
<p><strong>查看http连接</strong></p>
<pre class="brush: bash">netstat -n | awk &#039;/^tcp/ {++state[$NF]} END {for(key in state) print key,&quot;\t&quot;,state[key]}&#039;</pre>
<p><strong>查看SYN状态的http连接</strong></p>
<pre class="brush: bash">netstat -an | grep SYN | awk &#039;{print $5}&#039; | awk -F: &#039;{print $1}&#039; | sort | uniq -c | sort -nr | more</pre>
<p><strong>查看TIME_WAIT状态的http连接</strong></p>
<pre class="brush: bash">netstat -tna | cut -b 49- |grep TIME_WAIT | sort |more
netstat -an | grep TIME_WAIT | awk &#039;{print $5}&#039; | awk -F: &#039;{print $1}&#039; | sort | uniq -c | sort -nr | more</pre>
<p><strong>查看ESTABLISHED状态的http连接</strong></p>
<pre class="brush: bash">netstat -an | grep ESTABLISHED | awk &#039;{print $5}&#039; | awk -F: &#039;{print $1}&#039; | sort | uniq -c | sort -nr | more
netstat -an | grep &quot;:80&quot; | grep ESTABLISHED | sort | more</pre>
<p><strong>批量kill进程</strong></p>
<pre class="brush: bash">ps -efww|grep sqlr-listener|grep -v grep|cut -c 9-15|xargs kill -9</pre>
<p><strong>查看活动的php-cgi连接数</strong></p>
<pre class="brush: bash">netstat -anpo|grep php-cgi|wc -l</pre>
<p><strong>按ip查看httpd连接数</strong></p>
<pre class="brush: bash">netstat -anlp | grep 80 | grep tcp | awk {&#039;print $5&#039;} | awk -F: {&#039;print $1&#039;}| sort |uniq -c | sort -nr</pre>
<p><strong>禁IP</strong></p>
<pre class="brush: bash">iptables -A INPUT -s IP地址 -j REJECT
iptables -A INPUT -s IP地址/24 -j REJECT

route add -net IP地址 netmask 255.255.255.0 reject</pre>
<p><strong>调试命令</strong></p>
<pre class="brush: bash">strace -p pid</pre>
<p>跟踪指定的进程pid. </p>
<pre class="brush: bash">gdb -p pid</pre>
<p>跟踪指定的进程pid. </p>
<p><strong>批量查找文件并删除</strong></p>
<pre class="brush: bash">find . -name test.php -exec rm {} \;
find . -name test.php | xargs rm -rf</pre>
<p><strong>更改某一目录下所有目录的权限, 不包括文件, aaa 是目录名</strong></p>
<pre class="brush: bash">find aaa -type d -exec chmod 755 {} \;</pre>
<p><strong>替换文件内容</strong></p>
<pre class="brush: bash">sed -i &#039;s/b/strong/g&#039; index.html</pre>
<p>此命令搜索 index.html 文件中的 b 并将其替换为 strong。
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2008-11-10 -- <a href="http://www.lsproc.com/blog/useful_linux_command/" title="一些 linux 命令">一些 linux 命令</a> (0)</li><li>2007-11-30 -- <a href="http://www.lsproc.com/blog/linux_user_manage/" title="Linux系统用户账号的管理">Linux系统用户账号的管理</a> (0)</li><li>2010-01-15 -- <a href="http://www.lsproc.com/blog/bash_if_parameters/" title="bash if条件判断参数">bash if条件判断参数</a> (0)</li><li>2010-01-09 -- <a href="http://www.lsproc.com/blog/linux_timeline/" title="linux timeline">linux timeline</a> (2)</li><li>2008-08-31 -- <a href="http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/" title="ubuntu 安装Intel PRO100/1000系列网卡驱动">ubuntu 安装Intel PRO100/1000系列网卡驱动</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/linux_webserver_cmd/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>一些 linux 命令</title>
		<link>http://www.lsproc.com/blog/useful_linux_command/</link>
		<comments>http://www.lsproc.com/blog/useful_linux_command/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 08:13:34 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[命令]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/useful_linux_command/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/useful_linux_command/
1. 更改某一目录下所有目录的权限, 不包括文件 aaa 是目录名
find aaa -type d -exec chmod 755 {} \;

find . -name test.php -exec rm {} \;
find . -name test.php &#124; xargs rm -rf
搜索当前目录下（包括子目录）所有test.php这个文件，并将它们删除。
2. 查看文件属性，可用此查看压缩文件的格式
file 文件名
3. 定时任务
用cron处理定时任务,首先要保证cron操作已经运行。如果安装了cron 的话。正常情况下cron已经开机自运行了，如果没有运行的话。
/etc/init.d/cron start
 用crontab来安排定时任务
crontab [-u user] {-l&#124; -r &#124;  -e}
-l:显示任务
-e:编辑任务
-r:清空任务
任务格式为:
分 时 日期 月份 星期 操作命令
eg:

##每天14点运行一次
* 14 * * * echo &#34; look me&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/useful_linux_command/">http://www.lsproc.com/blog/useful_linux_command/</a></p>
<p>1. 更改某一目录下所有目录的权限, 不包括文件 aaa 是目录名</p>
<pre class="brush: bash">find aaa -type d -exec chmod 755 {} \;

find . -name test.php -exec rm {} \;
find . -name test.php | xargs rm -rf</pre>
<p>搜索当前目录下（包括子目录）所有test.php这个文件，并将它们删除。</p>
<p>2. 查看文件属性，可用此查看压缩文件的格式</p>
<pre class="brush: bash">file 文件名</pre>
<p>3. 定时任务<br />
用cron处理定时任务,首先要保证cron操作已经运行。如果安装了cron 的话。正常情况下cron已经开机自运行了，如果没有运行的话。</p>
<pre class="brush: bash">/etc/init.d/cron start</pre>
<p> 用crontab来安排定时任务</p>
<pre class="brush: bash">crontab [-u user] {-l| -r |  -e}
-l:显示任务
-e:编辑任务
-r:清空任务</pre>
<p>任务格式为:<br />
分 时 日期 月份 星期 操作命令<br />
eg:</p>
<pre class="brush: bash">
##每天14点运行一次
* 14 * * * echo &quot; look me&quot; &gt;&gt; /home/lost/test    

 ##表示每两分钟运行一次
0-59/2 * * * * echo &quot;look me&quot; &gt;&gt; /tmp/test   

##表示2与15点运行一次
* 2,15 * * * echo &quot;look me &quot; &gt;&gt; /tmp/test
</pre>
<p>* : 表示任意   - : 表示区间.  / :表示频率  , ：表示枚举<br />
<a href="http://linux.vbird.org/linux_basic/0430cron.php#cron">http://linux.vbird.org/linux_basic/0430cron.php#cron</a></p>
<p>4. 递归查找文件内的字符串</p>
<pre class="brush: bash">find ./ -name &#039;*.html&#039; -exec grep &quot;breadcrumbs.inc.php&quot; &#039;{}&#039; \; -print</pre>
<p>这条命令将查找所有包含 breadcrumbs.inc.php 的 HTML 文件。 </p>
<p>5. 搜索并替换文件里的内容</p>
<pre class="brush: bash">sed -i &#039;s/b/strong/g&#039; index.html</pre>
<p>此命令搜索 index.html 文件中的 b 并将其替换为 strong。 </p>
<p>6. 调试命令<br />
strace -p pid<br />
跟踪指定的进程pid. </p>
<p>gdb -p pid<br />
跟踪指定的进程pid. </p>
<p>7. 去掉不用的 /aaa/bbb 的$PATH</p>
<pre class="brush: bash">export PATH=`echo $PATH | sed -e &#039;s/:\/aaa\/bbb//g&#039;`</pre>
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2008-12-16 -- <a href="http://www.lsproc.com/blog/linux_webserver_cmd/" title="Webserver 维护常用命令">Webserver 维护常用命令</a> (9)</li><li>2007-11-30 -- <a href="http://www.lsproc.com/blog/linux_user_manage/" title="Linux系统用户账号的管理">Linux系统用户账号的管理</a> (0)</li><li>2010-01-15 -- <a href="http://www.lsproc.com/blog/bash_if_parameters/" title="bash if条件判断参数">bash if条件判断参数</a> (0)</li><li>2010-01-09 -- <a href="http://www.lsproc.com/blog/linux_timeline/" title="linux timeline">linux timeline</a> (2)</li><li>2008-08-31 -- <a href="http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/" title="ubuntu 安装Intel PRO100/1000系列网卡驱动">ubuntu 安装Intel PRO100/1000系列网卡驱动</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/useful_linux_command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ubuntu 安装Intel PRO100/1000系列网卡驱动</title>
		<link>http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/</link>
		<comments>http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 16:30:02 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[网卡]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/?p=153</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/
1、 下载相应的驱动程序压缩包 e1000xxxxx.tar.gz
2、 解压包文件 tar zxvf e1000xxxxx.tar.gz
3、 切换目录 cd e1000xxxxx/src
4、 编译make install //在目录 src下. 二进制驱动程序的位置/ /lib/modules/2.6.xx.xx.../kernel /drivers/net。
5、 加载模块 modprobe e1000
6、 修改文件 /etc/modprobe.d/alias, 添加 alias eth0 e1000 alias eth1 e1000
-- EOF --
Related Posts2007-07-11 -- 再谈自定义 ubuntu 安装 (0)2007-05-25 -- Fluxbox 配置 (0)2007-05-23 -- 安装独一无二的操作系统 (1)2007-05-18 -- Ubuntu 分区和文件系统的选择 (0)2007-05-18 -- Ubuntu apt源 (0)]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/">http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/</a></p>
<p>1、 下载相应的驱动程序压缩包 e1000xxxxx.tar.gz</p>
<p>2、 解压包文件 tar zxvf e1000xxxxx.tar.gz</p>
<p>3、 切换目录 cd e1000xxxxx/src</p>
<p>4、 编译make install //在目录 src下. 二进制驱动程序的位置/ /lib/modules/2.6.xx.xx.../kernel /drivers/net。</p>
<p>5、 加载模块 modprobe e1000</p>
<p>6、 修改文件 /etc/modprobe.d/alias, 添加 alias eth0 e1000 alias eth1 e1000
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2007-07-11 -- <a href="http://www.lsproc.com/blog/diy_your_ubuntu/" title="再谈自定义 ubuntu 安装">再谈自定义 ubuntu 安装</a> (0)</li><li>2007-05-25 -- <a href="http://www.lsproc.com/blog/fluxbox_config/" title="Fluxbox 配置">Fluxbox 配置</a> (0)</li><li>2007-05-23 -- <a href="http://www.lsproc.com/blog/install_unique_operating_system/" title="安装独一无二的操作系统">安装独一无二的操作系统</a> (1)</li><li>2007-05-18 -- <a href="http://www.lsproc.com/blog/ubuntu_partition_and_file_system/" title="Ubuntu 分区和文件系统的选择">Ubuntu 分区和文件系统的选择</a> (0)</li><li>2007-05-18 -- <a href="http://www.lsproc.com/blog/ubuntu_apt_sources_list/" title="Ubuntu apt源">Ubuntu apt源</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>lamp 相关配置 [Debian]</title>
		<link>http://www.lsproc.com/blog/configure_lamp/</link>
		<comments>http://www.lsproc.com/blog/configure_lamp/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 08:35:41 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/configure_lamp/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/configure_lamp/
编译环境
Debian (Ubuntu)

apt-get install build-essential
apt-get install libncurses5-dev
sudo apt-get install libxml2-dev libcurl3-dev libpng-dev libmhash-dev libmcrypt-dev libxslt-dev libpspell-dev

Mysql编译安装参数
CHOST=&#34;i686-pc-linux-gnu&#34; CFLAGS=&#34;-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&#34; CXXFLAGS=&#34;-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&#34; ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-Community-Server --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-ndb-debug --without-isam --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
配置成功会提示：
MySQL has [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/configure_lamp/">http://www.lsproc.com/blog/configure_lamp/</a></p>
<p>编译环境</p>
<p>Debian (Ubuntu)</p>
<pre class="brush: bash">
apt-get install build-essential
apt-get install libncurses5-dev
sudo apt-get install libxml2-dev libcurl3-dev libpng-dev libmhash-dev libmcrypt-dev libxslt-dev libpspell-dev
</pre>
<p><strong>Mysql编译安装参数</strong></p>
<pre class="brush: bash">CHOST=&quot;i686-pc-linux-gnu&quot; CFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; CXXFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-Community-Server --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-ndb-debug --without-isam --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock</pre>
<p>配置成功会提示：</p>
<p>MySQL has a Web site athttp://www.mysql.com/which carries details on the<br />
latest release, upcoming features, and other information to make your<br />
work or play with MySQL more productive. There you can also find<br />
information about mailing lists for MySQL discussion.</p>
<p>Remember to check the platform. specific part of the reference manual for<br />
hints about installing MySQL on your platform. Also have a look at the<br />
files in the Docs directory.</p>
<p>Thank you for choosing MySQL!</p>
<pre class="brush: bash">
make
make install

groupadd mysql                     //增加mysql组
useradd -g mysql mysql         //增加mysql用户，这个用户属于mysql组
cd /usr/local/mysql
bin/mysql_install_db --user=mysql
chown -R root:mysql . //设置权限，注意后面有一个 &quot;.&quot;
chown -R mysql /var/lib/mysql //设置 mysql 目录权限
chgrp -R mysql . //注意后面有一个 &quot;.&quot;
cp share/mysql/my-medium.cnf /etc/my.cnf
cp share/mysql/mysql.server /etc/init.d/mysqld //开机自动启动 mysql。
chmod 755 /etc/init.d/mysqld
rcconf    //开启启动服务设置
/etc/init.d/mysqld start //启动 MySQL
bin/mysqladmin -u root password &quot;password_for_root&quot;
</pre>
<p><strong>查看mysql编译参数</strong><br />
cat /usr/local/mysql/bin/mysqlbug |grep ./configure</p>
<p>把 mysql 加入环境变量<br />
export PATH="$PATH:/usr/local/mysql/bin"</p>
<p>apache 编译</p>
<pre class="brush: bash">
./configure   //配置源代码树
--prefix=/usr/local/apache2  //体系无关文件的顶级安装目录PREFIX ，也就Apache的安装目录。
--enable-module=so   //打开 so 模块，so 模块是用来提 DSO 支持的 apache 核心模块
--enable-deflate=shared   //支持网页压缩
--enable-expires=shared   //支持 HTTP 控制
--enable-rewrite=shared   //支持 URL 重写
--enable-cache  //支持缓存
--enable-file-cache  //支持文件缓存
--enable-mem-cache  //支持记忆缓存
--enable-disk-cache //支持磁盘缓存
--enable-static-support   //支持静态连接(默认为动态连接)
--enable-static-htpasswd   //使用静态连接编译 htpasswd - 管理用于基本认证的用户文件
--enable-static-htdigest  //使用静态连接编译 htdigest - 管理用于摘要认证的用户文件
--enable-static-rotatelogs  //使用静态连接编译 rotatelogs - 滚动 Apache 日志的管道日志程序
--enable-static-logresolve   //使用静态连接编译 logresolve - 解析 Apache 日志中的IP地址为主机名
--enable-static-htdbm   //使用静态连接编译 htdbm - 操作 DBM 密码数据库
--enable-static-ab  //使用静态连接编译 ab - Apache HTTP 服务器性能测试工具
--enable-static-checkgid   //使用静态连接编译 checkgid
--disable-cgid  //禁止用一个外部 CGI 守护进程执行CGI脚本
--disable-cgi   //禁止编译 CGI 版本的 PHP
--disable-userdir  //禁止用户从自己的主目录中提供页面
--with-mpm=worker // 让apache以worker方式运行
--enable-authn-dbm=shared // 对动态数据库进行操作。Rewrite时需要。

make
make install
</pre>
<p>建立一个符号连接：</p>
<pre class="brush: bash">
ln -s /usr/local/apache2/bin/apachectl /etc/init.d/httpd
rcconf    //加入自动启动
</pre>
<p>php 编译</p>
<pre class="brush: bash">
CHOST=&quot;i686-pc-linux-gnu&quot; CFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; CXXFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; ./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql --with-gd --enable-calendar --with-zlib --with-curl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-apxs2=/usr/local/apache2/bin/apxs --with-openssl --enable-zend-multibyte --with-gettext --with-mcrypt --enable-exif --with-png-dir=/usr/local/lib --enable-ftp --with-mhash --with-libxml-dir=/usr/local/lib --with-xsl --with-pspell
</pre>
<p>配置完成提示<br />
+--------------------------------------------------------------------+<br />
| License:                                                           |<br />
| This software is subject to the PHP License, available in this     |<br />
| distribution in the file LICENSE.  By continuing this installation |<br />
| process, you are bound by the terms of this license agreement.     |<br />
| If you do not agree with the terms of this license, you must abort |<br />
| the installation process at this point.                            |<br />
+--------------------------------------------------------------------+</p>
<p>Thank you for using PHP.</p>
<pre class="brush: bash">
make
make install
</pre>
<p>修改/usr/local/apache2/conf/httpd.conf，在AddType部分加入如下内容<br />
AddType application/x-httpd-php .php
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2006-08-22 -- <a href="http://www.lsproc.com/blog/trouble-with-rebuild-system/" title="重装系统是件麻烦的事">重装系统是件麻烦的事</a> (0)</li><li>2008-03-01 -- <a href="http://www.lsproc.com/blog/close_timewait_connection/" title="如何关闭time_wait连接">如何关闭time_wait连接</a> (4)</li><li>2007-09-07 -- <a href="http://www.lsproc.com/blog/php_mysql_study_4/" title="PHP 和 Mysql 学习笔记（四）">PHP 和 Mysql 学习笔记（四）</a> (0)</li><li>2007-06-22 -- <a href="http://www.lsproc.com/blog/php_mysql_study_2/" title="PHP 和 Mysql 学习笔记（二）">PHP 和 Mysql 学习笔记（二）</a> (0)</li><li>2010-05-21 -- <a href="http://www.lsproc.com/blog/nginx_php_pathinfo_securit/" title="Nginx/PHP 文件类型错误解析漏洞：fix_pathinfo">Nginx/PHP 文件类型错误解析漏洞：fix_pathinfo</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/configure_lamp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>解决webalizer 汉化后图表中乱码的问题</title>
		<link>http://www.lsproc.com/blog/webalizer_graphs_bad_encode/</link>
		<comments>http://www.lsproc.com/blog/webalizer_graphs_bad_encode/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 09:47:03 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[webalizer]]></category>
		<category><![CDATA[乱码]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/%e8%a7%a3%e5%86%b3webalizer_%e6%b1%89%e5%8c%96%e5%90%8e%e5%9b%be%e8%a1%a8%e4%b8%ad%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae%e9%a2%98/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/webalizer_graphs_bad_encode/
代码如下(webalizer_patch.pl):

#!/usr/bin/perl
######################################################
# webalizer_patch.pl
# 原作：http://mail.tses.tcc.edu.tw/nuke/sections.php?op=viewarticle&#38;artid=139
# 修改：陶然 &#60;taoran@taoran.net&#62;
# 功能: 解决HTML汉化后图表中乱码的问题
# 方法：图表中乱码改用英文显示就正常了
#       需要修改: graphs.c output.c webalizer_lang.h lang.h
#
# tar zxf webalizer-2.01-10-src.tgz
# cd webalizer-2.01-10
# ./configure --with-language=simplified_chinese
# perl /path/of/webalizer_patch.pl ./
# make
# make install
#
####################################################
$file_graph	= &#34;$ARGV[0]/graphs.c&#34;;
if(!(-e $file_graph))   {
	print &#34;error open  $file_graph
&#34;;
	print &#34;Usage:
  perl $0  DIR
&#34;;
#DIR是源文件目录，比如 ./
	exit;
}

#把图表中的月份和注释改成英文
@old_var	= (&#34;msg_h_hits&#34;,
		&#34;msg_h_pages&#34;,
		&#34;msg_h_visits&#34;,
		&#34;msg_h_files&#34;,
		&#34;msg_h_sites&#34;,
		&#34;msg_h_xfer&#34;,
		&#34;s_month&#34;);

@new_var	= (&#34;msg_gh_hits&#34;,
		&#34;msg_gh_pages&#34;,
		&#34;msg_gh_visits&#34;,
		&#34;msg_gh_files&#34;,
		&#34;msg_gh_sites&#34;,
		&#34;msg_gh_xfer&#34;,
		&#34;s_gmonth&#34;);

open(IN,&#34;&#60;$file_graph&#34;);
@lines	= &#60;IN&#62;;
$size	= @lines;
close(IN);

`mv $file_graph [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/webalizer_graphs_bad_encode/">http://www.lsproc.com/blog/webalizer_graphs_bad_encode/</a></p>
<p>代码如下(webalizer_patch.pl):</p>
<pre class="brush: perl">
#!/usr/bin/perl
######################################################
# webalizer_patch.pl
# 原作：http://mail.tses.tcc.edu.tw/nuke/sections.php?op=viewarticle&amp;artid=139
# 修改：陶然 &lt;taoran@taoran.net&gt;
# 功能: 解决HTML汉化后图表中乱码的问题
# 方法：图表中乱码改用英文显示就正常了
#       需要修改: graphs.c output.c webalizer_lang.h lang.h
#
# tar zxf webalizer-2.01-10-src.tgz
# cd webalizer-2.01-10
# ./configure --with-language=simplified_chinese
# perl /path/of/webalizer_patch.pl ./
# make
# make install
#
####################################################
$file_graph	= &quot;$ARGV[0]/graphs.c&quot;;
if(!(-e $file_graph))   {
	print &quot;error open  $file_graph
&quot;;
	print &quot;Usage:
  perl $0  DIR
&quot;;
#DIR是源文件目录，比如 ./
	exit;
}

#把图表中的月份和注释改成英文
@old_var	= (&quot;msg_h_hits&quot;,
		&quot;msg_h_pages&quot;,
		&quot;msg_h_visits&quot;,
		&quot;msg_h_files&quot;,
		&quot;msg_h_sites&quot;,
		&quot;msg_h_xfer&quot;,
		&quot;s_month&quot;);

@new_var	= (&quot;msg_gh_hits&quot;,
		&quot;msg_gh_pages&quot;,
		&quot;msg_gh_visits&quot;,
		&quot;msg_gh_files&quot;,
		&quot;msg_gh_sites&quot;,
		&quot;msg_gh_xfer&quot;,
		&quot;s_gmonth&quot;);

open(IN,&quot;&lt;$file_graph&quot;);
@lines	= &lt;IN&gt;;
$size	= @lines;
close(IN);

`mv $file_graph $file_graph.bak`;
open(OUT,&quot;&gt;$file_graph&quot;);
for($i=0;$i&lt;$size;$i++)   {
	for($k=0;$k&lt;@old_var;$k++)   {
		if($lines[$i] =~ s/$old_var[$k]/$new_var[$k]/g)   {
			print &quot;$i	$old_var[$k] -&gt; $new_var[$k]
&quot;;
			print OUT &quot;/* --- Modified --- */
&quot;;
		}
	}
	print OUT $lines[$i];
}
close(OUT);

#把图表中的标题改成英文显示
$file_output	= &quot;$ARGV[0]/output.c&quot;;
open(IN,&quot;&lt;$file_output&quot;);
@lines	= &lt;IN&gt;;
$size	= @lines;
close(IN);
`mv $file_output $file_output.bak`;
open(OUT,&quot;&gt;$file_output&quot;);
for($i=0;$i&lt;$size;$i++)   {
	if($lines[$i] =~ s/msg_hmth_du,l_month/&quot;Daily Usage for&quot;,s_gmonth/xg) {
		print &quot;$i	patched
&quot;;
		print OUT &quot;/* --- Modified --- */
&quot;;
	} elsif($lines[$i] =~ s/msg_hmth_hu,l_month/&quot;Hourly Usage for&quot;,s_gmonth/xg) {
		print &quot;$i	patched
&quot;;
		print OUT &quot;/* --- Modified --- */
&quot;;
	} elsif($lines[$i] =~ s/msg_ctry_use,l_month/&quot;Usage by Country for&quot;,s_gmonth/xg) {
		print &quot;$i	patched
&quot;;
		print OUT &quot;/* --- Modified --- */
&quot;;
	} elsif($lines[$i] =~ s/msg_main_us/&quot;Usage summary for&quot;/xg) {
		print &quot;$i	patched
&quot;;
		print OUT &quot;/* --- Modified --- */
&quot;;
	}
	print  OUT $lines[$i];
}
close(OUT);

#加入新的函数给前面显示的程序用 

print &quot;
patch	$ARGV[0]/webalizer_lang.h
&quot;;

$file_lang	= &quot;$ARGV[0]/webalizer_lang.h&quot;;
open(OUT,&quot;&gt;&gt;$file_lang&quot;);
print OUT qq~
/* --- start Add  ---*/
char *msg_gh_hits  = &quot;Hits&quot;;
char *msg_gh_pages = &quot;Pages&quot;;
char *msg_gh_visits= &quot;Visits&quot;;
char *msg_gh_files = &quot;Files&quot;;
char *msg_gh_sites = &quot;Sites&quot;;
char *msg_gh_xfer  = &quot;KBytes&quot;;

char *s_gmonth[12]={ &quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;,
                    &quot;Apr&quot;, &quot;May&quot;, &quot;Jun&quot;,
                    &quot;Jul&quot;, &quot;Aug&quot;, &quot;Sep&quot;,
                    &quot;Oct&quot;, &quot;Nov&quot;, &quot;Dec&quot;};

/* -------------End------------- */
~;

#补充声明这些新加的函数
print &quot;
patch	$ARGV[0]/lang.h
&quot;;

$file_lang	= &quot;$ARGV[0]/lang.h&quot;;
open(OUT,&quot;&gt;&gt;$file_lang&quot;);
print OUT qq~
/* --- start Add  ---*/
extern char *msg_gh_hits  ;
extern char *msg_gh_pages ;
extern char *msg_gh_visits;
extern char *msg_gh_files ;
extern char *msg_gh_sites ;
extern char *msg_gh_xfer  ;
extern char *s_gmonth[12];
/* -------------End------------- */
~;

print &quot;Done ^_^
&quot;;

####################################################
</pre>
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2010-01-15 -- <a href="http://www.lsproc.com/blog/bash_if_parameters/" title="bash if条件判断参数">bash if条件判断参数</a> (0)</li><li>2010-01-11 -- <a href="http://www.lsproc.com/blog/cacti_graph_with_chinese/" title="cacti 图片中文乱码问题">cacti 图片中文乱码问题</a> (2)</li><li>2010-01-09 -- <a href="http://www.lsproc.com/blog/linux_timeline/" title="linux timeline">linux timeline</a> (2)</li><li>2008-12-16 -- <a href="http://www.lsproc.com/blog/linux_webserver_cmd/" title="Webserver 维护常用命令">Webserver 维护常用命令</a> (9)</li><li>2008-11-10 -- <a href="http://www.lsproc.com/blog/useful_linux_command/" title="一些 linux 命令">一些 linux 命令</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/webalizer_graphs_bad_encode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何关闭time_wait连接</title>
		<link>http://www.lsproc.com/blog/close_timewait_connection/</link>
		<comments>http://www.lsproc.com/blog/close_timewait_connection/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 16:35:58 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[netstat]]></category>
		<category><![CDATA[time_wait]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/close_timewait_connection/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/close_timewait_connection/
结合netstat和awk命令来统计网络连接数
From: http://hi.baidu.com/thinkinginlamp/blog/item/afbcab64b1ad81f3f6365453.html
netstat -n &#124; awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"\t",state[key]}'
会得到类似下面的结果，具体数字会有所不同：
LAST_ACK         1
SYN_RECV         14
ESTABLISHED      79
FIN_WAIT1        28
FIN_WAIT2        3
CLOSING [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/close_timewait_connection/">http://www.lsproc.com/blog/close_timewait_connection/</a></p>
<p>结合netstat和awk命令来统计网络连接数<br />
From: <a href="http://hi.baidu.com/thinkinginlamp/blog/item/afbcab64b1ad81f3f6365453.html">http://hi.baidu.com/thinkinginlamp/blog/item/afbcab64b1ad81f3f6365453.html</a></p>
<p><code>netstat -n | awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"\t",state[key]}'</code></p>
<p>会得到类似下面的结果，具体数字会有所不同：</p>
<blockquote><p>LAST_ACK         1<br />
SYN_RECV         14<br />
ESTABLISHED      79<br />
FIN_WAIT1        28<br />
FIN_WAIT2        3<br />
CLOSING          5<br />
TIME_WAIT        1669</p></blockquote>
<p>状态：描述<br />
CLOSED：无连接是活动的或正在进行<br />
LISTEN：服务器在等待进入呼叫<br />
SYN_RECV：一个连接请求已经到达，等待确认<br />
SYN_SENT：应用已经开始，打开一个连接<br />
ESTABLISHED：正常数据传输状态<br />
FIN_WAIT1：应用说它已经完成<br />
FIN_WAIT2：另一边已同意释放<br />
ITMED_WAIT：等待所有分组死掉<br />
CLOSING：两边同时尝试关闭<br />
TIME_WAIT：另一边已初始化一个释放<br />
LAST_ACK：等待所有分组死掉</p>
<p>也就是说，这条命令可以把当前系统的网络连接状态分类汇总。</p>
<p>下面解释一下为啥要这样写：</p>
<p>一个简单的管道符连接了netstat和awk命令。</p>
<p>------------------------------------------------------------------</p>
<p>先来看看netstat：</p>
<p><strong>netstat -n</strong></p>
<p>Active Internet connections (w/o servers)<br />
Proto Recv-Q Send-Q Local Address           Foreign Address         State<br />
tcp        0      0 123.123.123.123:80      234.234.234.234:12345   TIME_WAIT</p>
<p>你实际执行这条命令的时候，可能会得到成千上万条类似上面的记录，不过我们就拿其中的一条就足够了。</p>
<p>------------------------------------------------------------------</p>
<p>再来看看awk：</p>
<p><strong>/^tcp/</strong><br />
滤出tcp开头的记录，屏蔽udp, socket等无关记录。</p>
<p><strong>state[]</strong><br />
相当于定义了一个名叫state的数组</p>
<p><strong>NF</strong><br />
表示记录的字段数，如上所示的记录，NF等于6</p>
<p><strong>$NF</strong><br />
表示某个字段的值，如上所示的记录，$NF也就是$6，表示第6个字段的值，也就是TIME_WAIT</p>
<p><strong>state[$NF]</strong><br />
表示数组元素的值，如上所示的记录，就是state[TIME_WAIT]状态的连接数</p>
<p><strong>++state[$NF]</strong><br />
表示把某个数加一，如上所示的记录，就是把state[TIME_WAIT]状态的连接数加一</p>
<p><strong>END</strong><br />
表示在最后阶段要执行的命令</p>
<p><strong>for(key in state)</strong><br />
遍历数组</p>
<p><strong>print key,"\t",state[key]</strong><br />
打印数组的键和值，中间用\t制表符分割，美化一下。</p>
<p>如发现系统存在大量TIME_WAIT状态的连接，通过调整内核参数解决，<br />
<code>vim /etc/sysctl.conf</code><br />
编辑文件，加入以下内容：</p>
<pre class="brush: bash">net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30</pre>
<p>然后执行 <code>/sbin/sysctl -p</code> 让参数生效。</p>
<p><strong>net.ipv4.tcp_syncookies = 1</strong> 表示开启SYN Cookies。当出现SYN等待队列溢出时，启用cookies来处理，可防范少量SYN攻击，默认为0，表示关闭；<br />
<strong>net.ipv4.tcp_tw_reuse = 1</strong> 表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接，默认为0，表示关闭；<br />
<strong>net.ipv4.tcp_tw_recycle = 1</strong> 表示开启TCP连接中TIME-WAIT sockets的快速回收，默认为0，表示关闭。<br />
<strong>net.ipv4.tcp_fin_timeout</strong> 修改系統默认的 TIMEOUT 时间</p>
<p>下面附上TIME_WAIT状态的意义：</p>
<p>客户端与服务器端建立TCP/IP连接后关闭SOCKET后，服务器端连接的端口<br />
状态为TIME_WAIT</p>
<p>是不是所有执行主动关闭的socket都会进入TIME_WAIT状态呢？<br />
有没有什么情况使主动关闭的socket直接进入CLOSED状态呢？</p>
<p>主动关闭的一方在发送最后一个 ack 后<br />
就会进入 TIME_WAIT 状态 停留2MSL（max segment lifetime）时间<br />
这个是TCP/IP必不可少的，也就是“解决”不了的。</p>
<p>也就是TCP/IP设计者本来是这么设计的<br />
主要有两个原因<br />
1。防止上一次连接中的包，迷路后重新出现，影响新连接<br />
（经过2MSL，上一次连接中所有的重复包都会消失）<br />
2。可靠的关闭TCP连接<br />
在主动关闭方发送的最后一个 ack(fin) ，有可能丢失，这时被动方会重新发<br />
fin, 如果这时主动方处于 CLOSED 状态 ，就会响应 rst 而不是 ack。所以<br />
主动方要处于 TIME_WAIT 状态，而不能是 CLOSED 。</p>
<p>TIME_WAIT 并不会占用很大资源的，除非受到攻击。</p>
<p>还有，如果一方 send 或 recv 超时，就会直接进入 CLOSED 状态</p>
<p>继续阅读:<br />
<a href="http://blog.s135.com/read.php/269.htm">查看Apache并发请求数及其TCP连接状态</a><br />
<a href="http://www.pgsqldb.org/mwiki/index.php/Linux_%E5%8F%8D_DDOS%E7%9A%84%E5%87%A0%E4%B8%AA%E8%AE%BE%E7%BD%AE">Linux 反 DDOS的几个设置</a>
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2008-03-18 -- <a href="http://www.lsproc.com/blog/configure_lamp/" title="lamp 相关配置 [Debian]">lamp 相关配置 [Debian]</a> (2)</li><li>2010-01-15 -- <a href="http://www.lsproc.com/blog/bash_if_parameters/" title="bash if条件判断参数">bash if条件判断参数</a> (0)</li><li>2010-01-09 -- <a href="http://www.lsproc.com/blog/linux_timeline/" title="linux timeline">linux timeline</a> (2)</li><li>2008-12-16 -- <a href="http://www.lsproc.com/blog/linux_webserver_cmd/" title="Webserver 维护常用命令">Webserver 维护常用命令</a> (9)</li><li>2008-11-10 -- <a href="http://www.lsproc.com/blog/useful_linux_command/" title="一些 linux 命令">一些 linux 命令</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/close_timewait_connection/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>vmware server (1.03) sn for linux</title>
		<link>http://www.lsproc.com/blog/vmware_server_sn_for_linux/</link>
		<comments>http://www.lsproc.com/blog/vmware_server_sn_for_linux/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 15:41:30 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sn]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/vmware_server_sn_for_linux/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/vmware_server_sn_for_linux/
Your serial number(s):
9A44N-YAFFA-22J9Q-4J314
9814N-YAY4C-20N45-402AH
9AJFM-Y8ADA-28HC3-4TL8D
981D5-Y0A4V-2AM41-403LN
98N60-Y2FFZ-20JC2-4LQ1X
92J6J-Y8CDZ-200F4-421C0
92HD5-YAV4F-2AJ3P-4TMLX
98JF1-Y2VDZ-22036-4L6TX
9A1DM-YAF6U-20H4M-4A735
98041-Y2UFV-224DH-48QHR
90M6J-Y0U4C-2A5D4-40KHN
98MF1-YAU6C-22561-4A52M
9A16H-Y8ZDA-22MDH-48Q2D
90HD0-Y0Z6V-22H4N-48MUM
9054J-Y2YFV-2A592-4TKHM
98H6H-Y8ZDG-201D1-4042W
90M4J-Y0VDZ-20HFM-4A0HT
90H4H-Y2A4Y-2AMDJ-4A5TJ
90144-Y8U6V-2A112-4L2JJ
98165-Y0C4C-22H44-4AQ38
90H61-YAAFA-20H3L-4T6HX
9816M-Y8C6V-2A5FM-481TT
985DM-Y8GDY-20144-4809X
90M44-Y8AFU-28J36-4LK01
90M4H-Y2UDC-28540-407J9
-- EOF --
Related Posts2010-01-15 -- bash if条件判断参数 (0)2010-01-09 -- linux timeline (2)2008-12-16 -- Webserver 维护常用命令 (9)2008-11-10 -- 一些 linux 命令 (0)2008-08-31 -- ubuntu 安装Intel PRO100/1000系列网卡驱动 (0)]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/vmware_server_sn_for_linux/">http://www.lsproc.com/blog/vmware_server_sn_for_linux/</a></p>
<p>Your serial number(s):<br />
9A44N-YAFFA-22J9Q-4J314<br />
9814N-YAY4C-20N45-402AH<br />
9AJFM-Y8ADA-28HC3-4TL8D<br />
981D5-Y0A4V-2AM41-403LN<br />
98N60-Y2FFZ-20JC2-4LQ1X<br />
92J6J-Y8CDZ-200F4-421C0<br />
92HD5-YAV4F-2AJ3P-4TMLX<br />
98JF1-Y2VDZ-22036-4L6TX<br />
9A1DM-YAF6U-20H4M-4A735<br />
98041-Y2UFV-224DH-48QHR<br />
90M6J-Y0U4C-2A5D4-40KHN<br />
98MF1-YAU6C-22561-4A52M<br />
9A16H-Y8ZDA-22MDH-48Q2D<br />
90HD0-Y0Z6V-22H4N-48MUM<br />
9054J-Y2YFV-2A592-4TKHM<br />
98H6H-Y8ZDG-201D1-4042W<br />
90M4J-Y0VDZ-20HFM-4A0HT<br />
90H4H-Y2A4Y-2AMDJ-4A5TJ<br />
90144-Y8U6V-2A112-4L2JJ<br />
98165-Y0C4C-22H44-4AQ38<br />
90H61-YAAFA-20H3L-4T6HX<br />
9816M-Y8C6V-2A5FM-481TT<br />
985DM-Y8GDY-20144-4809X<br />
90M44-Y8AFU-28J36-4LK01<br />
90M4H-Y2UDC-28540-407J9
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2010-01-15 -- <a href="http://www.lsproc.com/blog/bash_if_parameters/" title="bash if条件判断参数">bash if条件判断参数</a> (0)</li><li>2010-01-09 -- <a href="http://www.lsproc.com/blog/linux_timeline/" title="linux timeline">linux timeline</a> (2)</li><li>2008-12-16 -- <a href="http://www.lsproc.com/blog/linux_webserver_cmd/" title="Webserver 维护常用命令">Webserver 维护常用命令</a> (9)</li><li>2008-11-10 -- <a href="http://www.lsproc.com/blog/useful_linux_command/" title="一些 linux 命令">一些 linux 命令</a> (0)</li><li>2008-08-31 -- <a href="http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/" title="ubuntu 安装Intel PRO100/1000系列网卡驱动">ubuntu 安装Intel PRO100/1000系列网卡驱动</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/vmware_server_sn_for_linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>linux防arp欺骗</title>
		<link>http://www.lsproc.com/blog/anti_arp_on_linux/</link>
		<comments>http://www.lsproc.com/blog/anti_arp_on_linux/#comments</comments>
		<pubDate>Fri, 30 Nov 2007 11:38:18 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[arp]]></category>
		<category><![CDATA[arp欺骗]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/anti_arp_on_linux/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/anti_arp_on_linux/
主要是针对局域网里有人使用网络执法官或者p2p终结者冒充网关的行径。
假设真实的网关是192.168.0.1   其mac是00:0D:C0:13:3A:39。局域网中使用了局域网控制软件的有192.168.0.10,192.168.0.20 这几台机器。
1、编辑/etc/ethers（如果没有则创建），内容为真实网关的ip和mac：
192.168.0.1 00:0D:C0:13:3A:39
2、相关命令：
arp -d 192.168.0.10
arp -d 192.168.0.20
arp -f
可以将以上命令设为开机启动
-- EOF --
Related Posts2010-01-15 -- bash if条件判断参数 (0)2010-01-09 -- linux timeline (2)2008-12-16 -- Webserver 维护常用命令 (9)2008-11-10 -- 一些 linux 命令 (0)2008-08-31 -- ubuntu 安装Intel PRO100/1000系列网卡驱动 (0)]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/anti_arp_on_linux/">http://www.lsproc.com/blog/anti_arp_on_linux/</a></p>
<p>主要是针对局域网里有人使用网络执法官或者p2p终结者冒充网关的行径。</p>
<p>假设真实的网关是192.168.0.1   其mac是00:0D:C0:13:3A:39。局域网中使用了局域网控制软件的有192.168.0.10,192.168.0.20 这几台机器。</p>
<p>1、编辑/etc/ethers（如果没有则创建），内容为真实网关的ip和mac：<br />
<code>192.168.0.1 00:0D:C0:13:3A:39</code><br />
2、相关命令：<br />
<code>arp -d 192.168.0.10<br />
arp -d 192.168.0.20<br />
arp -f</code><br />
可以将以上命令设为开机启动
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2010-01-15 -- <a href="http://www.lsproc.com/blog/bash_if_parameters/" title="bash if条件判断参数">bash if条件判断参数</a> (0)</li><li>2010-01-09 -- <a href="http://www.lsproc.com/blog/linux_timeline/" title="linux timeline">linux timeline</a> (2)</li><li>2008-12-16 -- <a href="http://www.lsproc.com/blog/linux_webserver_cmd/" title="Webserver 维护常用命令">Webserver 维护常用命令</a> (9)</li><li>2008-11-10 -- <a href="http://www.lsproc.com/blog/useful_linux_command/" title="一些 linux 命令">一些 linux 命令</a> (0)</li><li>2008-08-31 -- <a href="http://www.lsproc.com/blog/install_network_card_driver_on_ubuntu/" title="ubuntu 安装Intel PRO100/1000系列网卡驱动">ubuntu 安装Intel PRO100/1000系列网卡驱动</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/anti_arp_on_linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
