<?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; webserver</title>
	<atom:link href="http://www.lsproc.com/blog/tag/webserver/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lsproc.com/blog</link>
	<description>lsproc.com</description>
	<lastBuildDate>Fri, 18 Nov 2011 09:22:52 +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>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 &#8230; <a href="http://www.lsproc.com/blog/linux_webserver_cmd/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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>
<p><strong>Linux根据端口查进程信息</strong> </p>
<pre class="brush: bash">ps -ef|awk &#039;{print $2&quot;\t&quot;$8$9}&#039;|grep `netstat -tlnp|grep 8080|awk &#039;{print $7}&#039;|awk -F &#039;/&#039; &#039;{print $1}&#039;` </pre>
<p><strong>批量删除文件BOM头</strong> </p>
<pre class="brush: bash">sed &#039;1s/^\xef\xbb\xbf//&#039; /path/to/has_bom_file</pre>
<p>-- EOF --</p>
<h2  class="related_post_title">Related Posts</h2><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>
	</channel>
</rss>

