<?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>Chris &#187; Linux / Unix</title>
	<atom:link href="http://blog.hehachris.com/archives/category/linux-unix/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.hehachris.com</link>
	<description>沉默是因為包容</description>
	<lastBuildDate>Thu, 11 Nov 2010 08:55:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySQL: To Check, Repair &amp; Optimize All Tables in All Databases</title>
		<link>http://blog.hehachris.com/archives/192</link>
		<comments>http://blog.hehachris.com/archives/192#comments</comments>
		<pubDate>Sat, 04 Jul 2009 20:23:24 +0000</pubDate>
		<dc:creator>Chris Lam</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://blog.hehachris.com/?p=192</guid>
		<description><![CDATA[mysqlcheck -u root -p --auto-repair --check --optimize -A
]]></description>
		<wfw:commentRss>http://blog.hehachris.com/archives/192/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>APF + BFD replaced by CSF</title>
		<link>http://blog.hehachris.com/archives/154</link>
		<comments>http://blog.hehachris.com/archives/154#comments</comments>
		<pubDate>Tue, 16 Dec 2008 12:35:21 +0000</pubDate>
		<dc:creator>Chris Lam</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://blog.hehachris.com/?p=154</guid>
		<description><![CDATA[CSF = ConfigServer Firewall
CSF 和 APF 同樣是透過讀取配置文件自動產生 iptables rules 的程式，撇除功能不說，兩者主要分別在於前者用 Perl 編寫，後者則純綷是一個 200 多行的 Bash Script.
基於 CSF 乃 Perl 所編寫，功能上自然比 APF 強大得多，而內建的 Login Failure Daemon (lfd) 正好可替換 BFD。再加上貼心的 Webmin Module，令我很久之前已經想把所有主機的firewall軟件轉為 CSF。但礙於所有主機的 APF + BFD 都一直運行正常而且可靠，新 firewall 又不知效果如何，實在不想花時間拿 production server 來冒險=.=
前天設定新主機時很順手地一併安裝了 APF + BFD，後來想想新主機用新 firewall 應該不要緊吧，於是就按照 DirectAdmin Forum 裡的 CSF Howto 安裝 CSF 並把 APF + [...]]]></description>
		<wfw:commentRss>http://blog.hehachris.com/archives/154/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[OpenVZ] 設定 VE 的 Ram Quota</title>
		<link>http://blog.hehachris.com/archives/106</link>
		<comments>http://blog.hehachris.com/archives/106#comments</comments>
		<pubDate>Thu, 06 Mar 2008 15:31:46 +0000</pubDate>
		<dc:creator>Chris Lam</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://chris.knetgb.com/archives/106</guid>
		<description><![CDATA[VMGUARPAGES=&#34;32768:2147483647&#34; // 128MB Guaranteed
VMGUARPAGES=&#34;65536:2147483647&#34; // 256MB Guaranteed
VMGUARPAGES=&#34;131072:2147483647&#34; // 512MB Guaranteed
&#160;
PRIVVMPAGES=&#34;64000:65536&#34; // 256MB Burst
PRIVVMPAGES=&#34;128000:131072&#34; // 512MB Burst
PRIVVMPAGES=&#34;256000:262140&#34; // 1024MB Burst
]]></description>
		<wfw:commentRss>http://blog.hehachris.com/archives/106/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Apache] No space left on device: mod_rewrite</title>
		<link>http://blog.hehachris.com/archives/105</link>
		<comments>http://blog.hehachris.com/archives/105#comments</comments>
		<pubDate>Sun, 24 Feb 2008 09:16:17 +0000</pubDate>
		<dc:creator>Chris Lam</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://chris.knetgb.com/archives/105</guid>
		<description><![CDATA[最近 Apache 經常無故死掉，查看 log 檔卻只看見：
[Sun Feb 24 16:48:46 2008] [crit] (28)No space left on device: mod_rewrite: could not create rewrite_log_lock
Configuration Failed
但當時主機各方面都很正常，絕無可能不夠 space/memory，解決方法就是 reboot = =
後來 google 一下，找到一個 work around，原理是刪除 Semaphores Array:
# ipcs -s &#124; grep apache &#124; awk '{ print $2 }' &#124; xargs ipcrm sem
]]></description>
		<wfw:commentRss>http://blog.hehachris.com/archives/105/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在 Shell 中產生隨機字串</title>
		<link>http://blog.hehachris.com/archives/104</link>
		<comments>http://blog.hehachris.com/archives/104#comments</comments>
		<pubDate>Sat, 23 Feb 2008 11:02:21 +0000</pubDate>
		<dc:creator>Chris Lam</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://chris.knetgb.com/archives/104</guid>
		<description><![CDATA[在 Linux/Unix 的 shell 中，似乎沒有一個指令可以產生隨機字串。網上看到很多使用 PERL 寫成的 shell script，都離不開 for 還圈。這些都是很笨的做法，因為用 PERL 一句指令就可以做到了：
# perl -le 'print map+(A..Z,a..z,0..9)[rand 62],0..7'
以上指令會產生 8 個位由 A-Za-z0-9 組成的隨機字串，意思很明顯吧。
]]></description>
		<wfw:commentRss>http://blog.hehachris.com/archives/104/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux 上查看佔用指定端口的進程</title>
		<link>http://blog.hehachris.com/archives/48</link>
		<comments>http://blog.hehachris.com/archives/48#comments</comments>
		<pubDate>Wed, 26 Sep 2007 13:55:41 +0000</pubDate>
		<dc:creator>Chris Lam</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://chris.knetgb.com/archives/48</guid>
		<description><![CDATA[在 Linux 上，如果想找出佔用某個 port 的進程，可使用 fuser 指令。
找出佔用 TCP port 8080 的進程:
# fuser -v 8080/tcp
砍掉佔用 TCP port 8080 的進程:
# fuser -k 8080/tcp
]]></description>
		<wfw:commentRss>http://blog.hehachris.com/archives/48/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shell Script 變量中的路徑解析</title>
		<link>http://blog.hehachris.com/archives/29</link>
		<comments>http://blog.hehachris.com/archives/29#comments</comments>
		<pubDate>Mon, 22 Jan 2007 18:35:13 +0000</pubDate>
		<dc:creator>Chris Lam</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://chris.knetgb.com/archives/29</guid>
		<description><![CDATA[編寫 Shell Script 時，如果變量的值是一個路徑的話，我們可以輕易擷取當中的路徑 (dirname) 或檔名 (basename).


變量
結果
說明


${path}
/usr/local/bin/emacs
原本值


${path#/*/}
local/bin/emacs
去除第一個資料夾


${path##/*/}
emacs
只取檔名 (basname)


${path%/*}
/usr/local/bin
只取路徑 (dirname)


${path:15}
emacs
取第 15 個字元後的所有字元


${path:10:4}
/bin
取第 10 個字元後的 4 個字元


最後兩個用法與 Java 的 subString 相同。
]]></description>
		<wfw:commentRss>http://blog.hehachris.com/archives/29/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>刪除超大量 (eg 5000+) 檔案</title>
		<link>http://blog.hehachris.com/archives/28</link>
		<comments>http://blog.hehachris.com/archives/28#comments</comments>
		<pubDate>Mon, 22 Jan 2007 17:53:48 +0000</pubDate>
		<dc:creator>Chris Lam</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://chris.knetgb.com/archives/28</guid>
		<description><![CDATA[如果嘗試使用 rm -f * 刪除超大量檔案 (eg 5000+)，有可能會得到這個結果: Argument list too long
這種情況下唯有使用 FOR 迴圈，以一個指令便可把檔案逐個刪除:
for i in $(find /home/peter -type f); do rm -f $i; done
或者照樣使用 FOR 迴圈寫一個 Shell Script，每次刪除 10 個檔案 (沒測試過, USE AT YOUR OWN RISK):
#!/bin/sh
&#160;
FILES=&#34;&#34;;
i=1;
&#160;
for i in $(find /home/peter -type f); do
&#160;
&#160;&#160; FILES=&#34;${FILES} $i&#34;
&#160;&#160; if [ $index -eq 10 ]; then
&#160;&#160; &#160; &#160;rm -f [...]]]></description>
		<wfw:commentRss>http://blog.hehachris.com/archives/28/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>關閉 Linux Kernel 的 IPv6 支援</title>
		<link>http://blog.hehachris.com/archives/21</link>
		<comments>http://blog.hehachris.com/archives/21#comments</comments>
		<pubDate>Thu, 16 Nov 2006 20:53:45 +0000</pubDate>
		<dc:creator>Chris Lam</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://chris.knetgb.com/archives/21</guid>
		<description><![CDATA[IPv6 (Internet Protocol Version 6) 多年來一直無法順利推動，本港的 ISP 更不在話下。但大部份 Linux Distro 的 kernel 都預設支援 IPv6，直接影響了網絡效能。以下方法可關閉 IPv6 支援:
Debian / Ubuntu
1. 開啟 /etc/modprobe.d/aliases
2. 裡面有一行是 &#8220;alias net-pf-10 ipv6&#8243;
3. 將以上一行用以下兩行取代:
alias net-pf-10 off
alias ipv6 off
Red Hat
1. 開啟 /etc/modprobe.conf
2. 加入這一行:
alias net-pf-10 off
更改以上檔案後，需要重新啟動系統才會生效。我在數部 CentOS 及 Fedora 主機關閉 IPv6 後，Resolve IP 的時間明顯加快了。
]]></description>
		<wfw:commentRss>http://blog.hehachris.com/archives/21/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ex 單行指令: 處理文字檔案</title>
		<link>http://blog.hehachris.com/archives/16</link>
		<comments>http://blog.hehachris.com/archives/16#comments</comments>
		<pubDate>Thu, 02 Nov 2006 15:18:42 +0000</pubDate>
		<dc:creator>Chris Lam</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://chris.knetgb.com/?p=16</guid>
		<description><![CDATA[以往需要從文字檔中進行 Search &#038; Replace, 通常都會使用 PERL。
但其實使用 VIM 的 ex 模式便可作更快的處理。
刪除特定字串:
echo '/delete_me/d &#124; x!' &#124; ex - 123.txt
&#160;
Search &#038; Replace:
echo '%s/search/replace/g &#124; x!' &#124; ex - 123.txt
]]></description>
		<wfw:commentRss>http://blog.hehachris.com/archives/16/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

