<?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>王永杰的Blog(博客) &#187; 技术为本</title>
	<atom:link href="http://wyj.zhuwo.info/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://wyj.zhuwo.info</link>
	<description>Keep thinking, seeking and practicing!</description>
	<lastBuildDate>Thu, 26 Jan 2012 11:41:13 +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>News: filesystem upgrade &#8211; manual intervention required(ZZ)</title>
		<link>http://wyj.zhuwo.info/2012/01/news-filesystem-upgrade-manual-intervention-requiredzz/</link>
		<comments>http://wyj.zhuwo.info/2012/01/news-filesystem-upgrade-manual-intervention-requiredzz/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 11:41:13 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=346</guid>
		<description><![CDATA[最近用上了archlinux，挺不错，不过升级系统的时候，出现错误，mtab有冲突，如果删除，又会出现空间不够的错误。google到了解决方法，如下： When upgrading to filesystem-2011.12 there will be a conflict with /etc/mtab. Install the package as follows: pacman -S filesystem --force It is strongly advised to avoid the --force or -f switch as it is not safe. However, in this &#8230; <a href="http://wyj.zhuwo.info/2012/01/news-filesystem-upgrade-manual-intervention-requiredzz/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div>
<p>最近用上了archlinux，挺不错，不过升级系统的时候，出现错误，mtab有冲突，如果删除，又会出现空间不够的错误。google到了解决方法，如下：</p>
<p>When upgrading to <code>filesystem-2011.12</code> there will be a conflict with <code>/etc/mtab</code>.</p>
<p>Install the package as follows:</p>
<p><code>pacman -S filesystem --force</code></p>
<p>It is strongly advised to avoid the <code>--force</code> or <code>-f</code> switch as it is not safe. However, in this particular case it is needed as deleting <code>/etc/mtab</code> manually would break pacman.<span id="more-346"></span></p>
<p>The reason for the conflict is that the file used to be generated at  boot and hence not owned by any package. Now it is a symlink to <code>/proc/self/mounts</code> owned by <code>filesystem</code>. This change means that <code>initscripts</code> no longer requires write access to the rootfs (though other packages might).</p>
<p>原文地址：<a href="http://www.archlinux.org/news/filesystem-upgrade-manual-intervention-required/">http://www.archlinux.org/news/filesystem-upgrade-manual-intervention-required/</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2012/01/news-filesystem-upgrade-manual-intervention-requiredzz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>aptitude update &#8211; Error: Connection failed [IP: 127.0.0.1 8080]</title>
		<link>http://wyj.zhuwo.info/2011/10/aptitude-update-error-connection-failed-ip-127-0-0-1-8080/</link>
		<comments>http://wyj.zhuwo.info/2011/10/aptitude-update-error-connection-failed-ip-127-0-0-1-8080/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 03:46:31 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=343</guid>
		<description><![CDATA[最近ubuntu一直无法更新，开始也没注意，过去很久了一直不能更新。今天抽空看了一下，原来是proxy的问题。 错误提示是：Connection failed [IP: 127.0.0.1 8080] 解决办法是： 将/etc/apt/apt.conf文件里面有关代理的设置删掉。 OK。]]></description>
			<content:encoded><![CDATA[<p>最近ubuntu一直无法更新，开始也没注意，过去很久了一直不能更新。今天抽空看了一下，原来是proxy的问题。</p>
<p>错误提示是：Connection failed [IP: 127.0.0.1 8080]</p>
<p>解决办法是：</p>
<p>将/etc/apt/apt.conf文件里面有关代理的设置删掉。</p>
<p>OK。</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/10/aptitude-update-error-connection-failed-ip-127-0-0-1-8080/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get Serial Number, Mac, or ANDROID ID of an Android Device(ZZ)</title>
		<link>http://wyj.zhuwo.info/2011/08/how-to-get-serial-number-mac-or-android-id-of-an-android-devicezz/</link>
		<comments>http://wyj.zhuwo.info/2011/08/how-to-get-serial-number-mac-or-android-id-of-an-android-devicezz/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 08:42:00 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[技术为本]]></category>
		<category><![CDATA[文摘转贴]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=339</guid>
		<description><![CDATA[Hi, I think many of you thought which is best to retrieve from the Android Device, so that you can be sure the device will not trick you and the identifier you asked is unique and unchangeable. For example we &#8230; <a href="http://wyj.zhuwo.info/2011/08/how-to-get-serial-number-mac-or-android-id-of-an-android-devicezz/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
I think many of you thought which is best to retrieve from the Android  Device, so that you can be sure the device will not trick you and the  identifier you asked is unique and unchangeable.<br />
For example we can get the IMEI code but users would became suspicious  because you will need to set a permission to use this, and beside this  IMEI have only phones, not tablets.<br />
You may choose to retrive ANDROID_ID with the following code:<span id="more-339"></span></p>
<div>
<div>
<pre>String deviceId = Settings.System.getString(getContentResolver(),
                                Settings.System.ANDROID_ID);</pre>
</div>
</div>
<p>But this is documented to be changeable at the factory reset and unpredictive changeable on rooted phones.<br />
Other option would be to get a Serial Number:</p>
<div>
<div>
<pre>TelephonyManager manager= (TelephonyManager)myActivity.getSystemService(Context.TELEPHONY_SERVICE);
String serial= manager.getDeviceId();</pre>
</div>
</div>
<p>This will need permission: android.permission.READ_PHONE_STATE</p>
<p>getDeviceID() will return the MDN or MEID of the device depending on which radio the phone uses (GSM or CDMA).</p>
<p>As you already guess this option have the same disadvantage(DON’ T WORK FOR TABLETS ).<br />
We have one last solution and maybe it’ s the best, since over 95% of Android Powered Devices have a wireless card.<br />
So we will retrieve the MAC address:</p>
<div>
<div>
<pre>WifiManager wimanager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
String address= wimanager.getConnectionInfo().getMacAddress();</pre>
</div>
</div>
<p>This will need permission: android.permission.ACCESS_WIFI_STATE<br />
WiFi MAC address can be easily faked  on rooted phones, so we have another unique serial number on Bluetooth.<br />
Code for retrieving Bluetooth unique identifier:</p>
<div>
<div>
<pre>BluetoothAdapter btAdapt= null;
    	btAdapt = BluetoothAdapter.getDefaultAdapter();
    	String address= btAdapt.getAddress();</pre>
</div>
</div>
<p>This code will need permission: android.permission.BLUETOOTH</p>
<p>转自：<a href="http://androidgenuine.com/?tag=get-mac-address-android">http://androidgenuine.com/?tag=get-mac-address-android</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/08/how-to-get-serial-number-mac-or-android-id-of-an-android-devicezz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>关于waitForCondition导致死锁的问题(zz)</title>
		<link>http://wyj.zhuwo.info/2011/08/%e5%85%b3%e4%ba%8ewaitforcondition%e5%af%bc%e8%87%b4%e6%ad%bb%e9%94%81%e7%9a%84%e9%97%ae%e9%a2%98zz/</link>
		<comments>http://wyj.zhuwo.info/2011/08/%e5%85%b3%e4%ba%8ewaitforcondition%e5%af%bc%e8%87%b4%e6%ad%bb%e9%94%81%e7%9a%84%e9%97%ae%e9%a2%98zz/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 07:26:37 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[技术为本]]></category>
		<category><![CDATA[文摘转贴]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=336</guid>
		<description><![CDATA[waitForCondition 基本都出现在继承了类 GLSurfaceView 的情况下 , 出现死锁的位置一般是引用 egl.eglCreateWindowSurface(&#8230;) 或者 mEgl.eglSwapBuffers(&#8230;) 这两个方法的时候 . 避免出现 waitForCondition 的方法总结 : 在绘制线程中必须先合法的获取Surface 才能开始绘制内容，在SurfaceHolder.Callback.surfaceCreated() 和SurfaceHolder.Callback.surfaceDestroyed() 之间的状态为合法的，另外在Surface 类型为 SURFACE_TYPE_PUSH_BUFFERS 时候是不合法的. 由于绘制是由绘制线程处理的，所以当主进程在调用surfaceCreated ，surfaceDestroyed ，onPause ，onResume ，onWindowFocusChanged ，onWindowResize ，requestExitAndWait ，queueEvent ，getEvent 时，都会访问绘制线程，所以这些方法需要使用同步关键字synchronized 锁定绘制线程, 主线程必需要等待绘制线程执行完相应的方法后，再 继续执行。 尽量将与 buffer 有关的操作放在 synchronized 同步块内 , &#8230; <a href="http://wyj.zhuwo.info/2011/08/%e5%85%b3%e4%ba%8ewaitforcondition%e5%af%bc%e8%87%b4%e6%ad%bb%e9%94%81%e7%9a%84%e9%97%ae%e9%a2%98zz/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p lang="zh-CN">waitForCondition    基本都出现在继承了类  GLSurfaceView    的情况下  ,     出现死锁的位置一般是引用  egl.eglCreateWindowSurface(&#8230;)     或者   mEgl.eglSwapBuffers(&#8230;)     这两个方法的时候  .</p>
<p><strong>避免出现</strong> <strong>waitForCondition</strong> <strong>的方法总结</strong> <strong>:</strong></p>
<ol>
<li>在绘制线程中必须先合法的获取Surface  才能开始绘制内容，在SurfaceHolder.Callback.surfaceCreated() 	  和SurfaceHolder.Callback.surfaceDestroyed()  之间的状态为合法的，另外在Surface  类型为 	SURFACE_TYPE_PUSH_BUFFERS  时候是不合法的.<span id="more-336"></span></li>
<li>由于绘制是由绘制线程处理的，所以当主进程在调用surfaceCreated  ，surfaceDestroyed  ，onPause  ，onResume  ，onWindowFocusChanged  ，onWindowResize  ，requestExitAndWait  ，queueEvent  ，getEvent  时，都会访问绘制线程，所以这些方法需要使用同步关键字synchronized  锁定绘制线程,  主线程必需要等待绘制线程执行完相应的方法后，再  继续执行。</li>
<li>尽量将与  buffer  有关的操作放在  synchronized 同步块内 , 比如刷新缓冲区的操作glFinish()和   glSwapBuffer() 	.</li>
</ol>
<p>注  : <em>SURFACE_TYPE_PUSH_BUFFERS</em> ：表明该Surface  不包含原生数据，Surface  用到的数据由其他对象提供，在 Camera  图像预览中就使用该类型的Surface  ，有Camera  负责提供给预览Surface  数据，这样图像预览会比较流畅。如果设置这种类型则就 不能调用lockCanvas  来获取Canvas  对象了。</p>
<p lang="zh-CN"><strong>出现</strong> <strong>waitForCondition</strong> <strong>后可尝试的调试方法:</strong></p>
<p lang="zh-CN"><strong>如果问题是可复现的:</strong></p>
<ol>
<li>查看是否在  surfaceCreated()  和  surfaceDestroyed()  方法之外对  surface  进行了绘制及  lockCanvas  等操作  . 	  查看是否在  surfaceCreate()  方法成功创建  surface  之前就开始了绘制工作  .</li>
<li>重点检查窗口改变状态时的代码  , 	  比如窗口大小改变  , 	  由横屏变竖屏等情况  , 	  此时对某一帧的渲染可能与窗口的销毁  /  重建同时进行  , 	  从而导致  waitForCondition. 	  用  synchronized  关键字对  Surface  等资源进行同步  .</li>
<li>注意  GLSurfaceView  中的  onPause()  方法  . 	  在执行  pause  动作时确保绘制线程已经停止绘制  ,可使用线程类的join()方法.</li>
</ol>
<p lang="zh-CN"><strong>如果问题是无规律随机出现的(一般很难彻底解决)</strong> <strong>:</strong></p>
<ol>
<li>注意主线程和绘制线程的同步. 	  使绘制线程最大限度的  做到线程安全. 	  尽量  对onDrawFrame    () 	  方法中接触到的变量加锁同步  .</li>
<li>尝试  在绘制结束后及时刷新帧缓冲区, 	  强制buffer  内的内容刷新至屏幕, 	  即强制SharedBufferClient/SharedBufferServer      做到同步  . 	   在onDrawFrame()   方法中  , 	  绘制结束时可尝试  利用glFinish() 	, glWaitGL()  或 glSwapBuffer() 	  等  刷新缓冲区. 	  这样做会降低帧率, 	  使性能下降.使用这种方法也有可能使问题更加恶化&#8230;</li>
</ol>
<p>转自：<a href="http://blog.csdn.net/liuxu0703/article/details/6128842">http://blog.csdn.net/liuxu0703/article/details/6128842</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/08/%e5%85%b3%e4%ba%8ewaitforcondition%e5%af%bc%e8%87%b4%e6%ad%bb%e9%94%81%e7%9a%84%e9%97%ae%e9%a2%98zz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MD5 算法 (The MD5 Message-Digest Algorithm)</title>
		<link>http://wyj.zhuwo.info/2011/06/the-md5-message-digest-algorithm/</link>
		<comments>http://wyj.zhuwo.info/2011/06/the-md5-message-digest-algorithm/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 03:13:44 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[C&C++]]></category>
		<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=333</guid>
		<description><![CDATA[MD5即Message-Digest Algorithm 5（信息-摘要算法 5），用于确保信息传输完整一致。是计算机广泛使用的雜湊算法之一（又译摘要算法、哈希算法），主流编程语言普遍已有MD5实现。 在维基百科上有详细介绍，在各种语言上也都已有相应实现。 http://www.ietf.org/rfc/rfc1321.txt 上给出了算法介绍和C语言的实现。 我们在使用过程中发现一个问题，就是计算出来的MD5值有误。 经过调查，并非算法有问题，而是因为机器是64位系统导致的，在32位系统上就没问题。 为了通用性，只要把md5.h中的41行，修改一下就可以了。 typedef unsigned int UINT4;]]></description>
			<content:encoded><![CDATA[<p><strong>MD5</strong>即Message-Digest Algorithm 5（信息-摘要<a title="算法" href="http://zh.wikipedia.org/wiki/%E7%AE%97%E6%B3%95">算法</a> 5），用于确保信息传输完整一致。是计算机广泛使用的雜湊算法之一（又译<strong><a title="摘要算法" href="http://zh.wikipedia.org/w/index.php?title=%E6%91%98%E8%A6%81%E7%AE%97%E6%B3%95&amp;action=edit&amp;redlink=1">摘要算法</a></strong>、哈希算法），主流编程语言普遍已有MD5实现。</p>
<p>在维基百科上有详细介绍，在各种语言上也都已有相应实现。<br />
<a href="http://www.ietf.org/rfc/rfc1321.txt">http://www.ietf.org/rfc/rfc1321.txt</a> 上给出了算法介绍和C语言的实现。<br />
我们在使用过程中发现一个问题，就是计算出来的MD5值有误。<br />
经过调查，并非算法有问题，而是因为机器是64位系统导致的，在32位系统上就没问题。<br />
为了通用性，只要把md5.h中的41行，修改一下就可以了。<br />
typedef unsigned int UINT4;</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/06/the-md5-message-digest-algorithm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一个简单的 makefile 模板</title>
		<link>http://wyj.zhuwo.info/2011/05/a-simple-makefile-template/</link>
		<comments>http://wyj.zhuwo.info/2011/05/a-simple-makefile-template/#comments</comments>
		<pubDate>Mon, 23 May 2011 09:03:27 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[C&C++]]></category>
		<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=330</guid>
		<description><![CDATA[一个简单的 makefile 模板， CC = gcc CFLAGS+=-c -Wall -I[include_path] LDFLAGS+= -lm SOURCES= \ main.c \ OBJECTS=$(SOURCES:.c=.o) EXECUTABLE=test all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) -o $@ .c.o: $(CC) $(CFLAGS) $&#60; -o $@ .PHONY: clean clean: rm -f $(EXECUTABLE) $(OBJECTS)]]></description>
			<content:encoded><![CDATA[<p>一个简单的 makefile 模板，</p>
<pre>CC = gcc

CFLAGS+=-c -Wall -I[include_path]
LDFLAGS+= -lm

SOURCES= \
		 main.c \

OBJECTS=$(SOURCES:.c=.o)

EXECUTABLE=test

all: $(SOURCES) $(EXECUTABLE) 

$(EXECUTABLE): $(OBJECTS)
	$(CC) $(LDFLAGS) $(OBJECTS) -o $@

.c.o:
	$(CC) $(CFLAGS) $&lt; -o $@

.PHONY: clean
clean:
	rm -f $(EXECUTABLE) $(OBJECTS)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/05/a-simple-makefile-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Undefined reference to &#8216;pow()&#8217; using  (ZZ)</title>
		<link>http://wyj.zhuwo.info/2011/05/undefined-reference-to-pow-using-zz/</link>
		<comments>http://wyj.zhuwo.info/2011/05/undefined-reference-to-pow-using-zz/#comments</comments>
		<pubDate>Mon, 23 May 2011 08:59:03 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[C&C++]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=328</guid>
		<description><![CDATA[加上 flag -lm 即可。]]></description>
			<content:encoded><![CDATA[<p>加上 flag -lm 即可。</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/05/undefined-reference-to-pow-using-zz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extra Keyboard Keys</title>
		<link>http://wyj.zhuwo.info/2011/05/extra-keyboard-keys/</link>
		<comments>http://wyj.zhuwo.info/2011/05/extra-keyboard-keys/#comments</comments>
		<pubDate>Tue, 17 May 2011 03:04:35 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=325</guid>
		<description><![CDATA[简介 许多键盘都有一些&#8221;特殊按键&#8221;(也叫热键)，用于执行某个应用程序或者输入那些不被包含在标准键盘映射表中的特殊字符。由于没有相应的规格标准，内核无法知道如何处处理它们，这也是为什么我们需要(手工的)将这些按键映射到特定的动作。我们有两种方法来实现： 通用的做法，使用HAL和Xorg提供的工具 (最终被桌面环境工具利用到) 更快的方式，使用第三方程序在图形界面中完成所有配置 也许出乎你的想象，第一种方法更受亲睐，因为HAL和Xorg较之任何第三方程序都更加通用和普适。 如果你赶时间只想让按键工作，这里有2种情况： 你使用Gnome： 所有配置都可以在控制中心完成。 你使用KDE或其他不支持内核级别的额外按键侦测： 使用第三方程序，推荐keytouch。 Arch的方式 前言 开始之前，你需要学习一些(新)词汇&#8230; scancode是一个键的最小识别ID。如果一个键没有scancode值，我们无法做任何事，因为内核看不到它。 keycode是一个键的第二级识别ID，对应到一个函数。 symbol是一个键的第三级识别ID，Xorg通过该ID引用按键。 第一步： 映射scancode 如果你使用HAL那么你的大部分按键应该已经有keycode了。如果没有，请想着帮助社区扩充(按键)数据库。 诊断 使用showkey 通常来说，使用showkey程序可以知道你的按键是否拥有一个keycode。使用showkey程序后，你可以按下 一个按键来查看屏幕上的输出，如果什么都不做，程序将在10秒后退出，这也是退出showkey程序的唯一方法。你需要在一个真正的控制台下执行 showkey程序，就是说你得切出图形界面，用ctrl+alt+F1组合键就能回到命令行的界面了。 $ showkey 尝试按下你的按键。如果有keycode输出则说明这个键是被映射了的。如果没有，啊，真是一个悲剧。这说明内核认不出这个键或者是这个按键还没被映射。 Using xev Another way to get the keycodes of your keys is &#8230; <a href="http://wyj.zhuwo.info/2011/05/extra-keyboard-keys/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>简介</h1>
<p>许多键盘都有一些&#8221;特殊按键&#8221;(也叫热键)，用于执行某个应用程序或者输入那些不被包含在标准键盘映射表中的特殊字符。由于没有相应的规格标准，内核无法知道如何处处理它们，这也是为什么我们需要(手工的)将这些按键映射到特定的动作。我们有两种方法来实现：</p>
<ul>
<li>通用的做法，使用<a title="HAL" href="https://wiki.archlinux.org/index.php/HAL">HAL</a>和<a title="Xorg" href="https://wiki.archlinux.org/index.php/Xorg">Xorg</a>提供的工具 (最终被桌面环境工具利用到)</li>
<li>更快的方式，使用第三方程序在图形界面中完成所有配置</li>
</ul>
<p>也许出乎你的想象，第一种方法更受亲睐，因为<a title="HAL" href="https://wiki.archlinux.org/index.php/HAL">HAL</a>和<a title="Xorg" href="https://wiki.archlinux.org/index.php/Xorg">Xorg</a>较之任何第三方程序都更加通用和普适。<span id="more-325"></span></p>
<p><strong>如果你赶时间</strong>只想让按键工作，这里有2种情况：</p>
<ul>
<li>你使用Gnome：</li>
</ul>
<p>所有配置都可以在控制中心完成。</p>
<ul>
<li>你使用KDE或其他不支持内核级别的额外按键侦测：</li>
</ul>
<p>使用第三方程序，推荐<a title="Keytouch" href="https://wiki.archlinux.org/index.php/Keytouch">keytouch</a>。</p>
<h1>Arch的方式</h1>
<h2>前言</h2>
<p>开始之前，你需要学习一些(新)词汇&#8230;</p>
<p><strong>scancode</strong>是一个键的最小识别ID。如果一个键没有scancode值，我们无法做任何事，因为内核看不到它。</p>
<p><strong>keycode</strong>是一个键的第二级识别ID，对应到一个函数。</p>
<p><strong>symbol</strong>是一个键的第三级识别ID，Xorg通过该ID引用按键。</p>
<h2>第一步： 映射scancode</h2>
<p>如果你使用<a title="HAL" href="https://wiki.archlinux.org/index.php/HAL">HAL</a>那么你的大部分按键应该已经有keycode了。如果没有，请想着帮助社区扩充(按键)数据库。</p>
<h3>诊断</h3>
<h4>使用showkey</h4>
<p>通常来说，使用<code>showkey</code>程序可以知道你的按键是否拥有一个keycode。使用showkey程序后，你可以按下 一个按键来查看屏幕上的输出，如果什么都不做，程序将在10秒后退出，这也是退出showkey程序的唯一方法。你需要在一个真正的控制台下执行 showkey程序，就是说你得切出图形界面，用ctrl+alt+F1组合键就能回到命令行的界面了。</p>
<pre> $ showkey
</pre>
<p>尝试按下你的按键。如果有keycode输出则说明这个键是被映射了的。如果没有，啊，真是一个悲剧。这说明内核认不出这个键或者是这个按键还没被映射。</p>
<h4>Using xev</h4>
<p>Another way to get the keycodes of your keys is to use the graphical X  program &#8220;xev&#8221; (without having to switch to a console environment). With  the following line you can start xev and directly grep the important  parts:</p>
<pre>$ xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'
</pre>
<p>In the example below I pressed the &#8220;a&#8221;, &#8220;r&#8221;, &#8220;c&#8221; and &#8220;h&#8221; keys and two  of the media keys on my Dell keyboard. This gives me the following  output:</p>
<pre>38 a
27 r
54 c
43 h
153 NoSymbol
144 NoSymbol
</pre>
<p>This means that the &#8220;a&#8221;, &#8220;r&#8221;, &#8220;c&#8221; and &#8220;h&#8221; keys have the keycodes 38,  27, 54 and 43 and are properly bound while the media keys with the  keycodes 153 and 144 have no function yet, which is indicated by  &#8220;NoSymbol&#8221;. If you press a key and nothing appears in the terminal, this  means that the kernel doesn&#8217;t see that key or that it is not mapped.</p>
<h4>2.6 kernels</h4>
<p>According to the keymap man page:</p>
<div><strong> Note: </strong>In   2.6  kernels  raw  mode, or scancode mode, is not very raw at all.   Scan codes are first translated to key codes, and when scancodes are  desired the key codes are translated  back. Various transformations are  involved, and there is no guarantee at all that the final result  corresponds to what the keyboard hardware did send.</div>
<p>This is relevant if the keymaps obtained from showkey and the ones set by <a title="Setkeycodes" href="https://wiki.archlinux.org/index.php/Setkeycodes">setkeycodes</a> differ from the ones obtained by xev in X. Keep this in mind when translating the keymaps into keysyms using xmodmap (See <a title="Extra Keyboard Keys in Xorg" href="https://wiki.archlinux.org/index.php/Extra_Keyboard_Keys_in_Xorg">Extra Keyboard Keys in Xorg</a>).</p>
<h4>Conclusion</h4>
<p>If all your keys have a keycode you can go directly to the second step.</p>
<p>If not keep reading below:</p>
<h3>Know if a key has a scancode</h3>
<p>If a key doesn&#8217;t have a keycode you can know if it has a scancode by looking at the kernel log using the dmesg command:</p>
<pre>$ dmesg|tail -5
</pre>
<p>If when you press the key something like that appears:</p>
<pre>atkbd.c: Unknown key pressed (translated set 2, code 0xf1 on isa0060/serio0).
atkbd.c: Use 'setkeycodes e071 &lt;keycode&gt;' to make it known.
</pre>
<p>then your key has a scancode which can be mapped to a keycode. See <a title="Map scancodes to keycodes" href="https://wiki.archlinux.org/index.php/Map_scancodes_to_keycodes">Map scancodes to keycodes</a>.</p>
<p>If nothing new appears in dmesg then your key doesn&#8217;t have a  scancode which means that it is not recognized by the kernel so it  cannot be used.</p>
<h3>Map scancodes to keycodes</h3>
<p><em>See the detailed article: <a title="Map scancodes to keycodes" href="https://wiki.archlinux.org/index.php/Map_scancodes_to_keycodes">Map scancodes to keycodes</a>.</em></p>
<h2>Step 2: Map keycodes</h2>
<h3>In Console</h3>
<p>When we are in console, we can use our hotkeys to print a certain  character. Moreover we can also print a sequence of characters and some  escape sequences. Thus, if we print the sequence of characters  constituting a command and afterwards an escape character for a new  line, that command will be executed!</p>
<p><em>See the detailed article: <a title="Extra Keyboard Keys in Console" href="https://wiki.archlinux.org/index.php/Extra_Keyboard_Keys_in_Console">Extra Keyboard Keys in Console</a>.</em></p>
<h3>In Xorg</h3>
<p>When we are in a graphical environment we may want a key to print a  special character or execute a command. There are many ways of doing  that and they are covered in a dedicated article: <a title="Extra Keyboard Keys in Xorg" href="https://wiki.archlinux.org/index.php/Extra_Keyboard_Keys_in_Xorg">Extra Keyboard Keys in Xorg</a>.</p>
<h1>The quick way</h1>
<h2>In Gnome</h2>
<p>If you use Gnome everything can be done from the Control Center.  However if you decide to change for another Desktop Environment you&#8217;ll  have to re-configure your keys.</p>
<h2>In Xmonad</h2>
<p>If you use Xmonad as a stand alone window manager, you can edit the  xmonad.hs to add unbinded keyboard keys. You just need to find the Xf86  name of the key (such as XF86PowerDown) and look it up in  /usr/include/X11/XF86keysym.h it will give you a keycode like  0x1008FF2A. than using that keycode you can just add a line like the  following in the keybindings section of your xmonad.hs</p>
<pre>((0,               0x1008FF2A), spawn "sudo pm-suspend")
</pre>
<h2>In other desktops environments</h2>
<p>In desktop environments that can&#8217;t read scancodes and/or keycodes you can use one of the following third-party softwares:</p>
<h3>keytouch</h3>
<p>KeyTouch is a program which allows you to easily configure the extra  function keys of your keyboard. This means that you can define, for  every individual function key, what to do if it is pressed.</p>
<p><em>See the detailed article: <a title="Keytouch" href="https://wiki.archlinux.org/index.php/Keytouch">keytouch</a>.</em></p>
<h3>lineak</h3>
<div><strong> Note: </strong>Lineak is not really an active project. If you really want to use a third-party program you are encouraged to use <a title="Keytouch" href="https://wiki.archlinux.org/index.php/Keytouch">keytouch</a> instead.</div>
<p>Lineak is a utility designed to enable the use and configuration of internet, easy access and multimedia keys.</p>
<h1>Laptops</h1>
<h2>Asus M series</h2>
<p>I think it&#8217;ll be work in another series with Asus product of laptops.  How to make work multimedia keys on Arch? And disable light sensor?  It&#8217;s very simple, login as root, edit:</p>
<pre>$ /etc/rc.local
</pre>
<p>add only one line:</p>
<pre>$ echo 0 &gt; /sys/devices/platform/asus-laptop/ls_switch
</pre>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/05/extra-keyboard-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keyboard scancode and keycode</title>
		<link>http://wyj.zhuwo.info/2011/05/keyboard-scancode-and-keycode/</link>
		<comments>http://wyj.zhuwo.info/2011/05/keyboard-scancode-and-keycode/#comments</comments>
		<pubDate>Mon, 16 May 2011 09:13:52 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=323</guid>
		<description><![CDATA[列举几个有关scancode和keycode的资源，备用，还没有仔细研究。 http://www.win.tue.nl/~aeb/linux/kbd/scancodes.html https://bbs.archlinux.org/viewtopic.php?id=43662 http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlkeycodes.html]]></description>
			<content:encoded><![CDATA[<p>列举几个有关scancode和keycode的资源，备用，还没有仔细研究。</p>
<p>http://www.win.tue.nl/~aeb/linux/kbd/scancodes.html</p>
<p>https://bbs.archlinux.org/viewtopic.php?id=43662</p>
<p>http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlkeycodes.html</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/05/keyboard-scancode-and-keycode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>merge Android 的 kernel 代码 by Git-Rebase</title>
		<link>http://wyj.zhuwo.info/2011/04/merge-android-kernel-by-git-rebase%e3%80%82/</link>
		<comments>http://wyj.zhuwo.info/2011/04/merge-android-kernel-by-git-rebase%e3%80%82/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 09:32:36 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>
		<category><![CDATA[配置管理]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=320</guid>
		<description><![CDATA[為了玩 Android，學會了 git 的初步使用。不過僅止於基本的 git checkout、git log、git diff、git status、git commit 等。 這幾天為了協助同事將 Android 移植到廠商的板子上，必須將廠商提供的 kernel 與 Android kernel 做結合。為此請教一些 git 高手。經過一番練習，總算對 git rebase 的使用有了初步的掌握。也漸漸了解了 git 的強大威力，為什麼高手都愛用… 特別將這段經驗記載在這邊，給有興趣的人參考。 有兩個 git repositories 要做合併。一個是廠商提供的 kernel： git://git.kernel.org/pub/scm/linux/kernel/git/kki_ap/samsung-ap-2.6.git 另一個是 Android 的 kernel： git://android.git.kernel.org/kernel/common.git 首先，先建立一個工作目錄 $ mkdir &#8230; <a href="http://wyj.zhuwo.info/2011/04/merge-android-kernel-by-git-rebase%e3%80%82/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>為了玩 Android，學會了 <a href="http://www.git-scm.org/">git</a> 的初步使用。不過僅止於基本的 git checkout、git log、git diff、git status、git commit 等。</p>
<p>這幾天為了協助同事將 Android 移植到廠商的板子上，必須將廠商提供的 kernel 與 Android kernel 做結合。為此請教一些 git 高手。經過一番練習，總算對 git rebase 的使用有了初步的掌握。也漸漸了解了 git 的強大威力，為什麼高手都愛用… 特別將這段經驗記載在這邊，給有興趣的人參考。<span id="more-320"></span></p>
<p>有兩個 git repositories 要做合併。一個是廠商提供的 kernel：</p>
<blockquote><p>git://git.kernel.org/pub/scm/linux/kernel/git/kki_ap/samsung-ap-2.6.git</p></blockquote>
<p>另一個是 Android 的 kernel：</p>
<blockquote><p>git://android.git.kernel.org/kernel/common.git</p></blockquote>
<p>首先，先建立一個工作目錄</p>
<table>
<tbody>
<tr>
<td>
<pre>$ mkdir kernel-git
$ cd kernel-git
$ git init
Initialized empty Git repository in /home/cwhuang/git/kernel-git/.git/
</pre>
</td>
</tr>
</tbody>
</table>
<p>然後加入兩個遠端的 repositories：</p>
<table>
<tbody>
<tr>
<td>
<pre>$ git remote add samsung git://git.kernel.org/pub/scm/linux/kernel/git/kki_ap/samsung-ap-2.6.git
$ git remote add android git://android.git.kernel.org/kernel/common.git
</pre>
</td>
</tr>
</tbody>
</table>
<p>將遠端 repositories 的資料取回：</p>
<table>
<tbody>
<tr>
<td>
<pre>$ git fetch samsung
remote: Counting objects: 11677, done.
remote: Compressing objects: 100% (2462/2462), done.
remote: Total 10383 (delta 7976), reused 10138 (delta 7743)
Receiving objects: 100% (10383/10383), 5.04 MiB, done.
Resolving deltas: 100% (7976/7976), completed with 324 local objects.
From git://git.kernel.org/pub/scm/linux/kernel/git/kki_ap/samsung-ap-2.6.git
 * [new branch]      master     -&gt; samsung/master
 * [new tag]         v2.6.28.6-samsung-v1 -&gt; v2.6.28.6-samsung-v1
From git://git.kernel.org/pub/scm/linux/kernel/git/kki_ap/samsung-ap-2.6.git
 * [new tag]         v2.6.28-rc4-s3c64xx -&gt; v2.6.28-rc4-s3c64xx
 * [new tag]         v2.6.28-rc4-s5pc1xx -&gt; v2.6.28-rc4-s5pc1xx
 * [new tag]         v2.6.28-rc5-s3c64xx -&gt; v2.6.28-rc5-s3c64xx
 * [new tag]         v2.6.28-rc5-s5pc1xx -&gt; v2.6.28-rc5-s5pc1xx
 * [new tag]         v2.6.28-rc6-s3c64xx -&gt; v2.6.28-rc6-s3c64xx
 * [new tag]         v2.6.28-rc6-s5pc1xx -&gt; v2.6.28-rc6-s5pc1xx
 * [new tag]         v2.6.28-rc7-s3c64xx -&gt; v2.6.28-rc7-s3c64xx
 * [new tag]         v2.6.28-rc7-s5pc1xx -&gt; v2.6.28-rc7-s5pc1xx
 * [new tag]         v2.6.28-rc8-s3c64xx -&gt; v2.6.28-rc8-s3c64xx
 * [new tag]         v2.6.28-rc8-s5pc1xx -&gt; v2.6.28-rc8-s5pc1xx
 * [new tag]         v2.6.28-rc8-s5pc1xx-v1 -&gt; v2.6.28-rc8-s5pc1xx-v1
 * [new tag]         v2.6.28.6-samsung -&gt; v2.6.28.6-samsung

$ git fetch android
remote: Counting objects: 1077412, done.
remote: Compressing objects: 100% (176782/176782), done.
Receiving objects: 100% (1077412/1077412), 263.30 MiB | 28369 KiB/s, done.
remote: Total 1077412 (delta 896526), reused 1076403 (delta 895639)
Resolving deltas: 100% (896526/896526), done.
From git://android.git.kernel.org/kernel/common.git
 * [new branch]      2.6.27     -&gt; android/2.6.27
 * [new branch]      2.6.29     -&gt; android/2.6.29
From git://android.git.kernel.org/kernel/common.git
 * [new tag]         v2.6.12    -&gt; v2.6.12
 * [new tag]         v2.6.12-rc2 -&gt; v2.6.12-rc2
(skipped...)
 * [new tag]         v2.6.29-rc8 -&gt; v2.6.29-rc8
</pre>
</td>
</tr>
</tbody>
</table>
<p>看看有哪些 branches?</p>
<table>
<tbody>
<tr>
<td>
<pre>$ git branch -a
  android/2.6.27
  android/2.6.29
  samsung/master
</pre>
</td>
</tr>
</tbody>
</table>
<p>在合併之前，先了解一下已存在的 branches。我們可以先看看這些 branches 的共同祖先(common ancestor)：</p>
<table>
<tbody>
<tr>
<td>
<pre>$ git merge-base samsung/master android/2.6.27
3fa8749e584b55f1180411ab1b51117190bac1e5

$ git show 3fa8749e584b55f1180411ab1b51117190bac1e5
commit 3fa8749e584b55f1180411ab1b51117190bac1e5
Author: Linus Torvalds
Date:   Thu Oct 9 15:13:53 2008 -0700

    Linux 2.6.27

diff --git a/Makefile b/Makefile
index ce9eceb..16e3fbb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 6
 SUBLEVEL = 27
-EXTRAVERSION = -rc9
+EXTRAVERSION =
 NAME = Rotary Wombat

 # *DOCUMENTATION*

$ git merge-base samsung/master android/2.6.29
4a6908a3a050aacc9c3a2f36b276b46c0629ad91

$ git show 4a6908a3a050aacc9c3a2f36b276b46c0629ad91
commit 4a6908a3a050aacc9c3a2f36b276b46c0629ad91
Author: Linus Torvalds
Date:   Wed Dec 24 15:26:37 2008 -0800

    Linux 2.6.28

    Happy holidays..

diff --git a/Makefile b/Makefile
index 4c8d797..71e98e9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 6
 SUBLEVEL = 28
-EXTRAVERSION = -rc9
+EXTRAVERSION =
 NAME = Erotic Pickled Herring

 # *DOCUMENTATION*
</pre>
</td>
</tr>
</tbody>
</table>
<p>因此 branch samsung/master 和 android/2.6.27 都是從 v2.6.27 來的，而 samsung/master 和 android/2.6.29 則從 v2.6.28 而來。事實上，不難驗證 samsung/master 是從 v2.6.28.6 改來的。</p>
<p>可以用 gitk 這個圖形化工具來看看從 v2.6.27 到 android/2.6.27 的變化：</p>
<table>
<tbody>
<tr>
<td>
<pre>$ gitk v2.6.27..android/2.6.27
</pre>
</td>
</tr>
</tbody>
</table>
<p>同樣的，samsung/master 的變化是：</p>
<table>
<tbody>
<tr>
<td>
<pre>$ gitk v2.6.28..samsung/master
</pre>
</td>
</tr>
</tbody>
</table>
<p>我們要決定如何進行合併。可以將 samsung 的修改合併到 Android kernel，也可以將 Android 的修改合併到 samsung kernel。我決定選擇後者，因為從 gitk 可以看出 Android 的變化相當簡單而清楚，就是單線發展而已。相對的，samsung kernel 就併來併去，線條亂七八糟，看得眼花瞭亂。因此將 Android 的修改併到 samsung kernel，應該比較簡單而容易成功。</p>
<p>可以用 git rebase 來進行合併。首先，建立一個新的本地 branch 來保存合併結果：</p>
<table>
<tbody>
<tr>
<td>
<pre>$ git branch --track samsung-android samsung/master
</pre>
</td>
</tr>
</tbody>
</table>
<p>然後用 git rebase 指令，將 v2.6.27 到 android/2.6.27 的修改，一個一個的 apply 到 samsung-android 這個 branch 中：</p>
<table>
<tbody>
<tr>
<td>
<pre>$ git rebase --whitespace=fix --onto samsung-android v2.6.27 android/2.6.27
First, rewinding head to replay your work on top of it...
Applying: PM: Add wake lock api.
Applying: PM: Add early suspend api.
Applying: PM: Implement wakelock api.
Applying: PM: Implement early suspend api
Applying: PM: Enable early suspend through /sys/power/state
Applying: PM: Add user-space wake lock api.
Applying: PM: wakelock: Abort task freezing if a wake lock is held.
Applying: PM: earlysuspend: Add console switch when user requested sleep state changes.
Applying: PM: earlysuspend: Removing dependence on console.
Applying: rtc: Add android alarm driver.
Applying: rtc: Try to prevent RTC errors from accumulating.
Applying: ledtrig-sleep: Add led trigger for sleep debugging.
error: patch failed: drivers/leds/Makefile:29
error: drivers/leds/Makefile: patch does not apply
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merged drivers/leds/Kconfig
Auto-merged drivers/leds/Makefile
Applying: PM: Wait for console in resume.
Applying: PM: Fix suspend_console/resume_console use only one semaphore.
Applying: switch: switch class and GPIO drivers.
Applying: lowmemorykiller: Initial support for 2.6.27
error: patch failed: drivers/misc/Kconfig:475
error: drivers/misc/Kconfig: patch does not apply
error: patch failed: drivers/misc/Makefile:30
error: drivers/misc/Makefile: patch does not apply
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merged drivers/misc/Kconfig
CONFLICT (content): Merge conflict in drivers/misc/Kconfig
Auto-merged drivers/misc/Makefile
CONFLICT (content): Merge conflict in drivers/misc/Makefile
Failed to merge in the changes.
Patch failed at 0016.
</pre>
</td>
</tr>
</tbody>
</table>
<p>由這些訊息可看出，前 15 個修改被成功的 apply 上去，但第 16 個產生 conflicts。先用 git status 看看問題出在哪裡：</p>
<table>
<tbody>
<tr>
<td>
<pre>$ git status
drivers/misc/Kconfig: needs merge
drivers/misc/Makefile: needs merge
# Not currently on any branch.
# Changes to be committed:
#   (use "git reset HEAD ..." to unstage)
#
#	new file:   drivers/misc/lowmemorykiller.c
#
# Changed but not updated:
#   (use "git add ..." to update what will be committed)
#
#	unmerged:   drivers/misc/Kconfig
#	unmerged:   drivers/misc/Makefile
#
</pre>
</td>
</tr>
</tbody>
</table>
<p>可以看出有兩個檔案有 conflicts，必須手動修改。例如，在 drivers/misc/Makefile 裡 conflicts 大約在 35 至 39 行：</p>
<table>
<tbody>
<tr>
<td>
<pre>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD:drivers/misc/Makefile
obj-$(CONFIG_C2PORT)            += c2port/
=======
obj-$(CONFIG_LOW_MEMORY_KILLER) += lowmemorykiller.o
&gt;&gt;&gt;&gt;&gt;&gt;&gt; lowmemorykiller: Initial support for 2.6.27:drivers/misc/Makefile
</pre>
</td>
</tr>
</tbody>
</table>
<p>不難看出，這兩行都要加到 Makefile 中。因此我改成：</p>
<table>
<tbody>
<tr>
<td>
<pre>obj-$(CONFIG_C2PORT)            += c2port/
obj-$(CONFIG_LOW_MEMORY_KILLER) += lowmemorykiller.o
</pre>
</td>
</tr>
</tbody>
</table>
<p>接著</p>
<table>
<tbody>
<tr>
<td>
<pre>$ git add drivers/misc/Makefile
</pre>
</td>
</tr>
</tbody>
</table>
<p>用同樣的方法修改 drivers/misc/Kconfig，然後</p>
<table>
<tbody>
<tr>
<td>
<pre>$ git rebase --continue
</pre>
</td>
</tr>
</tbody>
</table>
<p>如此會繼續合併的過程。當然可能產生其它的 conflicts，都用類似的方法修正，直到 rebase 完成。</p>
<p>如果覺得某個產生 conflicts 的修改是不必要的，可以跳過：</p>
<table>
<tbody>
<tr>
<td>
<pre>$ git rebase --skip
</pre>
</td>
</tr>
</tbody>
</table>
<p>如果覺得 conflicts 太複雜了，不知要麼修改，想要放棄，可以</p>
<table>
<tbody>
<tr>
<td>
<pre>$ git rebase --abort
</pre>
</td>
</tr>
</tbody>
</table>
<p>如此會放棄所有的合併結果，而將 source tree 回到合併前的狀態。</p>
<p>原文链接：<a href="http://cwhuang.info/2009/06/an-experience-of-git-rebase">http://cwhuang.info/2009/06/an-experience-of-git-rebase</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/04/merge-android-kernel-by-git-rebase%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git cherry-pick 和 rebase 的混合用法</title>
		<link>http://wyj.zhuwo.info/2011/04/git-cherry-pick-rebase/</link>
		<comments>http://wyj.zhuwo.info/2011/04/git-cherry-pick-rebase/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 08:13:33 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>
		<category><![CDATA[配置管理]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=316</guid>
		<description><![CDATA[之前在 git 上遇過一個問題 A-B master \ C-D-E-F-G topic 問題是，我只想把 D,F 加到 master ，其他的留在 topic ，而且又不想把 history 搞得很亂，最好就變成這個樣子： A-B-D-F master \ C-E-G topic 有甚麼好的作法？ 原來答案相當簡單。 $ git checkout master $ git cherry-pick D $ git cherry-pick F $ git checkout topic &#8230; <a href="http://wyj.zhuwo.info/2011/04/git-cherry-pick-rebase/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>之前在 git 上遇過一個問題</p>
<pre>A-B  master
   \
    C-D-E-F-G topic
</pre>
<p>問題是，我只想把 D,F 加到 master ，其他的留在 topic ，而且又不想把 history 搞得很亂，<span id="more-316"></span>最好就變成這個樣子：</p>
<pre>A-B-D-F  master
       \
        C-E-G topic
</pre>
<p>有甚麼好的作法？</p>
<p>原來答案相當簡單。</p>
<pre>$ git checkout master
$ git cherry-pick D
$ git cherry-pick F
$ git checkout topic
$ git rebase master
</pre>
<p>就這樣。</p>
<p>原文链接：http://blog.luzi82.com/2010/08/git-cherry-pick-rebase.html</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/04/git-cherry-pick-rebase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>git merge vs rebase vs cherry-pick (ZZ)</title>
		<link>http://wyj.zhuwo.info/2011/04/git-cherry-pick-merge-rebase/</link>
		<comments>http://wyj.zhuwo.info/2011/04/git-cherry-pick-merge-rebase/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 04:50:42 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>
		<category><![CDATA[配置管理]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=313</guid>
		<description><![CDATA[git merge是用来合并两个分支的。 1 2 # 将b分支合并到当前分支 git merge b git cherry-pick可以选择某一个分支中的一个或几个commit(s)来进行操作。例如，假设我 们有个稳定版本的分支，叫v2.0，另外还有个开发版本的分支v3.0，我们不能直接把两个分支合并，这样会导致稳定版本混乱，但是又想增加一个v3.0 中的功能到v2.0中，这里就可以使用cherry-pick了。 1 2 3 4 5 6 7 8 9 # 先在v3.0中查看要合并的commit的commit id git log # 假设是 commit f79b0b1ffe445cab6e531260743fa4e08fb4048b # 切到v2.0中 git check v2.0 # 合并commit git cherry-pick &#8230; <a href="http://wyj.zhuwo.info/2011/04/git-cherry-pick-merge-rebase/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>git merge</strong>是用来合并两个分支的。</p>
<div>
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1<br />
2</div>
</td>
<td>
<div># 将b分支合并到当前分支<br />
git merge b</div>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong><span id="more-313"></span>git cherry-pick</strong>可以选择某一个分支中的一个或几个commit(s)来进行操作。例如，假设我 们有个稳定版本的分支，叫v2.0，另外还有个开发版本的分支v3.0，我们不能直接把两个分支合并，这样会导致稳定版本混乱，但是又想增加一个v3.0 中的功能到v2.0中，这里就可以使用cherry-pick了。</p>
<div>
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
8<br />
9</div>
</td>
<td>
<div># 先在v3.0中查看要合并的commit的commit id<br />
git log<br />
# 假设是 commit f79b0b1ffe445cab6e531260743fa4e08fb4048b</p>
<p># 切到v2.0中<br />
git check v2.0</p>
<p># 合并commit<br />
git cherry-pick f79b0b1ffe445cab6e531260743fa4e08fb4048b</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>git rebase</strong>有点类似git  merge，但是两者又有不同，打个比方，你有两个抽屉A和B，里面都装了衣服，现在想把B中的衣服放到A中，git  merge是那种横冲直撞型的，拿起B就倒入A里面，如果满了（冲突）再一并整理；而git  rebase就很持家了，它会一件一件的从B往A中加，会根据一开始放入的时间顺序的来加，如果满了你可以处理这一件，你可以继续加，或者跳过这一件，又 或者不加了，把A还原。所以merge适合那种比较琐碎的，简单的合并，系统级的合并还是用rebase吧。</p>
<p>专业的区别请移步到这里<a href="http://progit.org/book/zh/ch3-6.html">合并和衍合</a></p>
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
8<br />
9<br />
10<br />
11</div>
</td>
<td>
<div># 合并b<br />
git rebase b</p>
<p># 处理完冲突继续合并<br />
git rebase &#8211;continue</p>
<p># 跳过<br />
git rebase &#8211;skip</p>
<p># 取消合并<br />
git rebase &#8211;abort</p>
</div>
</td>
</tr>
</tbody>
</table>
<p>转载自：<a title="http://zires.info/tag/git-cherry-pick/" href="http://zires.info/tag/git-cherry-pick/">http://zires.info/tag/git-cherry-pick/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/04/git-cherry-pick-merge-rebase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>快捷键代替鼠标 键盘使用技巧</title>
		<link>http://wyj.zhuwo.info/2011/03/keyboard-shortcuts/</link>
		<comments>http://wyj.zhuwo.info/2011/03/keyboard-shortcuts/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 13:01:57 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=301</guid>
		<description><![CDATA[一、常规键盘快捷键 CTRL + 向下键 将插入点移动到下一段落的起始处。 CTRL + 向上键 将插入点移动到前一段落的起始处。 Alt + 空格键 为当前窗口打开快捷菜单。 Alt + Esc 以项目打开的顺序循环切换。 F6 在窗口或桌面上循环切换屏幕元素。 F4 切换至Windows 资源管理器”中的“地址”栏列表。 Shift + F10 显示所选项的快捷菜单。 Alt + 空格键 显示当前窗口的“系统”菜单。 ALT + 菜单名中带下划线的字母 显示相应的菜单。 在打开的菜单上显示的命令名称中带有下划线的字母 执行相应的命令。 F10 激活当前程序中的菜单条。 二、对话框快捷键 按键 &#8230; <a href="http://wyj.zhuwo.info/2011/03/keyboard-shortcuts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>一、常规键盘快捷键<br />
CTRL + 向下键 将插入点移动到下一段落的起始处。<br />
CTRL + 向上键 将插入点移动到前一段落的起始处。<br />
Alt + 空格键 为当前窗口打开快捷菜单。<br />
Alt + Esc 以项目打开的顺序循环切换。<br />
F6 在窗口或桌面上循环切换屏幕元素。<br />
F4 切换至Windows 资源管理器”中的“地址”栏列表。<br />
Shift + F10 显示所选项的快捷菜单。<br />
Alt + 空格键 显示当前窗口的“系统”菜单。<br />
ALT + 菜单名中带下划线的字母 显示相应的菜单。<br />
在打开的菜单上显示的命令名称中带有下划线的字母 执行相应的命令。<br />
F10 激活当前程序中的菜单条。<br />
<span id="more-301"></span><br />
二、对话框快捷键</p>
<p>按键 目的<br />
Ctrl + Tab 在选项卡之间向前移动。<br />
Ctrl + Shift +Tab 在选项卡之间向后移动。<br />
Tab 在选项之间向前移动。<br />
Shift + Tab 在选项之间向后移动。<br />
F4 显示当前列表中的项目。</p>
<p>三、自然键盘快捷键</p>
<p>在“Microsoft 自然键盘”或包含 Windows 徽标键(简称WIN) 和“应用程序”键(简称KEY) 的其他兼容键盘中，您可以使用以下快捷键。</p>
<p>按键 目的<br />
WIN+ M 最小化所有窗口。<br />
WIN+ Shift + M 还原最小化的窗口。<br />
WIN+ U 打开&#8221;工具管理器&#8221;。</p>
<p>四、辅助键盘快捷键</p>
<p>按键 目的<br />
右侧 SHIFT 键八秒钟 切换“筛选键”的开和关。<br />
左边的 ALT + 左边的 SHIFT + PRINT SCREEN 切换“高对比度”的开和关。<br />
左边的 ALT + 左边的 SHIFT + NUM LOCK 切换“鼠标键”的开和关。<br />
Shift 键五次 切换“粘滞键”的开和关。<br />
Num Lock 键五秒钟 切换“切换键”的开和关。<br />
WIN+ U 打开“工具管理器”。</p>
<p>五、“Windows 资源管理器”键盘快捷键</p>
<p>按键 目的<br />
END 显示当前窗口的底端。<br />
主页 显示当前窗口的顶端。<br />
NUM LOCK + 数字键盘的星号 (*) 显示所选文件夹的所有子文件夹。<br />
NUM LOCK + 数字键盘的加号 (+) 显示所选文件夹的内容。<br />
NUM LOCK + 数字键盘的减号 (-) 折叠所选的文件夹。<br />
左箭头键 当前所选项处于展开状态时折叠该项，或选定其父文件夹。<br />
右箭头键 当前所选项处于折叠状态时展开该项，或选定第一</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/03/keyboard-shortcuts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ubuntu 隐藏 mount 挂载硬盘图标</title>
		<link>http://wyj.zhuwo.info/2011/03/ubuntu-hide-mount-hard-disk-icon/</link>
		<comments>http://wyj.zhuwo.info/2011/03/ubuntu-hide-mount-hard-disk-icon/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 14:51:59 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=298</guid>
		<description><![CDATA[新加了一块硬盘mount到了/media/ext下面了，方法参见： http://wyj.zhuwo.info/2011/03/debianubuntu-installing-a-new-hard-drive/ 但是重启之后，桌面上总是会出现硬盘的图标，有点郁闷。 上网搜了一下，有两种修改方法： 1. 修改路径，mount到/mnt/ext下面。 2. 修改 gconf-editor，app-&#62;nautilus-&#62;desktop去掉volumes_visible的勾。 建议使用前者，后者连优盘挂载的时候也会不显示。]]></description>
			<content:encoded><![CDATA[<p>新加了一块硬盘mount到了/media/ext下面了，方法参见：</p>
<p><a href="http://wyj.zhuwo.info/2011/03/debianubuntu-installing-a-new-hard-drive/">http://wyj.zhuwo.info/2011/03/debianubuntu-installing-a-new-hard-drive/</a></p>
<p>但是重启之后，桌面上总是会出现硬盘的图标，有点郁闷。</p>
<p>上网搜了一下，有两种修改方法：</p>
<p>1. 修改路径，mount到/mnt/ext下面。</p>
<p>2. 修改 gconf-editor，app-&gt;nautilus-&gt;desktop去掉volumes_visible的勾。</p>
<p>建议使用前者，后者连优盘挂载的时候也会不显示。</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/03/ubuntu-hide-mount-hard-disk-icon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian/Ubuntu 添加一块硬盘，Installing A New Hard Drive</title>
		<link>http://wyj.zhuwo.info/2011/03/debianubuntu-installing-a-new-hard-drive/</link>
		<comments>http://wyj.zhuwo.info/2011/03/debianubuntu-installing-a-new-hard-drive/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 01:48:54 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=296</guid>
		<description><![CDATA[ubuntu 的help做得非常好，详细的说了添加硬盘的各种方法和步骤，太棒了。 主要有几个步骤： 格式化硬盘/Partition The Disk 去掉保留空间/Modify Reserved Space (Optional) 创建挂载点Create A Mount Point 修改/etc/fstab，挂载硬盘/Mount The Drive 参考链接： https://help.ubuntu.com/community/InstallingANewHardDrive]]></description>
			<content:encoded><![CDATA[<p>ubuntu 的help做得非常好，详细的说了添加硬盘的各种方法和步骤，太棒了。<br />
主要有几个步骤：</p>
<ol>
<li>格式化硬盘/Partition The Disk</li>
<li>去掉保留空间/Modify Reserved Space (Optional)</li>
<li>创建挂载点Create A Mount Point</li>
<li>修改/etc/fstab，挂载硬盘/Mount The Drive</li>
</ol>
<p>参考链接：</p>
<p><a href="https://help.ubuntu.com/community/InstallingANewHardDrive">https://help.ubuntu.com/community/InstallingANewHardDrive</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/03/debianubuntu-installing-a-new-hard-drive/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java Bitwise Shift Operators</title>
		<link>http://wyj.zhuwo.info/2011/03/java-bitwise-shift-operators/</link>
		<comments>http://wyj.zhuwo.info/2011/03/java-bitwise-shift-operators/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 07:19:22 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[技术为本]]></category>
		<category><![CDATA[文摘转贴]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=294</guid>
		<description><![CDATA[The bitwise shift operators are : &#62;&#62; , &#60;&#60; , &#62;&#62;&#62; &#62;&#62; the SHIFT RIGHT operator &#60;&#60; the SHIFT LEFT operator &#62;&#62;&#62; the UNSIGNED SHIFT RIGHT operator Example 1: the &#62;&#62; opearator applied to positive intgers This example shows the &#8230; <a href="http://wyj.zhuwo.info/2011/03/java-bitwise-shift-operators/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The bitwise shift operators are : &gt;&gt; , &lt;&lt; , &gt;&gt;&gt;</p>
<p><strong><span style="color: #ff0000;">&gt;&gt; </span></strong>the SHIFT RIGHT operator</p>
<p><strong><span style="color: #ff0000;">&lt;&lt; </span></strong>the SHIFT LEFT operator</p>
<p><strong><span style="color: #ff0000;">&gt;&gt;&gt; </span></strong>the UNSIGNED SHIFT RIGHT operator<span id="more-294"></span></p>
<p><span style="text-decoration: underline;">Example 1: the &gt;&gt; opearator applied to positive intgers</span></p>
<p>This example shows the effect of using the &gt;&gt; opearator.</p>
<pre><strong><span style="color: #0000ff;">  
class Bits1{ 
   public static void main(String args[]){
      System.out.println(" &gt;&gt; opeartor");

// shift all the bits in 20 (in binary form) to the right by 2 
      System.out.println("20&gt;&gt;2 = "+20&gt;&gt;2);
    }
}</span></strong>
</pre>
<p>Explanation of 20&gt;&gt;2 = 5</p>
<p>20 in binary is: 00000000000000000000000000010100</p>
<p>shift all bits 2 positions to right 00000000000000000000000000000101</p>
<p>This is 5 (2*2^2+0*2^1+1*2^0) in binary form</p>
<p>参考链接：</p>
<p><a href="http://www.sap-img.com/java/java-bitwise-shift-operators.htm">http://www.sap-img.com/java/java-bitwise-shift-operators.htm</a></p>
<p><a href="http://www.leepoint.net/notes-java/data/expressions/bitops.html">http://www.leepoint.net/notes-java/data/expressions/bitops.html</a></p>
<p><a href="http://en.wikipedia.org/wiki/Bitwise_operation">http://en.wikipedia.org/wiki/Bitwise_operation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/03/java-bitwise-shift-operators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s this: __attribute__((packed))</title>
		<link>http://wyj.zhuwo.info/2011/03/whats-this-__attribute__packed/</link>
		<comments>http://wyj.zhuwo.info/2011/03/whats-this-__attribute__packed/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 10:27:02 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[C&C++]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=292</guid>
		<description><![CDATA[今天在Android的代码里面看到了“__attribute__((packed))”，不清楚什么意思，上网搜了一下，大概明白了。就是让struct按照紧凑模式排列，中间不留任何缝隙。这样在不同的处理器，不同的网络传输等情况都不会出现对齐问题了。很好很强大。 参考链接：http://www.linuxquestions.org/questions/programming-9/whats-this-__attribute__-packed-193570/ 后面是摘录网页上的解释，写的很好。 __attribute__((packed)) ensures that structure fields align on one-byte boundaries. If you want to ensure that your structures have the same size on all processors, the packed attribute is how you tell gcc. As an example, let&#8217;s define &#8230; <a href="http://wyj.zhuwo.info/2011/03/whats-this-__attribute__packed/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>今天在Android的代码里面看到了“__attribute__((packed))”，不清楚什么意思，上网搜了一下，大概明白了。就是让struct按照紧凑模式排列，中间不留任何缝隙。这样在不同的处理器，不同的网络传输等情况都不会出现对齐问题了。很好很强大。</p>
<p>参考链接：http://www.linuxquestions.org/questions/programming-9/whats-this-__attribute__-packed-193570/</p>
<p>后面是摘录网页上的解释，写的很好。<span id="more-292"></span></p>
<p>__attribute__((packed)) ensures that structure fields align on one-byte  boundaries. If you want to ensure that your structures have the same  size on all <a id="KonaLink0" href="http://www.linuxquestions.org/questions/#"><span style="color: blue;">processors</span></a>, the packed attribute is how you tell gcc.</p>
<p>As an example, let&#8217;s define this structure:</p>
<div>
<div>Code:</div>
<pre dir="ltr">struct s {
   char aChar;
   int    anInt;
};</pre>
</div>
<p>A processor that aligns on eight-byte boundaries may compile this  so that aChar is in the first byte, followed by seven bytes of unused  space, then starting anInt in the ninth byte.</p>
<p>A processor that aligns on four-byte boundaries may compile this so that  aChar is in the first byte, followed by three bytes of unused space,  then starting anInt in the fifth byte.</p>
<p>To force anInt to begin immediately after aChar, you would define the structure like this:</p>
<div>
<div>Code:</div>
<pre dir="ltr">struct s {
   char aChar;
   int anInt __attribute__((packed));
};</pre>
</div>
<p>To test these ideas out, I ran this code on an old Pentium 166:</p>
<div>
<div>Code:</div>
<pre dir="ltr">#include &lt;stdio.h&gt;

struct s1 {
   char a;
   int  i;
};

struct s2 {
   char a;
   int i __attribute__((packed));
};

int main( int argc, char* argv[] ) {

  struct s1 s_1;
  struct s2 s_2;

  printf( "sizeof s1 is %d\n" , sizeof(s_1) );
  printf( "sizeof s2 is %d\n" , sizeof(s_2) );

  return( 0 );
}</pre>
</div>
<p>And got these results:</p>
<div>
<div>Code:</div>
<pre dir="ltr">eric.r.turner@turing:~/lab/packed$ ./foo
sizeof s1 is 8
sizeof s2 is 5</pre>
</div>
<p>Looks like this processor aligns on four-byte boundaries.</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/03/whats-this-__attribute__packed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>好站推荐：在线读代码 http://www.sooset.com</title>
		<link>http://wyj.zhuwo.info/2011/02/%e5%a5%bd%e7%ab%99%e6%8e%a8%e8%8d%90%ef%bc%9a%e5%9c%a8%e7%ba%bf%e8%af%bb%e4%bb%a3%e7%a0%81-httpwww-sooset-com/</link>
		<comments>http://wyj.zhuwo.info/2011/02/%e5%a5%bd%e7%ab%99%e6%8e%a8%e8%8d%90%ef%bc%9a%e5%9c%a8%e7%ba%bf%e8%af%bb%e4%bb%a3%e7%a0%81-httpwww-sooset-com/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 10:43:50 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[技术为本]]></category>
		<category><![CDATA[网络应用]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=288</guid>
		<description><![CDATA[好站推荐：在线读代码 http://www.sooset.com 同事推荐的，相当强大，注册之后可以自己上传代码，压缩包限制20M以内。]]></description>
			<content:encoded><![CDATA[<p>好站推荐：在线读代码 <a href="http://www.sooset.com">http://www.sooset.com</a></p>
<p>同事推荐的，相当强大，注册之后可以自己上传代码，压缩包限制20M以内。</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/02/%e5%a5%bd%e7%ab%99%e6%8e%a8%e8%8d%90%ef%bc%9a%e5%9c%a8%e7%ba%bf%e8%af%bb%e4%bb%a3%e7%a0%81-httpwww-sooset-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Openproj on Ubuntu (zz)</title>
		<link>http://wyj.zhuwo.info/2011/02/installing-openproj-on-ubuntu-zz/</link>
		<comments>http://wyj.zhuwo.info/2011/02/installing-openproj-on-ubuntu-zz/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 02:10:46 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=286</guid>
		<description><![CDATA[从openproj官方网站下载rpm包 openproj-1.4-2.noarch.rpm sudo apt-get install alien sudo alien openproj-1.4-2.noarch.rpm sudo dpkg -i openproj-1.4-2_all.deb 原文地址：http://sidrit.wordpress.com/2008/10/10/installing-openproj-on-ubuntu/ 解决中文显示问题：http://wyj.zhuwo.info/2011/02/linux-jdk-解决乱码问题，中文字体设置方法/]]></description>
			<content:encoded><![CDATA[<ol>
<li>从openproj官方网站下载rpm包<code> openproj-1.4-2.noarch.rpm</code></li>
<li><code>sudo apt-get install alien</code></li>
<li><code>sudo alien openproj-1.4-2.noarch.rpm</code></li>
<li><code>sudo dpkg -i openproj-1.4-2_all.deb</code></li>
</ol>
<p>原文地址：<a href="http://sidrit.wordpress.com/2008/10/10/installing-openproj-on-ubuntu/">http://sidrit.wordpress.com/2008/10/10/installing-openproj-on-ubuntu/</a></p>
<p>解决中文显示问题：<a href="http://wyj.zhuwo.info/2011/02/linux-jdk-解决乱码问题，中文字体设置方法/">http://wyj.zhuwo.info/2011/02/linux-jdk-解决乱码问题，中文字体设置方法/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/02/installing-openproj-on-ubuntu-zz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux JDK 解决乱码问题，中文字体设置方法</title>
		<link>http://wyj.zhuwo.info/2011/02/linux-jdk-%e8%a7%a3%e5%86%b3%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%ef%bc%8c%e4%b8%ad%e6%96%87%e5%ad%97%e4%bd%93%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95/</link>
		<comments>http://wyj.zhuwo.info/2011/02/linux-jdk-%e8%a7%a3%e5%86%b3%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%ef%bc%8c%e4%b8%ad%e6%96%87%e5%ad%97%e4%bd%93%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 02:06:12 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=284</guid>
		<description><![CDATA[cd /usr/lib/jvm/java-1.5.0-sun/jre/lib/fonts sudo ln -s /usr/share/fonts/truetype/wqy/ fallback 应该就可以了，主要目录要没错。 如果还不行，再执行下面 sudo mkfontscale sudo mkfontdir]]></description>
			<content:encoded><![CDATA[<p>cd /usr/lib/jvm/java-1.5.0-sun/jre/lib/fonts</p>
<p>sudo ln -s /usr/share/fonts/truetype/wqy/ fallback</p>
<p>应该就可以了，主要目录要没错。</p>
<p>如果还不行，再执行下面</p>
<p>sudo mkfontscale</p>
<p>sudo mkfontdir</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/02/linux-jdk-%e8%a7%a3%e5%86%b3%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%ef%bc%8c%e4%b8%ad%e6%96%87%e5%ad%97%e4%bd%93%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>android.widget.Gallery getView, newView, bindView</title>
		<link>http://wyj.zhuwo.info/2011/02/android-widget-gallery-getview-newview-bindview/</link>
		<comments>http://wyj.zhuwo.info/2011/02/android-widget-gallery-getview-newview-bindview/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 04:27:58 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=273</guid>
		<description><![CDATA[在使用Gallery时，每一次bindView的同时也会有newView，这是Gallery的特殊性。从代码来看，Gallery从makeAndAddView里调用了 child = mAdapter.getView(position, null, this); 第二个参数是null，所以getView里面就调用了newView，然后bindView，而不是直接bindView。]]></description>
			<content:encoded><![CDATA[<p>在使用Gallery时，每一次bindView的同时也会有newView，这是Gallery的特殊性。从代码来看，Gallery从makeAndAddView里调用了</p>
<p>child = mAdapter.getView(position, null, this);</p>
<p>第二个参数是null，所以getView里面就调用了newView，然后bindView，而不是直接bindView。</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/02/android-widget-gallery-getview-newview-bindview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian 服务器网络问题解决</title>
		<link>http://wyj.zhuwo.info/2011/02/debian-%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%bd%91%e7%bb%9c%e9%97%ae%e9%a2%98%e8%a7%a3%e5%86%b3/</link>
		<comments>http://wyj.zhuwo.info/2011/02/debian-%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%bd%91%e7%bb%9c%e9%97%ae%e9%a2%98%e8%a7%a3%e5%86%b3/#comments</comments>
		<pubDate>Sat, 12 Feb 2011 13:08:53 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=267</guid>
		<description><![CDATA[过了年，开始工作，服务器却出了问题，可能是年前升级引起的问题吧，具体还不得而知。 现象：无法获取 ip。 解决办法：sudo ifconfig eth0 192.168.1.2 现象：域名服务无法启动。 错误信息：bind9rndc: connect failed: 127.0.0.1#953: connection refused 解决办法： sudo chown root.bind /etc/bind/rndc.key sudo /etc/init.d/bind9 restart 现象：lo 回环没有启动 解决办法：sudo ifconfig up lo 现象：bind重启后生效，自定义域名可用，但forwarder功能不起作用。 进一步：服务器 ping 外网不通。 错误信息：connect: Network is unreachable 解决办法：route add -net 0.0.0.0 &#8230; <a href="http://wyj.zhuwo.info/2011/02/debian-%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%bd%91%e7%bb%9c%e9%97%ae%e9%a2%98%e8%a7%a3%e5%86%b3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>过了年，开始工作，服务器却出了问题，可能是年前升级引起的问题吧，具体还不得而知。</p>
<p>现象：无法获取 ip。<br />
解决办法：sudo ifconfig eth0 192.168.1.2</p>
<p>现象：域名服务无法启动。<br />
错误信息：bind9rndc: connect failed: 127.0.0.1#953: connection refused<br />
解决办法：<span id="more-267"></span></p>
<pre>sudo chown root.bind /etc/bind/rndc.key
sudo /etc/init.d/bind9 restart
</pre>
<p>现象：lo 回环没有启动<br />
解决办法：sudo ifconfig up lo</p>
<p>现象：bind重启后生效，自定义域名可用，但forwarder功能不起作用。<br />
进一步：服务器 ping 外网不通。<br />
错误信息：connect: Network is unreachable<br />
解决办法：route add -net 0.0.0.0 gw 192.168.1.3 eth0</p>
<p>到此为止，问题就解决了。</p>
<p>现象：sudo /etc/init.d/networking restart 没有反应，不起作用。<br />
根源：ifup, ifdown 命令不存在<br />
解决办法：sudo aptitude install ifupdown</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/02/debian-%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%bd%91%e7%bb%9c%e9%97%ae%e9%a2%98%e8%a7%a3%e5%86%b3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>undefined reference to `__cxa_end_cleanup&#8217;</title>
		<link>http://wyj.zhuwo.info/2011/01/undefined-reference-to-__cxa_end_cleanup/</link>
		<comments>http://wyj.zhuwo.info/2011/01/undefined-reference-to-__cxa_end_cleanup/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 06:51:57 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=259</guid>
		<description><![CDATA[在使用Android里面使用stlport的时候出现错误 undefined reference to `__cxa_end_cleanup&#8217; 经查证，最后解决了该问题，是exception的问题。 去掉了try, catch和throw等语句，就OK了。 主要还要去掉：-fexceptions 后面附上参考链接。 http://groups.google.com/group/android-ndk/browse_thread/thread/3cde35eec53e0753?fwc=1&#38;pli=1 http://groups.google.com/group/android-ndk/browse_thread/thread/a5dd86e985e191fc/dae0067602d7bd0c?pli=1 https://groups.google.com/group/android-ndk/browse_thread/thread/513d5ba12c8981d0/6b0958e8e16854a1?hl=fr&#38;ie=UTF-8&#38;q=undefined+reference+to+%60__cxa_end_cleanup%27&#38;pli=1#6b0958e8e16854a1]]></description>
			<content:encoded><![CDATA[<div>在使用Android里面使用stlport的时候出现错误</div>
<div>undefined reference to `__cxa_end_cleanup&#8217; </div>
<div>经查证，最后解决了该问题，是exception的问题。</div>
<div>去掉了try, catch和throw等语句，就OK了。</div>
<div>主要还要去掉：<font face="Courier, Monospaced">-fexceptions</font></div>
<div>后面附上参考链接。</div>
<div></div>
<div>http://groups.google.com/group/android-ndk/browse_thread/thread/3cde35eec53e0753?fwc=1&amp;pli=1</div>
<div>http://groups.google.com/group/android-ndk/browse_thread/thread/a5dd86e985e191fc/dae0067602d7bd0c?pli=1</div>
<div>https://groups.google.com/group/android-ndk/browse_thread/thread/513d5ba12c8981d0/6b0958e8e16854a1?hl=fr&amp;ie=UTF-8&amp;q=undefined+reference+to+%60__cxa_end_cleanup%27&amp;pli=1#6b0958e8e16854a1</div>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/01/undefined-reference-to-__cxa_end_cleanup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>csv 转 xml 软件，很好用。</title>
		<link>http://wyj.zhuwo.info/2011/01/csv-%e8%bd%ac-xml-%e8%bd%af%e4%bb%b6%ef%bc%8c%e5%be%88%e5%a5%bd%e7%94%a8%e3%80%82/</link>
		<comments>http://wyj.zhuwo.info/2011/01/csv-%e8%bd%ac-xml-%e8%bd%af%e4%bb%b6%ef%bc%8c%e5%be%88%e5%a5%bd%e7%94%a8%e3%80%82/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 10:30:41 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=255</guid>
		<description><![CDATA[由于导入数据的需要，需要把Excel的CSV格式转为XML格式。 沙漠之周同学帮我找到一个很好的工具，地址在下面。很好用。http://csv2xml.sourceforge.net/ 另外还有一个perl的库也不错，只是对中文支持不好： http://search.cpan.org/~isterin/XML-CSV-0.15/CSV.pm 简介： csv2xml &#8211; A csv to xml converter As the name suggest, csv2xml is a simple csv to xml converter. It reads csv files from standard input, and output a valid xml file on standard output. &#8230; <a href="http://wyj.zhuwo.info/2011/01/csv-%e8%bd%ac-xml-%e8%bd%af%e4%bb%b6%ef%bc%8c%e5%be%88%e5%a5%bd%e7%94%a8%e3%80%82/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>由于导入数据的需要，需要把Excel的CSV格式转为XML格式。<br />
沙漠之周同学帮我找到一个很好的工具，地址在下面。很好用。<a href="http://csv2xml.sourceforge.net/">http://csv2xml.sourceforge.net/</a><br />
另外还有一个perl的库也不错，只是对中文支持不好：<br />
<a href="http://search.cpan.org/~isterin/XML-CSV-0.15/CSV.pm">http://search.cpan.org/~isterin/XML-CSV-0.15/CSV.pm</a><span id="more-255"></span></p>
<p>简介：</p>
<p>csv2xml &#8211; A csv to xml converter</p>
<p>As the name suggest, csv2xml is a simple csv to xml converter. It reads csv files from standard input, and output a valid xml file on standard output.</p>
<p>csv2xml is great if your client asks you to resend a data file as xml, no need to modify your scripts, or for when you have a large csv file and you would like to be able to view/edit it with your favourite xml utility.<br />
How to use csv2xml</p>
<p>If you have a csv file called test.csv and want to create a file test.xml after installing csv2xml you would type the following:</p>
<p>csv2xml &lt; test.csv &gt; test.xml</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2011/01/csv-%e8%bd%ac-xml-%e8%bd%af%e4%bb%b6%ef%bc%8c%e5%be%88%e5%a5%bd%e7%94%a8%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No module defined for the given PRODUCT_POLICY (android.policy_phone)</title>
		<link>http://wyj.zhuwo.info/2010/12/no-module-defined-for-the-given-product_policy/</link>
		<comments>http://wyj.zhuwo.info/2010/12/no-module-defined-for-the-given-product_policy/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 03:53:55 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=244</guid>
		<description><![CDATA[今天编译android的时候出现了一个编译错误： No module defined for the given PRODUCT_POLICY (android.policy_phone) frameworks/policies/base/PolicyConfig.mk:22: *** No module defined for the given PRODUCT_POLICY (android.policy_phone). Stop. 先是怀疑自己哪个地方改错了，经比对检查，都没问题。 最后发现根目录有个Android.mk，原来是它在作祟。 删除即可搞定。]]></description>
			<content:encoded><![CDATA[<p>今天编译android的时候出现了一个编译错误：<br />
No module defined for the given PRODUCT_POLICY (android.policy_phone)<br />
frameworks/policies/base/PolicyConfig.mk:22: *** No module defined for the given PRODUCT_POLICY (android.policy_phone).  Stop.</p>
<p>先是怀疑自己哪个地方改错了，经比对检查，都没问题。<br />
最后发现根目录有个Android.mk，原来是它在作祟。<br />
删除即可搞定。</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2010/12/no-module-defined-for-the-given-product_policy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SVN 限制 IP 访问</title>
		<link>http://wyj.zhuwo.info/2010/11/svn-%e9%99%90%e5%88%b6-ip-%e8%ae%bf%e9%97%ae/</link>
		<comments>http://wyj.zhuwo.info/2010/11/svn-%e9%99%90%e5%88%b6-ip-%e8%ae%bf%e9%97%ae/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 10:49:02 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[技术为本]]></category>
		<category><![CDATA[网络应用]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=239</guid>
		<description><![CDATA[我们的 SVN 采用的是http协议进行发布，通过 Apache，由于种种原因，需要限制。 以下代码加在 /etc/apache2/modes_available/dav_svn.conf 文件的 之前即可。 表示的意思是，仅192.168.1.*网段的IP可以访问SVN。 order deny,allow deny from all allow from 192.168.1 参考链接：http://blog.csdn.net/wyswlp/archive/2010/08/29/5848361.aspx]]></description>
			<content:encoded><![CDATA[<p>我们的 SVN 采用的是http协议进行发布，通过 Apache，由于种种原因，需要限制。<br />
以下代码加在 /etc/apache2/modes_available/dav_svn.conf 文件的  之前即可。<br />
表示的意思是，仅192.168.1.*网段的IP可以访问SVN。</p>
<p>  order deny,allow<br />
  deny from all<br />
  allow from 192.168.1</p>
<p>参考链接：<a href="http://blog.csdn.net/wyswlp/archive/2010/08/29/5848361.aspx">http://blog.csdn.net/wyswlp/archive/2010/08/29/5848361.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2010/11/svn-%e9%99%90%e5%88%b6-ip-%e8%ae%bf%e9%97%ae/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSN 登录，omega.contacts.msn.com 证书认证失败。</title>
		<link>http://wyj.zhuwo.info/2010/11/msn-omega-contacts-msn-com-invalidate/</link>
		<comments>http://wyj.zhuwo.info/2010/11/msn-omega-contacts-msn-com-invalidate/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 04:03:46 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>
		<category><![CDATA[网络应用]]></category>
		<category><![CDATA[pidgin]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=234</guid>
		<description><![CDATA[转贴至此，原文被墙。 The certificate for omega.contacts.msn.com could not be validated. The certificate chain presented is invalid. Pidgin Update. to fix this error: solution #1 remove file : c:\Documents and Settings\[your-username]\Application Data\.purple\certificates\x509\tls_peers\contacts.msn.com In Win 7 the path is: C:\Users\[UserID]\AppData\Roaming\.purple\certificates\x509\tls_peers or for linux &#8230; <a href="http://wyj.zhuwo.info/2010/11/msn-omega-contacts-msn-com-invalidate/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>转贴至此，原文被墙。</h3>
<h3><a href="http://sourcefield.blogspot.com/2010/11/certificate-for-omegacontactsmsncom.html">The certificate for omega.contacts.msn.com could not be validated. The certificate chain presented is invalid.</a></h3>
<p>Pidgin Update.<br />
to fix this error:<br />
<strong>solution #1 </strong></p>
<p>remove file :<br />
c:\Documents and Settings\[your-username]\Application Data\.purple\certificates\x509\tls_peers\contacts.msn.com<span id="more-234"></span></p>
<p>In Win 7 the path is: C:\Users\[UserID]\AppData\Roaming\.purple\certificates\x509\tls_peers</p>
<p>or for linux :<br />
~.purple/certificates/x509/tls_peers/contacts.msn.com<br />
and Pidgin will load latest certificate.</p>
<p><em>Update: it also can be fixed by deleting certificate from Pidgin menu Tools/Certificate.</em></p>
<p><strong> Solution #2: (if #1 is not working)</strong></p>
<p>a.<a href="http://files.andreineculau.com/projects/pidgin/omega.contacts.msn.com.txt">Download this file</a>,</p>
<p>b.<strong> delete the .txt extension</strong>, so that you end up with omega.contacts.msn.com only,</p>
<p>c.<strong> copy the file</strong> to your <strong>c:\Documents and Settings\[your-username]\Application Data\.purple\certificates\x509\tls_peers</strong> folder</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2010/11/msn-omega-contacts-msn-com-invalidate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu 下安装 linux 版飞信 OpenFetion</title>
		<link>http://wyj.zhuwo.info/2010/11/ubuntu-%e4%b8%8b%e5%ae%89%e8%a3%85-linux-%e7%89%88%e9%a3%9e%e4%bf%a1-openfetion/</link>
		<comments>http://wyj.zhuwo.info/2010/11/ubuntu-%e4%b8%8b%e5%ae%89%e8%a3%85-linux-%e7%89%88%e9%a3%9e%e4%bf%a1-openfetion/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 10:49:06 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=225</guid>
		<description><![CDATA[sudo apt-add-repository ppa:happyaron/ppa sudo apt-get update sudo apt-get install openfetion]]></description>
			<content:encoded><![CDATA[<p>sudo apt-add-repository ppa:happyaron/ppa<br />
sudo apt-get update<br />
sudo apt-get install openfetion</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2010/11/ubuntu-%e4%b8%8b%e5%ae%89%e8%a3%85-linux-%e7%89%88%e9%a3%9e%e4%bf%a1-openfetion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux下使用SSH翻墙 (ZZ)</title>
		<link>http://wyj.zhuwo.info/2010/10/linux%e4%b8%8b%e4%bd%bf%e7%94%a8ssh%e7%bf%bb%e5%a2%99/</link>
		<comments>http://wyj.zhuwo.info/2010/10/linux%e4%b8%8b%e4%bd%bf%e7%94%a8ssh%e7%bf%bb%e5%a2%99/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 01:36:12 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>
		<category><![CDATA[网络应用]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=203</guid>
		<description><![CDATA[原文地址：http://ssh987.tk/how_to_use_ssh_linux.html 在linux下用ssh翻墙很简单： 打开终端，输入：ssh -qTfnN -D 端口 user_name@host_home 其中端口号，user_name和host_home更改为你自己的ssh配置即可！ Firefox设置： 安装扩展：AutoProxy » 一般情况下，页面上方会出现下图提示是否允许安装，请点击“允许”。 点击立即安装，安装后，重新启动Firefox。然后你会看到如下对话框，按照下图依次进行选择，最后点击“确定”。 至此配置已全部就绪。现在你可以浏览国外网站了！ update： 如果你还是无法浏览Youtube等国外网站，可以参考如下解决方法： 在Firefox地址栏输入about:config回车，出现下图： 点击我保证会小心，在过滤器中输入network.proxy.socks_remote_dns 出现下图： 双击 默认 两个字。使其变成如下状态： 即使其值为true既可。然后在地址栏输入http://www.youtube.com试试看看是不是可以正常浏览了？]]></description>
			<content:encoded><![CDATA[<p>原文地址：http://ssh987.tk/how_to_use_ssh_linux.html</p>
<p>在linux下用ssh翻墙很简单：</p>
<p>打开终端，输入：ssh -qTfnN -D 端口 user_name@host_home</p>
<p>其中端口号，user_name和host_home更改为你自己的ssh配置即可！<span id="more-203"></span></p>
<p>Firefox设置：</p>
<p>安装扩展：<a href="http://autoproxy.mozdev.org/latest.xpi">AutoProxy »</a></p>
<p>一般情况下，页面上方会出现下图提示是否允许安装，请点击“允许”。</p>
<p><a href="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/706268944_HgQqf-O.jpg"><img class="aligncenter size-full wp-image-214" title="706268944_HgQqf-O" src="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/706268944_HgQqf-O.jpg" alt="" width="563" height="31" /></a></p>
<p><a href="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/498951512_XzxSh-O.png"><img class="aligncenter size-full wp-image-212" title="498951512_XzxSh-O" src="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/498951512_XzxSh-O.png" alt="" width="547" height="379" /></a></p>
<p>点击立即安装，安装后，重新启动Firefox。然后你会看到如下对话框，按照下图依次进行选择，最后点击“确定”。</p>
<p><a href="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/706264039_UrNRn-M.jpg"><img class="aligncenter size-full wp-image-213" title="706264039_UrNRn-M" src="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/706264039_UrNRn-M.jpg" alt="" width="445" height="450" /></a><br />
至此配置已全部就绪。现在你可以浏览国外网站了！</p>
<p><strong>update：</strong></p>
<p>如果你还是无法浏览Youtube等国外网站，可以参考如下解决方法：</p>
<p>在Firefox地址栏输入<strong>about:config</strong>回车，出现下图：<br />
<a href="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/12.gif"><img class="aligncenter size-full wp-image-209" title="12" src="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/12.gif" alt="" width="706" height="408" /></a><br />
点击<strong>我保证会小心</strong>，在<strong>过滤器</strong>中输入<strong>network.proxy.socks_remote_dns 出现下图：<br />
<a href="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/13.gif"><img class="aligncenter size-full wp-image-210" title="13" src="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/13.gif" alt="" width="592" height="87" /></a><br />
</strong><strong></strong><strong>双击 默认 两个字。使其变成如下状态：</strong></p>
<p><a href="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/14.gif"><img class="aligncenter size-full wp-image-211" title="14" src="http://wyj.zhuwo.info/wordpress/wp-content/uploads/2010/10/14.gif" alt="" width="588" height="94" /></a><br />
<strong>即使其值为true既可。然后在地址栏输入http://www.youtube.com试试看看是不是可以正常浏览了？</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2010/10/linux%e4%b8%8b%e4%bd%bf%e7%94%a8ssh%e7%bf%bb%e5%a2%99/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux文件查找命令find, xargs详述 (zz)</title>
		<link>http://wyj.zhuwo.info/2010/08/linux%e6%96%87%e4%bb%b6%e6%9f%a5%e6%89%be%e5%91%bd%e4%bb%a4find-xargs%e8%af%a6%e8%bf%b0-zz/</link>
		<comments>http://wyj.zhuwo.info/2010/08/linux%e6%96%87%e4%bb%b6%e6%9f%a5%e6%89%be%e5%91%bd%e4%bb%a4find-xargs%e8%af%a6%e8%bf%b0-zz/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 06:09:54 +0000</pubDate>
		<dc:creator>王永杰</dc:creator>
				<category><![CDATA[linux应用]]></category>
		<category><![CDATA[技术为本]]></category>
		<category><![CDATA[文摘转贴]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[xargs]]></category>

		<guid isPermaLink="false">http://wyj.zhuwo.info/?p=197</guid>
		<description><![CDATA[总结：zhy2111314 来自：LinuxSir.Org 整理：北南南北 摘要： 本文是find 命令的详细说明，可贵的是针对参数举了很多的实例，大量的例证，让初学者更为容易理解；本文是zhyfly兄贴在论坛中；我对本文进行了再次整理，为方便大家阅读； 版权声明 本文是zhyfly兄贴在LinuxSir.Org 的一个帖子而整理出来的，如果您对版权有疑问，请在本帖后面跟帖。谢谢；本文的HTML版本由北南南北整理；修改了整篇文档的全角及说明文字中的单词中每个字母空格的问题；为标题加了编号，方便大家阅读； 前言：关于find命令 由于find具有强大的功能，所以它的选项也很多，其中大部分选项都值得我们花时间来了解一下。即使系统中含有网络文件系统( NFS)，find命令在该文件系统中同样有效，只你具有相应的权限。 在运行一个非常消耗资源的find命令时，很多人都倾向于把它放在后台执行，因为遍历一个大的文件系统可能会花费很长的时间(这里是指30G字节以上的文件系统)。 一、find 命令格式 1、find命令的一般形式为； find pathname -options [-print -exec -ok ...] 2、find命令的参数； pathname: find命令所查找的目录路径。例如用.来表示当前目录，用/来表示系统根目录。 -print： find命令将匹配的文件输出到标准输出。 -exec： find命令对匹配的文件执行该参数所给出的shell命令。相应命令的形式为'command' {  } \;，注意{   }和\；之间的空格。 -ok： 和-exec的作用相同，只不过以一种更为安全的模式来执行该参数所给出的shell命令，在执行每一个命令之前，都会给出提示，让用户来确定是否执行。 3、find命令选项 -name 按照文件名查找文件。 -perm &#8230; <a href="http://wyj.zhuwo.info/2010/08/linux%e6%96%87%e4%bb%b6%e6%9f%a5%e6%89%be%e5%91%bd%e4%bb%a4find-xargs%e8%af%a6%e8%bf%b0-zz/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><!-- begin content --><strong>总结：</strong><a href="http://www.linuxsir.org/bbs/member.php?u=57037" target="_blank">zhy2111314</a><br />
<strong>来自：</strong><a href="http://www.linuxsir.org/main/?q=node/137">LinuxSir.Org</a><br />
<strong>整理：</strong>北南南北<br />
<strong>摘要：</strong> 本文是find 命令的详细说明，可贵的是针对参数举了很多的实例，大量的例证，让初学者更为容易理解；本文是zhyfly兄贴在论坛中；我对本文进行了再次整理，为方便大家阅读；</p>
<p><strong><span id="more-197"></span></strong><br />
<span style="font-size: medium;"><strong><br />
版权声明<br />
</strong></span></p>
<p>本文是zhyfly兄贴在LinuxSir.Org 的一个帖子而整理出来的，如果您对版权有疑问，请在本帖后面跟帖。谢谢；本文的HTML版本由北南南北整理；修改了整篇文档的全角及说明文字中的单词中每个字母空格的问题；为标题加了编号，方便大家阅读；</p>
<p><span style="font-size: medium;"><strong>前言：关于find命令</strong></span></p>
<p>由于find具有强大的功能，所以它的选项也很多，其中大部分选项都值得我们花时间来了解一下。即使系统中含有网络文件系统( NFS)，find命令在该文件系统中同样有效，只你具有相应的权限。</p>
<p>在运行一个非常消耗资源的find命令时，很多人都倾向于把它放在后台执行，因为遍历一个大的文件系统可能会花费很长的时间(这里是指30G字节以上的文件系统)。</p>
<p><span style="font-size: medium;"><strong><br />
一、find 命令格式<br />
</strong></span></p>
<p><span style="font-size: small;"><strong><br />
1、find命令的一般形式为；<br />
</strong></span></p>
<div><code>find pathname -options [-print -exec -ok ...]</code></div>
<p><span style="font-size: small;"><strong><br />
2、find命令的参数；<br />
</strong></span></p>
<div><code>pathname: find命令所查找的目录路径。例如用.来表示当前目录，用/来表示系统根目录。<br />
-print： find命令将匹配的文件输出到标准输出。<br />
-exec： find命令对匹配的文件执行该参数所给出的shell命令。相应命令的形式为'command' {  } \;，注意{   }和\；之间的空格。<br />
-ok： 和-exec的作用相同，只不过以一种更为安全的模式来执行该参数所给出的shell命令，在执行每一个命令之前，都会给出提示，让用户来确定是否执行。</code></div>
<p><span style="font-size: small;"><strong><br />
3、find命令选项<br />
</strong></span></p>
<div>
<p><code>-name</code></p>
<p>按照文件名查找文件。</p>
<p>-perm<br />
按照文件权限来查找文件。</p>
<p>-prune<br />
使用这一选项可以使find命令不在当前指定的目录中查找，如果同时使用-depth选项，那么-prune将被find命令忽略。</p>
<p>-user<br />
按照文件属主来查找文件。</p>
<p>-group<br />
按照文件所属的组来查找文件。</p>
<p>-mtime -n +n<br />
按照文件的更改时间来查找文件， &#8211; n表示文件更改时间距现在n天以内，+ n表示文件更改时间距现在n天以前。find命令还有-atime和-ctime 选项，但它们都和-m time选项。</p>
<p>-nogroup<br />
查找无有效所属组的文件，即该文件所属的组在/etc/groups中不存在。</p>
<p>-nouser<br />
查找无有效属主的文件，即该文件的属主在/etc/passwd中不存在。<br />
-newer file1 ! file2</p>
<p>查找更改时间比文件file1新但比文件file2旧的文件。<br />
-type</p>
<p>查找某一类型的文件，诸如：</p>
<p>b &#8211; 块设备文件。<br />
d &#8211; 目录。<br />
c &#8211; 字符设备文件。<br />
p &#8211; 管道文件。<br />
l &#8211; 符号链接文件。<br />
f &#8211; 普通文件。</p>
<p>-size n：[c] 查找文件长度为n块的文件，带有c时表示文件长度以字节计。<br />
-depth：在查找文件时，首先查找当前目录中的文件，然后再在其子目录中查找。<br />
-fstype：查找位于某一类型文件系统中的文件，这些文件系统类型通常可以在配置文件/etc/fstab中找到，该配置文件中包含了本系统中有关文件系统的信息。</p>
<p>-mount：在查找文件时不跨越文件系统mount点。<br />
-follow：如果find命令遇到符号链接文件，就跟踪至链接所指向的文件。<br />
-cpio：对匹配的文件使用cpio命令，将这些文件备份到磁带设备中。</p>
</div>
<p>另外,下面三个的区别:</p>
<div><code> -amin n<br />
查找系统中最后N分钟访问的文件</code></p>
<p>-atime n<br />
查找系统中最后n*24小时访问的文件</p>
<p>-cmin n<br />
查找系统中最后N分钟被改变文件状态的文件</p>
<p>-ctime n<br />
查找系统中最后n*24小时被改变文件状态的文件</p>
<p>-mmin n<br />
查找系统中最后N分钟被改变文件数据的文件</p>
<p>-mtime n<br />
查找系统中最后n*24小时被改变文件数据的文件</p>
</div>
<p><span style="font-size: small;"><strong><br />
4、使用exec或ok来执行shell命令<br />
</strong></span></p>
<p>使用find时，只要把想要的操作写在一个文件里，就可以用exec来配合find查找，很方便的</p>
<p>在有些操作系统中只允许-exec选项执行诸如l s或ls -l这样的命令。大多数用户使用这一选项是为了查找旧文件并删除它们。建议在真正执行rm命令删除文件之前，最好先用ls命令看一下，确认它们是所要删除的文件。</p>
<p>exec选项后面跟随着所要执行的命令或脚本，然后是一对儿{ }，一个空格和一个\，最后是一个分号。为了使用exec选项，必须要同时使用print选项。如果验证一下find命令，会发现该命令只输出从当前路径起的相对路径及文件名。</p>
<p>例如：为了用ls -l命令列出所匹配到的文件，可以把ls -l命令放在find命令的-exec选项中</p>
<div><code># find . -type f -exec ls -l {  } \;<br />
-rw-r--r--    1 root     root        34928 2003-02-25  ./conf/httpd.conf<br />
-rw-r--r--    1 root     root        12959 2003-02-25  ./conf/magic<br />
-rw-r--r--    1 root     root          180 2003-02-25  ./conf.d/README</code></div>
<p>上面的例子中，find命令匹配到了当前目录下的所有普通文件，并在-exec选项中使用ls -l命令将它们列出。<br />
在/logs目录中查找更改时间在5日以前的文件并删除它们：</p>
<div><code>$ find logs -type f -mtime +5 -exec rm {  } \;</code></div>
<p><strong>记住：</strong>在shell中用任何方式删除文件之前，应当先查看相应的文件，一定要小心！当使用诸如mv或rm命令时，可以使用-exec选项的安全模式。它将在对每个匹配到的文件进行操作之前提示你。</p>
<p>在下面的例子中， find命令在当前目录中查找所有文件名以.LOG结尾、更改时间在5日以上的文件，并删除它们，只不过在删除之前先给出提示。</p>
<div><code>$ find . -name "*.conf"  -mtime +5 -ok rm {  } \;<br />
&lt; rm ... ./conf/httpd.conf &gt; ? n</code></div>
<p>按y键删除文件，按n键不删除。</p>
<p>任何形式的命令都可以在-exec选项中使用。</p>
<p>在下面的例子中我们使用grep命令。find命令首先匹配所有文件名为“ passwd*”的文件，例如passwd、passwd.old、passwd.bak，然后执行grep命令看看在这些文件中是否存在一个sam用户。</p>
<div><code># find /etc -name "passwd*" -exec grep "sam" {  } \;<br />
sam:x:501:501::/usr/sam:/bin/bash</code></div>
<p><span style="font-size: medium;"><strong><br />
二、find命令的例子；<br />
</strong></span></p>
<p><span style="font-size: small;"><strong><br />
1、查找当前用户主目录下的所有文件：<br />
</strong></span></p>
<p>下面两种方法都可以使用</p>
<div><code>$ find $HOME -print<br />
$ find ~ -print</code></div>
<p><span style="font-size: small;"><strong><br />
2、让当前目录中文件属主具有读、写权限，并且文件所属组的用户和其他用户具有读权限的文件；<br />
</strong></span></p>
<div><code>$ find . -type f -perm 644 -exec ls -l {  } \;</code></div>
<p><span style="font-size: small;"><strong><br />
3、为了查找系统中所有文件长度为0的普通文件，并列出它们的完整路径；<br />
</strong></span></p>
<div><code>$ find / -type f -size 0 -exec ls -l {  } \;</code></div>
<p><span style="font-size: small;"><strong><br />
4、查找/var/logs目录中更改时间在7日以前的普通文件，并在删除之前询问它们；<br />
</strong></span></p>
<div><code>$ find /var/logs -type f -mtime +7 -ok rm {  } \;</code></div>
<p><span style="font-size: small;"><strong><br />
5、为了查找系统中所有属于root组的文件；<br />
</strong></span></p>
<div><code>$find . -group root -exec ls -l {  } \;<br />
-rw-r--r--    1 root     root          595 10月 31 01:09 ./fie1</code></div>
<p><span style="font-size: small;"><strong><br />
6、find命令将删除当目录中访问时间在7日以来、含有数字后缀的admin.log文件。<br />
</strong></span></p>
<p>该命令只检查三位数字，所以相应文件的后缀不要超过999。先建几个admin.log*的文件 ，才能使用下面这个命令</p>
<div><code>$ find . -name "admin.log[0-9][0-9][0-9]" -atime -7  -ok<br />
rm {  } \;<br />
&lt; rm ... ./admin.log001 &gt; ? n<br />
&lt; rm ... ./admin.log002 &gt; ? n<br />
&lt; rm ... ./admin.log042 &gt; ? n<br />
&lt; rm ... ./admin.log942 &gt; ? n</code></div>
<p><span style="font-size: small;"><strong><br />
7、为了查找当前文件系统中的所有目录并排序；<br />
</strong></span></p>
<div><code>$ find . -type d | sort</code></div>
<p><span style="font-size: small;"><strong><br />
8、为了查找系统中所有的rmt磁带设备；<br />
</strong></span></p>
<div><code>$ find /dev/rmt -print</code></div>
<p><span style="font-size: medium;"><strong><br />
三、xargs<br />
</strong></span></p>
<p>xargs &#8211; build and execute command lines from standard input</p>
<p>在使用find命令的-exec选项处理匹配到的文件时，  find命令将所有匹配到的文件一起传递给exec执行。但有些系统对能够传递给exec的命令长度有限制，这样在find命令运行几分钟之后，就会出现 溢出错误。错误信息通常是“参数列太长”或“参数列溢出”。这就是xargs命令的用处所在，特别是与find命令一起使用。</p>
<p>find命令把匹配到的文件传递给xargs命令，而xargs命令每次只获取一部分文件而不是全部，不像-exec选项那样。这样它可以先处理最先获取的一部分文件，然后是下一批，并如此继续下去。</p>
<p>在有些系统中，使用-exec选项会为处理每一个匹配到的文件而发起一个相应的进程，并非将匹配到的文件全部作为参数一次执行；这样在有些情况下就会出现进程过多，系统性能下降的问题，因而效率不高；</p>
<p>而使用xargs命令则只有一个进程。另外，在使用xargs命令时，究竟是一次获取所有的参数，还是分批取得参数，以及每一次获取参数的数目都会根据该命令的选项及系统内核中相应的可调参数来确定。</p>
<p>来看看xargs命令是如何同find命令一起使用的，并给出一些例子。</p>
<p>下面的例子查找系统中的每一个普通文件，然后使用xargs命令来测试它们分别属于哪类文件</p>
<div><code>#find . -type f -print | xargs file<br />
./.kde/Autostart/Autorun.desktop: UTF-8 Unicode English text<br />
./.kde/Autostart/.directory:      ISO-8859 text\<br />
......</code></div>
<p>在整个系统中查找内存信息转储文件(core dump) ，然后把结果保存到/tmp/core.log 文件中：</p>
<div><code>$ find / -name "core" -print | xargs echo "" &gt;/tmp/core.log</code></div>
<p>上面这个执行太慢，我改成在当前目录下查找</p>
<div><code>#find . -name "file*" -print | xargs echo "" &gt; /temp/core.log<br />
# cat /temp/core.log<br />
./file6</code></div>
<p>在当前目录下查找所有用户具有读、写和执行权限的文件，并收回相应的写权限：</p>
<div><code># ls -l<br />
drwxrwxrwx    2 sam      adm          4096 10月 30 20:14 file6<br />
-rwxrwxrwx    2 sam      adm             0 10月 31 01:01 http3.conf<br />
-rwxrwxrwx    2 sam      adm             0 10月 31 01:01 httpd.conf</code></p>
<p># find . -perm -7 -print | xargs chmod o-w<br />
# ls -l<br />
drwxrwxr-x    2 sam      adm          4096 10月 30 20:14 file6<br />
-rwxrwxr-x    2 sam      adm             0 10月 31 01:01 http3.conf<br />
-rwxrwxr-x    2 sam      adm             0 10月 31 01:01 httpd.conf</p>
</div>
<p>用grep命令在所有的普通文件中搜索hostname这个词：</p>
<div><code># find . -type f -print | xargs grep "hostname"<br />
./httpd1.conf:#     different IP addresses or hostnames and have them handled by the<br />
./httpd1.conf:# VirtualHost: If you want to maintain multiple domains/hostnames<br />
on your</code></div>
<p>用grep命令在当前目录下的所有普通文件中搜索hostnames这个词：</p>
<div><code># find . -name \* -type f -print | xargs grep "hostnames"<br />
./httpd1.conf:#     different IP addresses or hostnames and have them handled by the<br />
./httpd1.conf:# VirtualHost: If you want to maintain multiple domains/hostnames<br />
on your</code></div>
<p>注意，在上面的例子中， \用来取消find命令中的*在shell中的特殊含义。</p>
<p>find命令配合使用exec和xargs可以使用户对所匹配到的文件执行几乎所有的命令。</p>
<p><span style="font-size: medium;"><strong><br />
四、find 命令的参数<br />
</strong></span></p>
<p>下面是find一些常用参数的例子，有用到的时候查查就行了，像上面前几个贴子，都用到了其中的的一些参数，也可以用man或查看论坛里其它贴子有find的命令手册</p>
<p><span style="font-size: small;"><strong><br />
1、使用name选项<br />
</strong></span></p>
<p>文件名选项是find命令最常用的选项，要么单独使用该选项，要么和其他选项一起使用。</p>
<p>可以使用某种文件名模式来匹配文件，记住要用引号将文件名模式引起来。</p>
<p>不管当前路径是什么，如果想要在自己的根目录$HOME中查找文件名符合*.txt的文件，使用~作为 &#8216;pathname&#8217;参数，波浪号~代表了你的$HOME目录。</p>
<div><code>$ find ~ -name "*.txt" -print</code></div>
<p>想要在当前目录及子目录中查找所有的‘ *.txt’文件，可以用：</p>
<div><code>$ find . -name "*.txt" -print</code></div>
<p>想要的当前目录及子目录中查找文件名以一个大写字母开头的文件，可以用：</p>
<div><code>$ find . -name "[A-Z]*" -print</code></div>
<p>想要在/etc目录中查找文件名以host开头的文件，可以用：</p>
<div><code>$ find /etc -name "host*" -print</code></div>
<p>想要查找$HOME目录中的文件，可以用：</p>
<div><code>$ find ~ -name "*" -print 或find . -print</code></div>
<p>要想让系统高负荷运行，就从根目录开始查找所有的文件。</p>
<div><code>$ find / -name "*" -print</code></div>
<p>如果想在当前目录查找文件名以两个小写字母开头，跟着是两个数字，最后是.txt的文件，下面的命令就能够返回名为ax37.txt的文件：</p>
<div><code>$find . -name "[a-z][a-z][0--9][0--9].txt" -print</code></div>
<p><span style="font-size: small;"><strong><br />
2、用perm选项<br />
</strong></span></p>
<p>按照文件权限模式用-perm选项,按文件权限模式来查找文件的话。最好使用八进制的权限表示法。</p>
<p>如在当前目录下查找文件权限位为755的文件，即文件属主可以读、写、执行，其他用户可以读、执行的文件，可以用：</p>
<div><code>$ find . -perm 755 -print</code></div>
<p>还有一种表达方法：在八进制数字前面要加一个横杠-，表示都匹配，如-007就相当于777，-006相当于666</p>
<div><code># ls -l<br />
-rwxrwxr-x    2 sam      adm             0 10月 31 01:01 http3.conf<br />
-rw-rw-rw-    1 sam      adm         34890 10月 31 00:57 httpd1.conf<br />
-rwxrwxr-x    2 sam      adm             0 10月 31 01:01 httpd.conf<br />
drw-rw-rw-    2 gem      group        4096 10月 26 19:48 sam<br />
-rw-rw-rw-    1 root     root         2792 10月 31 20:19 temp</code></p>
<p># find . -perm 006<br />
# find . -perm -006<br />
./sam<br />
./httpd1.conf<br />
./temp</p>
</div>
<p>-perm mode:文件许可正好符合mode</p>
<p>-perm +mode:文件许可部分符合mode</p>
<p>-perm -mode: 文件许可完全符合mode</p>
<p><span style="font-size: small;"><strong><br />
3、忽略某个目录<br />
</strong></span></p>
<p>如果在查找文件时希望忽略某个目录，因为你知道那个目录中没有你所要查找的文件，那么可以使用-prune选项来指出需要忽略的目录。在使用-prune选项时要当心，因为如果你同时使用了-depth选项，那么-prune选项就会被find命令忽略。</p>
<p>如果希望在/apps目录下查找文件，但不希望在/apps/bin目录下查找，可以用：</p>
<div><code>$ find /apps -path "/apps/bin" -prune -o -print</code></div>
<p><span style="font-size: small;"><strong><br />
4、使用find查找文件的时候怎么避开某个文件目录<br />
</strong></span></p>
<p>比如要在/usr/sam目录下查找不在dir1子目录之内的所有文件</p>
<div><code>find /usr/sam -path "/usr/sam/dir1" -prune -o -print </code></div>
<div><code>find [-path ..] [expression] 在路径列表的后面的是表达式</code></div>
<p>-path &#8220;/usr/sam&#8221; -prune -o -print 是 -path &#8220;/usr/sam&#8221; -a -prune -o<br />
-print 的简写表达式按顺序求值, -a 和 -o 都是短路求值，与 shell 的 &amp;&amp; 和 || 类似如果 -path  &#8220;/usr/sam&#8221; 为真，则求值 -prune , -prune 返回真，与逻辑表达式为真；否则不求值 -prune，与逻辑表达式为假。如果  -path &#8220;/usr/sam&#8221; -a -prune 为假，则求值 -print ，-print返回真，或逻辑表达式为真；否则不求值  -print，或逻辑表达式为真。</p>
<p>这个表达式组合特例可以用伪码写为</p>
<div><code>if -path "/usr/sam"  then<br />
-prune<br />
else<br />
-print</code></div>
<p>避开多个文件夹</p>
<div><code>find /usr/sam \( -path /usr/sam/dir1 -o -path /usr/sam/file1 \) -prune -o -print</code></div>
<p>圆括号表示表达式的结合。</p>
<div><code>\ 表示引用，即指示 shell 不对后面的字符作特殊解释，而留给 find 命令去解释其意义。</code></div>
<p>查找某一确定文件，-name等选项加在-o 之后</p>
<div><code>#find /usr/sam  \(-path /usr/sam/dir1 -o -path /usr/sam/file1 \) -prune -o -name "temp" -print</code></div>
<p><span style="font-size: small;"><strong><br />
5、使用user和nouser选项<br />
</strong></span></p>
<p>按文件属主查找文件，如在$HOME目录中查找文件属主为sam的文件，可以用：</p>
<div><code>$ find ~ -user sam -print</code></div>
<p>在/etc目录下查找文件属主为uucp的文件：</p>
<div><code>$ find /etc -user uucp -print</code></div>
<p>为了查找属主帐户已经被删除的文件，可以使用-nouser选项。这样就能够找到那些属主在/etc/passwd文件中没有有效帐户的文件。在使用-nouser选项时，不必给出用户名； find命令能够为你完成相应的工作。</p>
<p>例如，希望在/home目录下查找所有的这类文件，可以用：</p>
<div><code>$ find /home -nouser -print</code></div>
<p><span style="font-size: small;"><strong><br />
6、使用group和nogroup选项<br />
</strong></span></p>
<p>就像user和nouser选项一样，针对文件所属于的用户组， find命令也具有同样的选项，为了在/apps目录下查找属于gem用户组的文件，可以用：</p>
<div><code>$ find /apps -group gem -print</code></div>
<p>要查找没有有效所属用户组的所有文件，可以使用nogroup选项。下面的find命令从文件系统的根目录处查找这样的文件</p>
<div><code>$ find / -nogroup-print</code></div>
<p><span style="font-size: small;"><strong><br />
7、按照更改时间或访问时间等查找文件<br />
</strong></span></p>
<p>如果希望按照更改时间来查找文件，可以使用mtime,atime或ctime选项。如果系统突然没有可用空间了，很有可能某一个文件的长度在此期间增长迅速，这时就可以用mtime选项来查找这样的文件。</p>
<p>用减号-来限定更改时间在距今n日以内的文件，而用加号+来限定更改时间在距今n日以前的文件。</p>
<p>希望在系统根目录下查找更改时间在5日以内的文件，可以用：</p>
<div><code>$ find / -mtime -5 -print</code></div>
<p>为了在/var/adm目录下查找更改时间在3日以前的文件，可以用：</p>
<div><code>$ find /var/adm -mtime +3 -print</code></div>
<p><span style="font-size: small;"><strong><br />
8、查找比某个文件新或旧的文件<br />
</strong></span></p>
<p>如果希望查找更改时间比某个文件新但比另一个文件旧的所有文件，可以使用-newer选项。它的一般形式为：</p>
<div><code>newest_file_name ! oldest_file_name</code></div>
<p>其中，！是逻辑非符号。</p>
<p>查找更改时间比文件sam新但比文件temp旧的文件：</p>
<p>例：有两个文件</p>
<div><code>-rw-r--r--    1 sam      adm             0 10月 31 01:07 fiel<br />
-rw-rw-rw-    1 sam      adm         34890 10月 31 00:57 httpd1.conf<br />
-rwxrwxr-x    2 sam      adm             0 10月 31 01:01 httpd.conf<br />
drw-rw-rw-    2 gem      group        4096 10月 26 19:48 sam<br />
-rw-rw-rw-    1 root     root         2792 10月 31 20:19 temp</code></p>
<p># find -newer httpd1.conf  ! -newer temp -ls<br />
1077669    0 -rwxrwxr-x   2 sam      adm             0 10月 31 01:01 ./httpd.conf<br />
1077671    4 -rw-rw-rw-   1 root     root         2792 10月 31 20:19 ./temp<br />
1077673    0 -rw-r&#8211;r&#8211;   1 sam      adm             0 10月 31 01:07 ./fiel</p>
</div>
<p>查找更改时间在比temp文件新的文件：</p>
<div><code>$ find . -newer temp -print</code></div>
<p><span style="font-size: small;"><strong><br />
9、使用type选项<br />
</strong></span></p>
<p>在/etc目录下查找所有的目录，可以用：</p>
<div><code>$ find /etc -type d -print</code></div>
<p>在当前目录下查找除目录以外的所有类型的文件，可以用：</p>
<div><code>$ find . ! -type d -print</code></div>
<p>在/etc目录下查找所有的符号链接文件，可以用</p>
<div><code>$ find /etc -type l -print</code></div>
<p><span style="font-size: small;"><strong><br />
10、使用size选项<br />
</strong></span></p>
<p>可以按照文件长度来查找文件，这里所指的文件长度既可以用块（block）来计量，也可以用字节来计量。以字节计量文件长度的表达形式为N c；以块计量文件长度只用数字表示即可。</p>
<p>在按照文件长度查找文件时，一般使用这种以字节表示的文件长度，在查看文件系统的大小，因为这时使用块来计量更容易转换。<br />
在当前目录下查找文件长度大于1 M字节的文件：</p>
<div><code>$ find . -size +1000000c -print</code></div>
<p>在/home/apache目录下查找文件长度恰好为100字节的文件：</p>
<div><code>$ find /home/apache -size 100c -print</code></div>
<p>在当前目录下查找长度超过10块的文件（一块等于512字节）：</p>
<div><code>$ find . -size +10 -print</code></div>
<p><span style="font-size: small;"><strong><br />
11、使用depth选项<br />
</strong></span></p>
<p>在使用find命令时，可能希望先匹配所有的文件，再在子目录中查找。使用depth选项就可以使find命令这样做。这样做的一个原因就是，当在使用find命令向磁带上备份文件系统时，希望首先备份所有的文件，其次再备份子目录中的文件。</p>
<p>在下面的例子中， find命令从文件系统的根目录开始，查找一个名为CON.FILE的文件。</p>
<p>它将首先匹配所有的文件然后再进入子目录中查找。</p>
<div><code>$ find / -name "CON.FILE" -depth -print</code></div>
<p><span style="font-size: small;"><strong><br />
12、使用mount选项<br />
</strong></span></p>
<p>在当前的文件系统中查找文件（不进入其他文件系统），可以使用find命令的mount选项。</p>
<p>从当前目录开始查找位于本文件系统中文件名以XC结尾的文件：</p>
<div><code>$ find . -name "*.XC" -mount -print</code></div>
<p><span style="font-size: medium;"><strong>五、关于本文</strong></span></p>
<p>本文是find 命令的详细说明，可贵的是针对参数举了很多的实例，大量的例证，让初学者更为容易理解；本文是<a href="http://www.linuxsir.org/bbs/member.php?u=57037" target="_blank">zhy2111314</a>兄贴在论坛中；我对本文进行了再次整理，为方便大家阅读； ── 北南南北</p>
]]></content:encoded>
			<wfw:commentRss>http://wyj.zhuwo.info/2010/08/linux%e6%96%87%e4%bb%b6%e6%9f%a5%e6%89%be%e5%91%bd%e4%bb%a4find-xargs%e8%af%a6%e8%bf%b0-zz/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

