<?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>夜行人 &#187; Linux</title>
	<atom:link href="http://www.187299.com/archives/tag/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://www.187299.com</link>
	<description>寻觅生命中的那一片浅草......</description>
	<lastBuildDate>Wed, 16 Nov 2011 11:25:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Linux下根据模块名查看网卡驱动版本</title>
		<link>http://www.187299.com/archives/1830</link>
		<comments>http://www.187299.com/archives/1830#comments</comments>
		<pubDate>Tue, 25 Oct 2011 05:15:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1830</guid>
		<description><![CDATA[例如我们要查看博通网卡的驱动版本，如果该机器上刚好是博通的网卡，最简单的方法就是 ethtool -i eth0 但如果我们所查看的机器用的不是博通的网卡，则可以通过以下方法查看 我们知道博通... ]]></description>
			<content:encoded><![CDATA[<p>例如我们要查看博通网卡的驱动版本，如果该机器上刚好是博通的网卡，最简单的方法就是<br />
ethtool -i eth0</p>
<p>但如果我们所查看的机器用的不是博通的网卡，则可以通过以下方法查看<br />
我们知道博通网卡的驱动文件名叫bnx2.ko<br />
我们查找下bnx2.ko的位置<br />
updatedb<br />
locate bnx2.ko<br />
结果如下<br />
/lib/modules/2.6.32-71.el6.x86_64/kernel/drivers/net/bnx2.ko<br />
查看驱动详细情况<br />
modinfo /lib/modules/2.6.32-71.el6.x86_64/kernel/drivers/net/bnx2.ko<br />
以下信息中，version记录就是我们的网卡驱动版本，是2.0.8-j15</p>
<p>filename:       /lib/modules/2.6.32-71.el6.x86_64/kernel/drivers/net/bnx2.ko<br />
firmware:       bnx2/bnx2-rv2p-09ax-5.0.0.j10.fw<br />
firmware:       bnx2/bnx2-rv2p-09-5.0.0.j10.fw<br />
firmware:       bnx2/bnx2-mips-09-5.0.0.j15.fw<br />
firmware:       bnx2/bnx2-rv2p-06-5.0.0.j3.fw<br />
firmware:       bnx2/bnx2-mips-06-5.0.0.j6.fw<br />
version:        2.0.8-j15<br />
license:        GPL<br />
description:    Broadcom NetXtreme II BCM5706/5708/5709/5716 Driver<br />
author:         Michael Chan &lt;mchan@broadcom.com&gt;<br />
srcversion:     8CDA41B3E0DF70A112FBA80<br />
alias:          pci:v000014E4d0000163Csv*sd*bc*sc*i*<br />
alias:          pci:v000014E4d0000163Bsv*sd*bc*sc*i*<br />
alias:          pci:v000014E4d0000163Asv*sd*bc*sc*i*<br />
alias:          pci:v000014E4d00001639sv*sd*bc*sc*i*<br />
alias:          pci:v000014E4d000016ACsv*sd*bc*sc*i*<br />
alias:          pci:v000014E4d000016AAsv*sd*bc*sc*i*<br />
alias:          pci:v000014E4d000016AAsv0000103Csd00003102bc*sc*i*<br />
alias:          pci:v000014E4d0000164Csv*sd*bc*sc*i*<br />
alias:          pci:v000014E4d0000164Asv*sd*bc*sc*i*<br />
alias:          pci:v000014E4d0000164Asv0000103Csd00003106bc*sc*i*<br />
alias:          pci:v000014E4d0000164Asv0000103Csd00003101bc*sc*i*<br />
depends:<br />
vermagic:       2.6.32-71.el6.x86_64 SMP mod_unload modversions<br />
parm:           disable_msi:Disable Message Signaled Interrupt (MSI) (int)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1830/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx递归限制访问同名目录</title>
		<link>http://www.187299.com/archives/1815</link>
		<comments>http://www.187299.com/archives/1815#comments</comments>
		<pubDate>Fri, 25 Mar 2011 13:30:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1815</guid>
		<description><![CDATA[Nginx根目录是/opt/www 假如 /opt/www/a/x /opt/www/a/d/x /opt/www/b/x 如果配置可以禁止访问所有的x目录？ 找到了 location ~ ^(.*)\/\x\/{ deny all;... ]]></description>
			<content:encoded><![CDATA[<p>Nginx根目录是/opt/www</p>
<p>假如<br />
/opt/www/a/x<br />
/opt/www/a/d/x<br />
/opt/www/b/x<br />
如果配置可以禁止访问所有的x目录？</p>
<p>找到了<br />
location ~ ^(.*)\/\x\/{ deny all;}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1815/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux下SecureCRT的替代品：PAC Manager</title>
		<link>http://www.187299.com/archives/1794</link>
		<comments>http://www.187299.com/archives/1794#comments</comments>
		<pubDate>Fri, 04 Mar 2011 16:21:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1794</guid>
		<description><![CDATA[在windows下管理linux服务器，经常用的是securecrt，它主要特性有 1、标签式管理 2、标签可以克隆，方便在不同标签完成不同工作 3、服务器列表支持分类 4、缓存key的 passphrase，只需要输入一次，... ]]></description>
			<content:encoded><![CDATA[<p>在windows下管理linux服务器，经常用的是securecrt，它主要特性有</p>
<p>1、标签式管理<br />
2、标签可以克隆，方便在不同标签完成不同工作<br />
3、服务器列表支持分类<br />
4、缓存key的 passphrase，只需要输入一次，后续使用该key的服务器访问都不需要再输入<br />
5、Forward agent.</p>
<p>大家通过用securecrt登录到2台服务器，2台服务器上都有自己的key，这时，2台服务器上不需要额外的设置即可以相互scp文件，这个过程用的就是 SSH的Forward agent特性，它把认证进行转发。</p>
<p>而我们在linux下管理linux，比较常用的是gnome terminal，这个与securecrt比起来，未免太原始了，敲命令，敲到手抽筋，最近在网上找securecrt的替代工具，竟然在WOW！Ubuntu上找到了PAC Manager 。</p>
<p>http://wowubuntu.com/pac-254.html</p>
<p>它主要特性：<br />
1、标签式管理<br />
2、标签可以克隆，方便在不同标签完成不同工作<br />
3、服务器列表支持分类<br />
4、Forward agent（这个可以通过PAC本身的配置实现，有可以通过修改/etc/ssh/ssh_config的配置来实现）.</p>
<p>对比下可以看到，PAC Manager不支持缓存passphrase，这意味着，你每登录一台服务器 ，你都需要输入一次你key的 passphrase，但这个可以通过修改系统配置来达到.</p>
<p>我在ubuntu 10.10上安装了，下面先来做简单介绍</p>
<p>下面说下PAC Manager的图形化操作<br />
添加组：<br />
PAC窗口左上角“GROUP”显示的是组信息，点击添加可以新建分组</p>
<p>左下角是添加服务器列表，点击添加可以添加服务器信息</p>
<p>填好IP，用户名和密码等，如果是用key登录，密码留空即，再指定key的位置</p>
<p>"Edit connection" -&gt; "Connections Properties" -&gt; "Advanced Options":</p>
<p>-o "IdentityFile=/path/to/my_private_key_file"</p>
<p>如果想登录2台服务器，可以相互scp文件，则需要在“CONNECTION PROPERTIES”里把“Forward Agent”选上。</p>
<p>这样就可以进行连接了</p>
<p>每台服务器都需要指定key，这个未免太麻烦了，另外有些服务器需要使用另一个key，而且每次使用key登录服务器，都需要输入key的passphrase，为解决这个问题，我们只要把要用到的private key都交给ssh-agent来进行管理，，每个key只需要输入一次passphrase，后面的登录，就不用输入密码了。</p>
<p>ssh-agent 是个管理 private key 的 passphrase 的工具，启动<br />
ssh-agent<br />
添加需要被ssh-agent管理的key，假设你的private key名是id_rsa<br />
ssh-add id_rsa<br />
此时需要输入一次 private key 的 passphrase ，输入正确后，passphrase 就归 ssh-agent 管理，往后的 ssh 操作，就不需要询问 passphrase 了</p>
<p>ssh-add -l 可以看到现有托管的key</p>
<p>PAC Manager的配置文件保存在/home/user/.pac/pac.yml<br />
如果有大量服务器需要添加，可以写脚本，直接生成配置文件放到/home/user/.pac/pac.yml</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1794/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>syslog记录history历史记录</title>
		<link>http://www.187299.com/archives/1781</link>
		<comments>http://www.187299.com/archives/1781#comments</comments>
		<pubDate>Thu, 06 Jan 2011 13:32:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1781</guid>
		<description><![CDATA[工作中可能会有无聊的黑客在你服务器上转悠，黑客智商都不错，所有离开的时候就会删除history记录。怎么办才能记录下用户的历史记录呢？ 原理：将history记录到syslog上面，并实时的传送到... ]]></description>
			<content:encoded><![CDATA[<p>工作中可能会有无聊的黑客在你服务器上转悠，黑客智商都不错，所有离开的时候就会删除history记录。怎么办才能记录下用户的历史记录呢？<br />
原理：将history记录到syslog上面，并实时的传送到了远端的日志集中服务器上。</p>
<p>方法：使用bash4.1的新功能：历史命令保存到syslog！然后使用syslog-ng构建集中型日志服务器收集主机日志。</p>
<p>1、下载bash：<br />
#wget http://ftp.gnu.org/gnu/bash/bash-4.1.tar.gz<br />
#tar zxvf bash-4.1.tar.gz –C /tmp/bash-4.1<br />
#cd /tmp/bash-4.1</p>
<p>2、修改源码</p>
<p>(根据个人需要，我只保留了pid，uid，sid等，参数请看目录下的shell.c中)：<br />
文件bashhist.c大约708行的位置开始，修改成以下一段：</p>
<p>syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d PPID=%d SID=%d  User=%s CMD=%s", getpid(), getppid(), getsid(getpid()),  current_user.user_name, line);<br />
else<br />
{<br />
strncpy (trunc, line, SYSLOG_MAXLEN);<br />
trunc[SYSLOG_MAXLEN - 1] = '\0';<br />
syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY (TRUNCATED): PID=%d  PPID=%d SID=%d User=%s CMD=%s", getpid(), getppid(), getsid(getpid()),  current_user.user_name, trunc);<br />
}<br />
注：<br />
ppid：跟踪sh切换后的用户<br />
Sid： 跟踪 su 切换后的用户<br />
第二段代表log长度超过600后使用的语句<br />
修改config-top.h文件</p>
<p>/*#define SYSLOG_HISTORY*/<br />
修改为<br />
#define SYSLOG_HISTORY<br />
编译安装<br />
# ./configure --prefix=/usr/local/bash_4.1 &#038;&#038; make &#038;&#038; make install<br />
修改用户配置：<br />
将用户的bash换成现在的bash4.1<br />
# vi /etc/passwd<br />
dongwm:x:501:501::/home/dongwm:/usr/local/bash_4.1/bin/bash<br />
这样日志就会记在/var/log/messages<br />
结果类似这样：</p>
<p>Dec 23 17:40:28 server -bash: HISTORY: PID=4089 PPID=4088 SID=4089 User=dongwm CMD=exit<br />
Dec 23 17:41:47 server -bash: HISTORY: PID=4282 PPID=4278 SID=4282 User=root CMD=exit<br />
Dec 23 17:41:53 server -bash: HISTORY: PID=4321 PPID=4317 SID=4321 User=root CMD=ssh java00<br />
Dec 23 17:44:09 server -bash: HISTORY: PID=2152 PPID=2137 SID=2152 User=root CMD=vi Clean_javalog.sh<br />
Dec 23 17:45:16 server -bash: HISTORY: PID=2152 PPID=2137 SID=2152 User=root CMD=sh Clean_javalog.sh<br />
Dec 23 17:45:30 server -bash: HISTORY: PID=2152 PPID=2137 SID=2152 User=root CMD=cat /dev/shm/cleanJavaLog.log<br />
Dec 23 17:46:08 server -bash: HISTORY: PID=2152 PPID=2137 SID=2152 User=root CMD=vi Clean_javalog.sh<br />
Dec 23 17:48:54 server -bash: HISTORY: PID=2152 PPID=2137 SID=2152 User=root CMD=cat Clean_javalog.sh</p>
<p>......<br />
在整个环境布置了记录功能，就能方便的查出来谁-在何时，用什么账号，做了什么操作...</p>
<p>3、主机syslog配置（添加日志服务器的地址）<br />
# vi /etc/syslog.conf</p>
<p>在最后添加一列：<br />
*.* @server.dongwm.com</p>
<p>4、搭建日志服务器<br />
请参看：http://wenku.baidu.com/view/c3bb49c58bd63186bcebbc7a.html</p>
<p>转载自:http://salogs.com/2010/12/syslog%E8%AE%B0%E5%BD%95history%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1781/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python处理keepass导出的xml文件</title>
		<link>http://www.187299.com/archives/1775</link>
		<comments>http://www.187299.com/archives/1775#comments</comments>
		<pubDate>Mon, 20 Dec 2010 13:23:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1775</guid>
		<description><![CDATA[用keepass管理密码 现在有员工需要将用户名和密码导出来 格式如下 username password 我觉得最难的地方是根据Value取出来的list中，有空值，如果是空值，取其值或者类型时，都会提示 “AttributeError:... ]]></description>
			<content:encoded><![CDATA[<p>用keepass管理密码<br />
现在有员工需要将用户名和密码导出来<br />
格式如下<br />
username password</p>
<p>我觉得最难的地方是根据Value取出来的list中，有空值，如果是空值，取其值或者类型时，都会提示<br />
“AttributeError: 'NoneType' object has no attribute 'nodeType'”<br />
可以加if i.firstChild is None:continue进行判断，如果是空值则跳出本次循环<br />
if i.firstChild is None:continue这个是非常pythonic的写法哦</p>
<p>程序</p>
<p>[python]<br />
#!/bin/env python<br />
import sys<br />
from xml.dom import minidom<br />
if len(sys.argv[0:]) != 2:<br />
    print "./keepass.py your xml file's path"<br />
    sys.exit()</p>
<p>list=[]<br />
xmldoc = minidom.parse(sys.argv[1])<br />
reflist = xmldoc.getElementsByTagName('Value')<br />
for i in reflist[::-1]:<br />
    if i.firstChild is None:continue<br />
    list.append(i.firstChild.nodeValue)</p>
<p>for j in range(0,len(list),3):<br />
	print list[j]+" "+list[j+2]</p>
<p>[/python]</p>
<p>输出结果<br />
lisi BiPqIcbHVfUDxaONKjNV<br />
zhangsan h5LGhEYc3OASZf1VcGbD</p>
<p>keepass.xml</p>
<p>[xml]<br />
<?xml version="1.0" encoding="utf-8" standalone="yes"?><br />
<KeePassFile><br />
	<Meta><br />
		<Generator>KeePass</Generator><br />
		<DatabaseName /><br />
		<DatabaseNameChanged>2010-10-18T06:08:30Z</DatabaseNameChanged><br />
		<DatabaseDescription /><br />
		<DatabaseDescriptionChanged>2010-10-18T06:08:30Z</DatabaseDescriptionChanged><br />
		<DefaultUserName /><br />
		<DefaultUserNameChanged>2010-10-18T06:08:30Z</DefaultUserNameChanged><br />
		<MaintenanceHistoryDays>365</MaintenanceHistoryDays><br />
		<MasterKeyChanged>2010-11-12T05:41:29Z</MasterKeyChanged><br />
		<MasterKeyChangeRec>-1</MasterKeyChangeRec><br />
		<MasterKeyChangeForce>-1</MasterKeyChangeForce><br />
		<MemoryProtection><br />
			<ProtectTitle>False</ProtectTitle><br />
			<ProtectUserName>False</ProtectUserName><br />
			<ProtectPassword>True</ProtectPassword><br />
			<ProtectURL>False</ProtectURL><br />
			<ProtectNotes>False</ProtectNotes><br />
		</MemoryProtection><br />
		<RecycleBinEnabled>True</RecycleBinEnabled><br />
		<RecycleBinUUID>c8kwCXpGOE+MBy1jzCOT/g==</RecycleBinUUID><br />
		<RecycleBinChanged>2010-10-18T06:08:30Z</RecycleBinChanged><br />
		<EntryTemplatesGroup>AAAAAAAAAAAAAAAAAAAAAA==</EntryTemplatesGroup><br />
		<EntryTemplatesGroupChanged>2010-10-18T06:08:30Z</EntryTemplatesGroupChanged><br />
		<LastSelectedGroup>NHp/A6+c1kqAdPJrncQ5mQ==</LastSelectedGroup><br />
		<LastTopVisibleGroup>Vgbin7aoeEuGRJXKiJk47g==</LastTopVisibleGroup><br />
		<CustomData /><br />
	</Meta><br />
	<Root><br />
		<Group><br />
			<UUID>NHp/A6+c1kqAdPJrncQ5mQ==</UUID><br />
			<Name>keepass</Name><br />
			<Notes /><br />
			<IconID>48</IconID><br />
			<Times><br />
				<LastModificationTime>2010-12-20T13:00:58Z</LastModificationTime><br />
				<CreationTime>2010-12-20T13:00:52Z</CreationTime><br />
				<LastAccessTime>2010-12-20T13:01:06Z</LastAccessTime><br />
				<ExpiryTime>2010-12-18T10:04:30Z</ExpiryTime><br />
				<Expires>False</Expires><br />
				<UsageCount>3</UsageCount><br />
				<LocationChanged>2010-12-20T13:00:52Z</LocationChanged><br />
			</Times><br />
			<IsExpanded>True</IsExpanded><br />
			<DefaultAutoTypeSequence /><br />
			<EnableAutoType>null</EnableAutoType><br />
			<EnableSearching>null</EnableSearching><br />
			<LastTopVisibleEntry>NMjEkhZudUiMAnPQOYQa+Q==</LastTopVisibleEntry><br />
			<Entry><br />
				<UUID>NMjEkhZudUiMAnPQOYQa+Q==</UUID><br />
				<IconID>0</IconID><br />
				<ForegroundColor /><br />
				<BackgroundColor /><br />
				<OverrideURL /><br />
				<Tags /><br />
				<Times><br />
					<LastModificationTime>2010-12-20T13:01:18Z</LastModificationTime><br />
					<CreationTime>2010-12-20T13:01:07Z</CreationTime><br />
					<LastAccessTime>2010-12-20T13:01:18Z</LastAccessTime><br />
					<ExpiryTime>2010-12-18T10:04:30Z</ExpiryTime><br />
					<Expires>False</Expires><br />
					<UsageCount>1</UsageCount><br />
					<LocationChanged>2010-12-20T13:01:07Z</LocationChanged><br />
				</Times><br />
				<String><br />
					<Key>Notes</Key><br />
					<Value /><br />
				</String><br />
				<String><br />
					<Key>Password</Key><br />
					<Value>h5LGhEYc3OASZf1VcGbD</Value><br />
				</String><br />
				<String><br />
					<Key>Title</Key><br />
					<Value>张三</Value><br />
				</String><br />
				<String><br />
					<Key>URL</Key><br />
					<Value /><br />
				</String><br />
				<String><br />
					<Key>UserName</Key><br />
					<Value>zhangsan</Value><br />
				</String><br />
				<AutoType><br />
					<Enabled>True</Enabled><br />
					<DataTransferObfuscation>0</DataTransferObfuscation><br />
				</AutoType><br />
				<History /><br />
			</Entry><br />
			<Entry><br />
				<UUID>b3KWP7kC+UmZnnSA4d0byg==</UUID><br />
				<IconID>0</IconID><br />
				<ForegroundColor /><br />
				<BackgroundColor /><br />
				<OverrideURL /><br />
				<Tags /><br />
				<Times><br />
					<LastModificationTime>2010-12-20T13:01:31Z</LastModificationTime><br />
					<CreationTime>2010-12-20T13:01:22Z</CreationTime><br />
					<LastAccessTime>2010-12-20T13:01:31Z</LastAccessTime><br />
					<ExpiryTime>2010-12-18T10:04:30Z</ExpiryTime><br />
					<Expires>False</Expires><br />
					<UsageCount>1</UsageCount><br />
					<LocationChanged>2010-12-20T13:01:22Z</LocationChanged><br />
				</Times><br />
				<String><br />
					<Key>Notes</Key><br />
					<Value /><br />
				</String><br />
				<String><br />
					<Key>Password</Key><br />
					<Value>BiPqIcbHVfUDxaONKjNV</Value><br />
				</String><br />
				<String><br />
					<Key>Title</Key><br />
					<Value>李四</Value><br />
				</String><br />
				<String><br />
					<Key>URL</Key><br />
					<Value /><br />
				</String><br />
				<String><br />
					<Key>UserName</Key><br />
					<Value>lisi</Value><br />
				</String><br />
				<AutoType><br />
					<Enabled>True</Enabled><br />
					<DataTransferObfuscation>0</DataTransferObfuscation><br />
				</AutoType><br />
				<History /><br />
			</Entry><br />
		</Group><br />
		<DeletedObjects><br />
			<DeletedObject><br />
				<UUID>9LVoDcHI9UquYgzy1tRXzg==</UUID><br />
				<DeletionTime>2010-11-12T05:49:57Z</DeletionTime><br />
			</DeletedObject><br />
			<DeletedObject><br />
				<UUID>gimxTDSBBkWdSIFORZUx0w==</UUID><br />
				<DeletionTime>2010-11-12T05:50:02Z</DeletionTime><br />
			</DeletedObject><br />
			<DeletedObject><br />
				<UUID>7/7Rd5KBT0CyY9O9A2RDpA==</UUID><br />
				<DeletionTime>2010-11-12T05:50:05Z</DeletionTime><br />
			</DeletedObject><br />
			<DeletedObject><br />
				<UUID>tPT9aQPrNkOM2mmj6kP3CA==</UUID><br />
				<DeletionTime>2010-11-16T02:58:07Z</DeletionTime><br />
			</DeletedObject><br />
			<DeletedObject><br />
				<UUID>gN/uXsDF206oc1g783tsLQ==</UUID><br />
				<DeletionTime>2010-11-16T02:58:11Z</DeletionTime><br />
			</DeletedObject><br />
			<DeletedObject><br />
				<UUID>jMYxMK3iakOWgPJGVz9lSg==</UUID><br />
				<DeletionTime>2010-11-22T08:55:46Z</DeletionTime><br />
			</DeletedObject><br />
			<DeletedObject><br />
				<UUID>j8UaFYCZbE2drG+gNysIwg==</UUID><br />
				<DeletionTime>2010-11-26T08:30:23Z</DeletionTime><br />
			</DeletedObject><br />
			<DeletedObject><br />
				<UUID>13QkVRyovk+9TNqxneYO5w==</UUID><br />
				<DeletionTime>2010-11-26T08:33:04Z</DeletionTime><br />
			</DeletedObject><br />
			<DeletedObject><br />
				<UUID>1+DFhfzAYUmL74gsRFzZNw==</UUID><br />
				<DeletionTime>2010-12-20T12:41:13Z</DeletionTime><br />
			</DeletedObject><br />
		</DeletedObjects><br />
	</Root><br />
</KeePassFile><br />
[/xml]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1775/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>调查服务器响应时间的利器 tcprstat</title>
		<link>http://www.187299.com/archives/1771</link>
		<comments>http://www.187299.com/archives/1771#comments</comments>
		<pubDate>Fri, 17 Dec 2010 05:05:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1771</guid>
		<description><![CDATA[我们在做服务器程序的时候，经常要知道一个请求的响应时间，借以优化或者定位问题。 通常的做法是在代码里面加入日志计算时间，这个方法有问题，时间不准确。因为数据从网卡到应用程... ]]></description>
			<content:encoded><![CDATA[<p>我们在做服务器程序的时候，经常要知道一个请求的响应时间，借以优化或者定位问题。 通常的做法是在代码里面加入日志计算时间，这个方法有问题，时间不准确。因为数据从网卡到应用程序，从应用到网卡的时间没有被计算在内。 而且这个时间随着系统的负载有很大的变化。<br />
那同学说，我wireshark, tcpdump抓包人肉统计不行吗。 可以的，只不过我会很同情你，此举需要耐心且不具可持续性。 所以我们希望有个工具能够最少费力的做这个事情。</p>
<p>这时候来自percona的tcprstat来救助了！ 这个工具原本开发用来调查mysqld的性能问题，所以不要奇怪它的默认端口是3306, 但是我们可以用这个工具来调查典型的request-&gt;response类型的服务器。</p>
<p>什么是tcprstat:</p>
<p>tcprstat is a free, open-source TCP analysis tool that watches network traffic and computes the delay between requests and responses. From this it derives response-time statistics and prints them out. The output is similar to other Unix -stat tools such as vmstat, iostat, and mpstat. The tool can optionally watch traffic to only a specified port, which makes it practical for timing requests and responses to a single daemon process such as mysqld, httpd, memcached, or any of a variety of other server processes.</p>
<p>文档很详细： 请参考： http://www.percona.com/docs/wiki/tcprstat:start</p>
<p>不愿意编译的同学直接从这里下载64位系统的编译好的二进制： http://github.com/downloads/Lowercases/tcprstat/tcprstat-static.v0.3.1.x86_64</p>
<p>源码编译也挺容易的： 由于它自带libpcap包， 这个包有可能在configure的时候没认识好netlink, 只要把config.h里面的netlink那个define注释掉就好。</p>
<p>编译好了， 典型使用很简单：</p>
<p># tcprstat -p 3306 -t 1 -n 5<br />
timestamp	count	max	min	avg	med	stddev	95_max	95_avg	95_std	99_max	99_avg	99_std<br />
1283261499	1870	559009	39	883	153	13306	1267	201	150	6792	323	685<br />
1283261500	1865	25704	29	578	142	2755	889	175	107	23630	333	1331<br />
1283261501	1887	26908	33	583	148	2761	714	176	94	23391	339	1340<br />
1283261502	2015	304965	35	624	151	7204	564	171	79	8615	237	507<br />
1283261503	1650	289087	35	462	146	7133	834	184	120	3565	244	358</p>
<p>但是这个tcprstat在bonding的网卡下有点问题：</p>
<p># /sbin/ifconfig<br />
bond0 Link encap:Ethernet HWaddr A4:BA:DB:28:B5:AB<br />
inet addr:10.232.31.19 Bcast:10.232.31.255 Mask:255.255.255.0<br />
inet6 addr: fe80::a6ba:dbff:fe28:b5ab/64 Scope:Link<br />
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1<br />
RX packets:19451951688 errors:0 dropped:4512 overruns:0 frame:0<br />
TX packets:26522074966 errors:0 dropped:0 overruns:0 carrier:0<br />
collisions:0 txqueuelen:0<br />
RX bytes:6634368171533 (6.0 TiB) TX bytes:32576206882863 (29.6 TiB)<br />
…<br />
# tcprstat -p 3306 -t 1 -n 5<br />
pcap: SIOCGIFFLAGS: bonding_masters: No such device</p>
<p>解决方案是:</p>
<p># sudo tcprstat -p 3306 -t 1 -n 0 -l `/sbin/ifconfig | grep ‘addr:[^ ]\+’ -o | cut -f 2 -d : | xargs echo | sed -e ’s/ /,/g’`</p>
<p>在典型满负载的mysql服务器上抓包的开销是：</p>
<p>26163 root 18 0 104m 5304 4696 S 18.3 0.0 49:47.58 tcprstat</p>
<p>用IP方式，而不是网络接口方式搞定。</p>
<p>祝大家玩的开心。</p>
<p>转载自：http://rdc.taobao.com/blog/cs/?p=728</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1771/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux下杀僵尸进程办法</title>
		<link>http://www.187299.com/archives/1724</link>
		<comments>http://www.187299.com/archives/1724#comments</comments>
		<pubDate>Fri, 10 Dec 2010 03:09:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1724</guid>
		<description><![CDATA[1) 检查当前僵尸进程信息 # ps -ef &#124; grep defunct &#124; grep -v grep &#124; wc -l 175 # top &#124; head -2 top - 15:05:54 up 97 days, 23:49, 4 users, load average: 0.66, 0.45, 0.39 Tasks: 829 total, 1 running, 479 sleeping, 174 stopped, 175... ]]></description>
			<content:encoded><![CDATA[<p>1) 检查当前僵尸进程信息</p>
<p># ps -ef | grep defunct | grep -v grep | wc -l</p>
<p>175</p>
<p># top | head -2</p>
<p>top - 15:05:54 up 97 days, 23:49,  4 users,  load average: 0.66, 0.45, 0.39</p>
<p>Tasks: 829 total,   1 running, 479 sleeping, 174 stopped, 175 zombie</p>
<p># ps -ef | grep defunct | grep -v grep</p>
<p>2) 获得杀僵尸进程语句</p>
<p># ps -ef | grep defunct | grep -v grep | awk '{print "kill -9 " $2,$3}'</p>
<p>执行上面获得的语句即可, 使用信号量9, 僵尸进程数会大大减少.</p>
<p>3) 过一会儿检查当前僵尸进程信息</p>
<p># ps -ef | grep defunct | grep -v grep | wc -l</p>
<p>125</p>
<p># top | head -2</p>
<p>top - 15:29:26 up 98 days, 12 min,  7 users,  load average: 0.27, 0.54, 0.56</p>
<p>Tasks: 632 total,   1 running, 381 sleeping, 125 stopped, 125 zombie</p>
<p>发现僵尸进程数减少了一些, 但还有不少啊.</p>
<p>4) 再次获得杀僵尸进程语句</p>
<p># ps -ef | grep defunct | grep -v grep | awk '{print "kill -18 " $3}'</p>
<p>执行上面获得的语句即可, 这次使用信号量18杀其父进程, 僵尸进程应该会全部消失.</p>
<p>5) 过一会儿再检查当前僵尸进程信息</p>
<p># ps -ef | grep defunct | grep -v grep | wc -l</p>
<p>0</p>
<p># top | head -2</p>
<p>top - 15:39:46 up 98 days, 23 min,  7 users,  load average: 5.46, 2.20, 1.12</p>
<p>Tasks: 134 total,   1 running, 133 sleeping,   0 stopped,   0 zombie</p>
<p>6) 清除ZOMBIE(僵尸)进程原理</p>
<p># kill -18 PPID</p>
<p>PPID是其父进程, 这个信号是告诉父进程, 该子进程已经死亡了, 请收回分配给他的资源. 如果还不行则看先看其父进程又无其他子进程, 如果有, 可能需要先kill其他子进程, 也就是兄弟进程.</p>
<p>方法是:</p>
<p># kill -15 PID1 PID2</p>
<p>PID1,PID2是僵尸进程的父进程的其它子进程.</p>
<p>然后再kill父进程:</p>
<p># kill -15 PPID</p>
<p>--End--</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1724/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: Linux / UNIX Delete or Remove Files With Inode Number</title>
		<link>http://www.187299.com/archives/1713</link>
		<comments>http://www.187299.com/archives/1713#comments</comments>
		<pubDate>Tue, 16 Nov 2010 04:59:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1713</guid>
		<description><![CDATA[An inode identifies the file and its attributes such as file size, owner, and so on. A unique inode number within the file system identifies each inode. But, why to delete file by an inode number? Sure, you can use rm command to delete file. Sometime acc... ]]></description>
			<content:encoded><![CDATA[<p>An inode identifies the file and its attributes such as file size, owner, and so on. A unique inode number within the file system identifies each inode. But, why to delete file by an inode number? Sure, you can use rm command to delete file. Sometime accidentally you creates filename with control characters or characters which are unable to be input on a keyboard or special character such as ?, * ^ etc. Removing such special character filenames can be problem. Use following method to delete a file with strange characters in its name:</p>
<p>Please note that the procedure outlined below works with Solaris, FreeBSD, Linux, or any other Unixish oses out there:</p>
<p>Find out file inode<br />
First find out file inode number with any one of the following command:</p>
<p>stat {file-name}</p>
<p>OR</p>
<p>ls -il {file-name}</p>
<p>Use find command to remove file:<br />
Use find command as follows to find and remove a file:</p>
<p>find . -inum [inode-number] -exec rm -i {} \;</p>
<p>When prompted for confirmation, press Y to confirm removal of the file.</p>
<p>Delete or remove files with inode number<br />
Let us try to delete file using inode number.</p>
<p>(a) Create a hard to delete file name:<br />
$ cd /tmp<br />
$ touch "\+Xy \+\8"<br />
$ ls<br />
(b) Try to remove this file with rm command:<br />
$ rm \+Xy \+\8</p>
<p>(c) Remove file by an inode number, but first find out the file inode number:<br />
$ ls -ilOutput:</p>
<p>781956 drwx------  3 viv viv 4096 2006-01-27 15:05 gconfd-viv<br />
781964 drwx------  2 viv viv 4096 2006-01-27 15:05 keyring-pKracm<br />
782049 srwxr-xr-x  1 viv viv    0 2006-01-27 15:05 mapping-viv<br />
781939 drwx------  2 viv viv 4096 2006-01-27 15:31 orbit-viv<br />
781922 drwx------  2 viv viv 4096 2006-01-27 15:05 ssh-cnaOtj4013<br />
781882 drwx------  2 viv viv 4096 2006-01-27 15:05 ssh-SsCkUW4013<br />
782263 -rw-r--r--  1 viv viv    0 2006-01-27 15:49 \+Xy \+\8Note: 782263 is inode number.</p>
<p>(d) Use find command to delete file by inode:<br />
Find and remove file using find command, type the command as follows:<br />
$ find . -inum 782263 -exec rm -i {} \;<br />
Note you can also use add \ character before special character in filename to remove it directly so the command would be:<br />
$ rm "\+Xy \+\8"<br />
If you have file like name like name "2005/12/31" then no UNIX or Linux command can delete this file by name. Only method to delete such file is delete file by an inode number. Linux or UNIX never allows creating filename like 2005/12/31 but if you are using NFS from MAC OS or Windows then it is possible to create a such file.</p>
<p>转载自：http://www.cyberciti.biz/tips/delete-remove-files-with-inode-number.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1713/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux : How to delete file securely</title>
		<link>http://www.187299.com/archives/1710</link>
		<comments>http://www.187299.com/archives/1710#comments</comments>
		<pubDate>Tue, 16 Nov 2010 04:55:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1710</guid>
		<description><![CDATA[Recently we had lot of discussion regarding this issue. How to remove files securely so that it cannot be undeleted. Peter Gutmann paper "Secure Deletion of Data from Magnetic and Solid-State Memory" has very good information. Here are some commands/tool... ]]></description>
			<content:encoded><![CDATA[<p>Recently we had lot of discussion regarding this issue. How to remove files securely so that it cannot be undeleted. Peter Gutmann paper "Secure Deletion of Data from Magnetic and Solid-State Memory" has very good information. Here are some commands/tools available under Debian GNU/Linux (it should work with other Linux distributions) to delete file securely.</p>
<p>srm: Securely remove files or directories<br />
This command is a replacement for rm command. It works under Linux/BSD/UNIX-like OSes. It removes each specified file by overwriting, renaming, and truncating it before unlinking. This prevents other people from undelete or recovering any information about the file from the command line. Because it does lots of operation on file/directory for secure deletion, it also takes lot of time to remove it. Download srm from http://sourceforge.net/projects/srm (RPM file is also available for RPM based Linux distributions)</p>
<p>i) Untar and install the srm:</p>
<p># ./configure<br />
# make<br />
# make install ii) How to use srm?<br />
srm syntax is like rm command. Read man srm. Here is simple example:</p>
<p>$ srm privateinfo.docwipe: It is a secure file wiping utility<br />
Download wipe from http://wipe.sourceforge.net/<br />
i) Untar and install the wipe</p>
<p># ./configure<br />
# make<br />
# make installii) How to use wipe?</p>
<p>$ wipe filenameRead man page of wipe for information.</p>
<p>shred: Delete a file securely, first overwriting it to hide its contents.<br />
It is available on most of Linux distributions including Debian GNU/Linux. To remove file called personalinfo.tar.gz :</p>
<p>$ shred -n 200 -z -u  personalinfo.tar.gzWhere,</p>
<p>-n: Overwrite N (200) times instead of the default (25)<br />
-z: Add a final overwrite with zeros to hide shreddin<br />
-u: Truncate and remove file after overwriting<br />
Read the man page of shred(1) for more information. Most of these utilities are not effective (read as useless) only if :</p>
<p>File system is log-structured or journaled filesystems, such as JFS, ReiserFS, XFS, Ext3 etc<br />
Your filesystems is RAID-based, compressed filesystem etc<br />
In addition, file system backups and remote mirrors may contain copies of the file that cannot be removed by these utilities.<br />
See also:</p>
<p><a href="http://www.cyberciti.biz/tips/delete-remove-files-with-inode-number.html" target="_blank">Delete (remove) files with inode number - to remove special character filename</a></p>
<p>转载自：http://www.cyberciti.biz/tips/linux-how-to-delete-file-securely.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1710/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOW-TO:X11 forwarding using ssh, SecureCRT and Xming</title>
		<link>http://www.187299.com/archives/1703</link>
		<comments>http://www.187299.com/archives/1703#comments</comments>
		<pubDate>Wed, 03 Nov 2010 03:56:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1703</guid>
		<description><![CDATA[1. Linux Server's IP:192.168.1.100 2. Install Desktop Enviroment on server 2.1 List software group yum grouplist 2.2 Install Gnome yum groupinstall "GNOME Desktop Environment" 2.3 The server can run in level 3 or level 5.By default,OPENSSH enable X11 for... ]]></description>
			<content:encoded><![CDATA[<p>1. Linux Server's IP:192.168.1.100</p>
<p>2. Install Desktop Enviroment on server</p>
<p>2.1 List software group<br />
yum grouplist</p>
<p>2.2 Install Gnome<br />
yum groupinstall "GNOME Desktop Environment"</p>
<p>2.3 The server can run in level 3 or level 5.By default,OPENSSH enable X11 forward,make sure your /etc/ssh/sshd_config on "X11 forward" look like</p>
<p>X11Forwarding yes</p>
<p>3. Configure Linux client which must run in level 5</p>
<p>3.1 login in the server<br />
[root@client ~]# ssh -X username@192.168.1.100</p>
<p>the output should contain DISPLAY<br />
[root@server_192.168.1.100 ~]# env |grep -i DISPLAY<br />
DISPLAY=localhost:10.0</p>
<p>[root@server_192.168.1.100 ~]# xclock</p>
<p>If you can see a clock,it means that the X11 forward is successful.</p>
<p>4. Configure Windows client<br />
4.1 Install X server : Xming and launch it.<br />
4.2 Install a ssh client,such as SecureCRT,putty.<br />
4.3 Configure SecureCRT<br />
Options--Session Options--Connection--Port Forward--Remote/X11<br />
enable Forward X11 packets,click ok,Connect to the server 192.168.1.100,after login in,also type "env |grep -i DISPLAY" to make sure the desktop enviroment is ok.</p>
<p>type xclock,you will see a clock.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1703/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

