<?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/"
	xmlns:georss="http://www.georss.org/georss">

<channel>
	<title>Here comes the Sun &#187; shell</title>
	<atom:link href="http://sunng.info/blog/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://sunng.info/blog</link>
	<description>Life ramblings</description>
	<lastBuildDate>Thu, 02 Sep 2010 12:29:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Performance Visualization with Gnuplot, continued</title>
		<link>http://sunng.info/blog/2009/09/performance-visualization-with-gnuplot-continued/</link>
		<comments>http://sunng.info/blog/2009/09/performance-visualization-with-gnuplot-continued/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 13:07:46 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[gnuplot]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[vmstat]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=203</guid>
		<description><![CDATA[After I post my command to commandlinefu.com, there is an alternative command followed: (echo &#8220;set terminal png;plot &#8216;-&#8217; u 1:2 t &#8216;cpu&#8217; w linespoints;&#8221;; sudo vmstat 2 10 &#124; awk &#8216;NR &#62; 2 {print NR, $13}&#8217;) &#124; gnuplot &#62; plot.png This one is appreciated for using pipes and redirection. It works on Ubuntu Jaunty, on [...]]]></description>
			<content:encoded><![CDATA[<p>After I post my command to <a href="http://www.commandlinefu.com/" target="_blank">commandlinefu.com</a>, there is an alternative command followed:<br />
<em>(echo &#8220;set terminal png;plot &#8216;-&#8217; u 1:2 t &#8216;cpu&#8217; w linespoints;&#8221;; sudo vmstat 2 10 | awk &#8216;NR &gt; 2 {print NR, $13}&#8217;) | gnuplot &gt; plot.png</em></p>
<p>This one is appreciated for using pipes and redirection. It works on Ubuntu Jaunty, on which, gnuplot doesn&#8217;t provide a -e option. The author also showed an link to an open source project &#8216;vmplot&#8217; on <a href="http://freshmeat.net/projects/vmplot/" target="_blank">freshmeat</a>. Vmplot is written in python, which combines parameters with scripts and end up with an os.system call. Grab the source from <a href="http://elvis.elte.hu/~fuji/stuff/vmplot.py" target="_blank">here</a>. (Why use python instead on a simple bash command? because it&#8217;s difficult to draw a multiplot without temp file or variables, you cannot read &#8216;-&#8217; twice.)</p>
<p>There are several people vote me down for my command! It must be primers whose use ubuntu and knows the world via Synaptic only, because they failed to run the command on their dated machine (*_*)</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/09/performance-visualization-with-gnuplot-continued/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DB dump with chroot</title>
		<link>http://sunng.info/blog/2009/07/db-dump-with-chroot/</link>
		<comments>http://sunng.info/blog/2009/07/db-dump-with-chroot/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 11:59:07 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=104</guid>
		<description><![CDATA[I caught chroot first time when attempting to install gentoo linux. Of course, its a tool of great useful. Two months ago I had my laptop crashed, and all static files were recovery easily by copy while raw db data file seems to be difficult to handle. The old file system is in a mobile [...]]]></description>
			<content:encoded><![CDATA[<p>I caught chroot first time when attempting to install gentoo linux. Of course, its a tool of great useful. Two months ago I had my laptop crashed, and all static files were recovery easily by copy while raw db data file seems to be difficult to handle.</p>
<p>The old file system is in a mobile disk, mounted at /media/disk-1/. Now I try to use chroot to rollback to that environment, so that all standard dump tools will be available.</p>
<p>Before you chroot to the system, don&#8217;t forget to bind /dev to new location. Or you might get error prompt such as &#8220;/dev/null Permission Denied&#8221; (it&#8217;s a common error). Just execute command below:<br />
<em>$ sudo mount &#8211;bind /dev /media/disk-1/dev</em></p>
<p>Then change root to my old system:<br />
<em>$ sudo chroot /media/disk-1</em></p>
<p>Now you become root user automatically.</p>
<h3>MySQL Dump</h3>
<p>In a standard ubuntu mysql installation, we should launch mysql db from init.d by:<br />
<em># /etc/init.d/mysql start</em></p>
<p>But it&#8217;s no longer available in such environment. Fortunately, there is a direct way:<br />
<em># mysqld_safe &amp;</em></p>
<p>OK, go on to dump database with mysqldump:<br />
<em># mysqldump &#8211;all-databases &gt; mysql_dump_file</em></p>
<h3>Postgresql Dump</h3>
<p>We cannot use init.d to start pgsql either. Therefore, try to run it by:<br />
<em># su postgres -c &#8220;/usr/lib/postgresql/8.3/bin/pg_ctl start -D /etc/postgresql/8.3/main&#8221;</em></p>
<p><em>/etc/postgresql/8.3/main</em> is the default data directory in standard installation(with apt-get). This directory is supposed to contain a file named with &#8220;postgesql.conf&#8221;</p>
<p>Now pgsql db is also running. As root user we have no privilege to run pgsql utilities. so take following steps:<br />
<em># touch pgsql_dump_file<br />
# chmod a+w pgsql_dump_file<br />
# su postgres -c &#8220;pg_dumpall -f pgsql_dump_file&#8221;</em></p>
<h3>Conclusion</h3>
<p>Personally, I found it&#8217;s too complex and low efficiency to backup and restore data with mysql and postgresql. If there is no critical requirement(just like personal data management), file based db(Surely I mean sqlite) is no doubt better choice. Easy management(lots of gui tool now provided), smooth copy and move, standard db interface for programming, and enough functionality.</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/07/db-dump-with-chroot/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>早起，写一个变色的小程序</title>
		<link>http://sunng.info/blog/2009/05/%e6%97%a9%e8%b5%b7%ef%bc%8c%e5%86%99%e4%b8%80%e4%b8%aa%e5%8f%98%e8%89%b2%e7%9a%84%e5%b0%8f%e7%a8%8b%e5%ba%8f/</link>
		<comments>http://sunng.info/blog/2009/05/%e6%97%a9%e8%b5%b7%ef%bc%8c%e5%86%99%e4%b8%80%e4%b8%aa%e5%8f%98%e8%89%b2%e7%9a%84%e5%b0%8f%e7%a8%8b%e5%ba%8f/#comments</comments>
		<pubDate>Tue, 05 May 2009 01:29:32 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[把戏]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=63</guid>
		<description><![CDATA[以前用Windows的时候，我是说用XP的时候，因为不支持颜色主题，也无从知晓如何通过自动化的方式更换Windows的主题，所以，经常是人肉地每天换主题（其实只是为了换标题栏的颜色），追求新鲜感。 现在用Gnome桌面以后依然保持着这种爱好。遗憾是之前一直没有找到设置存放的位置。前两天在command-line-fu上恰好看到一个变换桌面背景的命令，原来这类配置都存放在gconf里，用gconftool就可以进行操作了。 然后很容易地就能在图形化配置管理器里找到颜色配置的键值位于/desktop/gnome/interface/gtk_color_scheme，值是一个用换行符隔开的名值对，内容就是我们在Appearance配置窗口里看到的那些。good，写个shell小程序每天换颜色！ 以下是我孱弱的shell脚本： [codesyntax lang="bash" lines="fancy"] case `date +%w` in 0) color='#C4C4A0A00000';; 1) color='#CECE5C5C0000';; 2) color='#8F8F59590202';; 3) color='#4E4E9A9A0606';; 4) color='#20204A4A8787';; 5) color='#5C5C35356666';; 6) color='#A4A400000000';; esac sedcommand="s/\(selected_bg_color:\)\(.*\)/\1$color/" color_scheme=`gconftool-2 -g /desktop/gnome/interface/gtk_color_scheme &#124; sed $sedcommand` gconftool-2 -t string -s /desktop/gnome/interface/gtk_color_scheme "$color_scheme" [/codesyntax] 每天一换，颜色是tango调色板里的色彩，HOHOHAHA]]></description>
			<content:encoded><![CDATA[<p>以前用Windows的时候，我是说用XP的时候，因为不支持颜色主题，也无从知晓如何通过自动化的方式更换Windows的主题，所以，经常是人肉地每天换主题（其实只是为了换标题栏的颜色），追求新鲜感。<br />
现在用Gnome桌面以后依然保持着这种爱好。遗憾是之前一直没有找到设置存放的位置。前两天在<a href="http://www.commandlinefu.com" target="_parent">command-line-fu</a>上恰好看到一个变换桌面背景的命令，原来这类配置都存放在gconf里，用gconftool就可以进行操作了。<br />
然后很容易地就能在图形化配置管理器里找到颜色配置的键值位于/desktop/gnome/interface/gtk_color_scheme，值是一个用换行符隔开的名值对，内容就是我们在Appearance配置窗口里看到的那些。good，写个shell小程序每天换颜色！<br />
以下是我孱弱的shell脚本：<br />
[codesyntax lang="bash" lines="fancy"]</p>
<pre>case `date +%w` in
	0) color='#C4C4A0A00000';;
	1) color='#CECE5C5C0000';;
	2) color='#8F8F59590202';;
	3) color='#4E4E9A9A0606';;
	4) color='#20204A4A8787';;
	5) color='#5C5C35356666';;
	6) color='#A4A400000000';;
esac

sedcommand="s/\(selected_bg_color:\)\(.*\)/\1$color/"

color_scheme=`gconftool-2 -g /desktop/gnome/interface/gtk_color_scheme | sed $sedcommand`

gconftool-2 -t string -s /desktop/gnome/interface/gtk_color_scheme "$color_scheme"</pre>
<p>[/codesyntax]<br />
每天一换，颜色是tango调色板里的色彩，HOHOHAHA</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/05/%e6%97%a9%e8%b5%b7%ef%bc%8c%e5%86%99%e4%b8%80%e4%b8%aa%e5%8f%98%e8%89%b2%e7%9a%84%e5%b0%8f%e7%a8%8b%e5%ba%8f/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
