<?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>Sakana.fr - A sysadmin&#039;s blog &#187; Systems</title>
	<atom:link href="http://www.sakana.fr/blog/category/systems/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sakana.fr/blog</link>
	<description>On the fly saving of few useful (?) tech tips</description>
	<lastBuildDate>Thu, 26 Jan 2012 15:30:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Unix 101 : Showing non-printing characters in text files (ex : DOS files)</title>
		<link>http://www.sakana.fr/blog/2011/01/07/unix-101-showing-non-printing-characters-in-text-files-ex-dos-files/</link>
		<comments>http://www.sakana.fr/blog/2011/01/07/unix-101-showing-non-printing-characters-in-text-files-ex-dos-files/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 12:12:33 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=494</guid>
		<description><![CDATA[A non-printing character is a character which won&#8217;t actually get directly printed (or displayed) but rather interpreted. Such non-printing characters are for example line-feed or tabulation. The interpretation of those characters can differ from one system to the next. For example the line-feed character is different on Unix or DOS. If you need an easy [...]<p><a href="http://www.sakana.fr/blog/2011/01/07/unix-101-showing-non-printing-characters-in-text-files-ex-dos-files/">Unix 101 : Showing non-printing characters in text files (ex : DOS files)</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>A non-printing character is a character which won&#8217;t actually get directly printed (or displayed) but rather interpreted. Such non-printing characters are for example line-feed or tabulation. The interpretation of those characters can differ from one system to the next. For example the line-feed character is different on Unix or DOS.</p>
<p>If you need an easy way to confirm that a text file is DOS or UNIX formatted (they differ with respect to the end of line character(s) for example) or if you wish to display normally non-printing characters of a text file, you can use the <tt>-vET</tt> command line switches of the <tt>cat</tt> utility.</p>
<p>As explained in the man page :</p>
<ul>
<li>-v : will use the ^ and M- notation for control and multibytes characters</li>
<li>-E : will make ends of lines visible</li>
<li>-T : will make tabulations visible</li>
</ul>
<p>For example : <span id="more-494"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p494code3'); return false;">View Code</a> EXAMPLE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4943"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p494code3"><pre class="example" style="font-family:monospace;">% cat -vET test.txt
a test message for$
showing the^Iuse of   cat -vET$
^I$
that is all$</pre></td></tr></table></div>

<p>and compare it to the following plain <tt>cat</tt> output, without any command line option :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p494code4'); return false;">View Code</a> EXAMPLE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4944"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p494code4"><pre class="example" style="font-family:monospace;">% cat test.txt     
a test message for
showing the     use of   cat -vET
&nbsp;
that is all</pre></td></tr></table></div>

<p>You can easily tell what blank space is a space or actually a tabulation for example. If you&#8217;d happen to see ^M characters popping out at the end of the lines, then you this is actually a DOS text file (which you might need to convert to UNIX style end of lines with an utility such as dos2unix)</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4571688872511149";
/* 728x90, created 10/17/09 */
google_ad_slot = "0784069657";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><a href="http://www.sakana.fr/blog/2011/01/07/unix-101-showing-non-printing-characters-in-text-files-ex-dos-files/">Unix 101 : Showing non-printing characters in text files (ex : DOS files)</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2011/01/07/unix-101-showing-non-printing-characters-in-text-files-ex-dos-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix 101 : Filesystem basics &amp; Special files</title>
		<link>http://www.sakana.fr/blog/2010/12/08/unix-101-filesystem-basics-special-files/</link>
		<comments>http://www.sakana.fr/blog/2010/12/08/unix-101-filesystem-basics-special-files/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 21:34:48 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[hardlinks]]></category>
		<category><![CDATA[sticky bit]]></category>
		<category><![CDATA[symlinks]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=479</guid>
		<description><![CDATA[This post is meant to clarify a few key concepts about Unix filesystems such as directory permissions, hardlinks and symlinks. Q: If I chmod 777 a file, can someone delete it ? A: No. To explain that, let&#8217;s first talk about directories. You can imagine a directory as a special file which would have one [...]<p><a href="http://www.sakana.fr/blog/2010/12/08/unix-101-filesystem-basics-special-files/">Unix 101 : Filesystem basics &#038; Special files</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This post is meant to clarify a few key concepts about Unix filesystems such as directory permissions, hardlinks and symlinks.</p>
<p><span id="more-479"></span></p>
<p><strong>Q:</strong> If I chmod 777 a file, can someone delete it ?<br />
<strong>A:</strong> No. To explain that, let&#8217;s first talk about directories. You can imagine a directory as a special file which would have one line for each file contained in that directory. On each such line, there would be the inode number, and the name of the matching file.<br />
Deleting a file would be like removing a line from that special directory file <strong>which means that you need write permission on the directory containing the file to do so.</strong></p>
<p><strong>Q:</strong> What about that 777 mode /tmp directory ? Won&#8217;t someone delete all my files then ?<br />
<strong>A:</strong> No. /tmp &#8216;s permissions are not actually 777 but 1777. That &#8220;1&#8243; is the sticky bit which materialize by the &#8220;t&#8221; flag showing up in &#8220;ls -l&#8221;. That sticky bit means that only the owner of the file is allowed to delete it.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p479code6'); return false;">View Code</a> EXAMPLE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4796"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p479code6"><pre class="example" style="font-family:monospace;">kattoo@roadrunner ~ % ls -ld /tmp
drwxrwxrwt 10 root root 4096 Dec  8 21:53 /tmp/</pre></td></tr></table></div>

<p><strong>Q:</strong> Knowing that bit about directories being special files, how would you implement a hard links ?<br />
<strong>A:</strong> Simply have 2 &#8220;special file directories&#8221; having a line with the same inode number and different (or same !) file names. There you go, alternate filenames for the same on-disk content.</p>
<p><strong>Q:</strong> But then, if I delete a file with a hardlink, the &#8220;other&#8221; filename will point to no data ?<br />
<strong>A:</strong> No. The inode contains quite a few informations : dates, permissions, owner, group and such as well as the number of hardlinks. Every time you delete such a hardlink, this counter is decremented. Everytime you create a hardlink, the count is incremented. The actual content of the file is only actually deleted when the count reaches 0.</p>
<p><strong>Q:</strong> How about soft links (aka symbolic links aka symlinks) ?<br />
<strong>A:</strong> A symlink is yet another special kind of file. You can imagine that it&#8217;s a file which contains the name of another file. Anyone accessing the symlink will actually access the content of the file which name is in the symlink special file. This name resolution being done in-kernel, it&#8217;s mostly transparent for userland processes. Notice that you could place the name of a non-existing file in the symlink (dead link !), which is not possible with a hardlink.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4571688872511149";
/* 728x90, created 10/17/09 */
google_ad_slot = "0784069657";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><a href="http://www.sakana.fr/blog/2010/12/08/unix-101-filesystem-basics-special-files/">Unix 101 : Filesystem basics &#038; Special files</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2010/12/08/unix-101-filesystem-basics-special-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux + Xorg : Remapping caps lock key to escape</title>
		<link>http://www.sakana.fr/blog/2010/11/12/linux-xorg-remapping-caps-lock-key-to-escape/</link>
		<comments>http://www.sakana.fr/blog/2010/11/12/linux-xorg-remapping-caps-lock-key-to-escape/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 23:49:31 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[caps lock]]></category>
		<category><![CDATA[hal]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[xorg]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=465</guid>
		<description><![CDATA[In this post I&#8217;ll revisit the classical &#8220;how to remap caps lock into something useful&#8221; once again. In this post, I&#8217;ll show how to remap the caps lock key to have an extra Escape key, which is very useful for all VI/Vim users. Method 1 : Using xmodmap This is mostly the usual way of [...]<p><a href="http://www.sakana.fr/blog/2010/11/12/linux-xorg-remapping-caps-lock-key-to-escape/">Linux + Xorg : Remapping caps lock key to escape</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In this post I&#8217;ll revisit the classical &#8220;<strong>how to remap caps lock into something useful</strong>&#8221; once again. In this post, I&#8217;ll show how to remap the caps lock key to have an extra Escape key, which is very useful for all VI/Vim users.</p>
<p><span id="more-465"></span></p>
<h4>Method 1 : Using xmodmap</h4>
<p>This is mostly the usual way of altering the keyboard map. All you have to do edit the ${HOME}/.Xmodmap file like below :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p465code10'); return false;">View Code</a> CONF</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p46510"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p465code10"><pre class="conf" style="font-family:monospace;">clear Lock
keycode 66 = Escape</pre></td></tr></table></div>

<p>This file is often sourced when your X sessions is opened, but there are numerous bug reports stating that it&#8217;s either <a href="https://bbs.archlinux.org/viewtopic.php?pid=723967" target="_blank">ignored</a> or <a href="https://bugs.launchpad.net/ubuntu/+source/xfce4-session/+bug/97175" target="_blank">overridden</a> by some windows managers.</p>
<p>You might need to source the file by running <tt>xmodmap ~/.Xmodmap</tt> at some point after the windows manager is started.</p>
<h4>Method 2 : Using XKB configuration</h4>
<p>If you let Xorg setup your keyboard by consulting HAL, you can remap the caps lock key to escape by having the following policy file in <tt>/etc/hal/fdi/policy/keyboard.fdi</tt></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p465code11'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p46511"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p465code11"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;deviceinfo</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;device<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;match</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;info.capabilities&quot;</span> <span style="color: #000066;">contains</span>=<span style="color: #ff0000;">&quot;input.keyboard&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;match</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;info.product&quot;</span> <span style="color: #000066;">contains</span>=<span style="color: #ff0000;">&quot;Logitech Logitech USB Keyboard&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merge</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;input.x11_driver&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;string&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>evdev<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merge<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merge</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;input.x11_options.XkbOptions&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;string&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>caps:escape<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merge<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merge</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;input.x11_options.XkbLayout&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;string&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>us<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merge<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merge</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;input.x11_options.XkbVariant&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;string&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>intl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merge<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/match<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/match<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/device<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/deviceinfo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The <tt>caps:escape</tt> takes care of setting up caps lock as an escape key.</p>
<p>See more about <a href="http://www.sakana.fr/blog/2009/10/12/hal-xorg-x-server-using-hal-to-set-harware-specific-configuration-for-xorg-xserver/" target="_blank">How to setup Xorg according to HAL</a></p>
<p>If you don&#8217;t use HAL and prefer to setup your keyboard through xorg.conf, it will look like the snippet below :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p465code12'); return false;">View Code</a> CONF</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p46512"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p465code12"><pre class="conf" style="font-family:monospace;">Section &quot;InputDevice&quot;
    Identifier &quot;Keyboard1&quot;
    Driver &quot;evdev&quot;
&nbsp;
    Option &quot;XkbLayout&quot; &quot;us&quot;
    Option &quot;XkbVarian&quot; &quot;intl&quot;
    Option &quot;XKbOptions&quot; &quot;caps:escape&quot;
EndSection</pre></td></tr></table></div>

<p>To see the other available options, check <tt>/usr/share/X11/xkb/rules/xorg</tt></p>
<p>Further readings :</p>
<ul>
<li><a href="http://www.x.org/archive/X11R7.0/doc/html/XKB-Config.html" target="_blank">The XKB Configuration Guide</a></li>
<li><a href="http://www.charvolant.org/~doug/xkb/html/node1.html" target="_blank">An Unreliable Guide to XKB Configuration</a></li>
</ul>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2010/11/12/linux-xorg-remapping-caps-lock-key-to-escape/">Linux + Xorg : Remapping caps lock key to escape</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2010/11/12/linux-xorg-remapping-caps-lock-key-to-escape/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash / zsh : Using the history expansion</title>
		<link>http://www.sakana.fr/blog/2010/03/28/bash-zsh-history-expansion/</link>
		<comments>http://www.sakana.fr/blog/2010/03/28/bash-zsh-history-expansion/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 19:48:31 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=424</guid>
		<description><![CDATA[One of the features of bash I&#8217;ve too long overlooked is its history expansion. In this post I&#8217;ll show a few examples to get a grip at it. Recall a previous line Recall the last line ?View Code SHELL1 2 3 4 5 6 kattoo@roadrunner ~ $ date Sun Mar 28 18:35:12 CEST 2010 kattoo@roadrunner [...]<p><a href="http://www.sakana.fr/blog/2010/03/28/bash-zsh-history-expansion/">Bash / zsh : Using the history expansion</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>One of the features of bash I&#8217;ve too long overlooked is its history expansion. In this post I&#8217;ll show a few examples to get a grip at it.<br />
<span id="more-424"></span></p>
<h4>Recall a previous line</h4>
<ul>
<li>Recall the last line

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p424code19'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p42419"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p424code19"><pre class="shell" style="font-family:monospace;">kattoo@roadrunner ~ $ date
Sun Mar 28 18:35:12 CEST 2010
kattoo@roadrunner ~ $ !!
date
Sun Mar 28 18:35:13 CEST 2010
kattoo@roadrunner ~ $</pre></td></tr></table></div>

</li>
<li>Recall the n-th last line :

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p424code20'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p42420"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p424code20"><pre class="shell" style="font-family:monospace;">kattoo@roadrunner ~ $ echo 1
1
kattoo@roadrunner ~ $ echo 2
2
kattoo@roadrunner ~ $ echo 3
3
kattoo@roadrunner ~ $ !-3
echo 1
1
kattoo@roadrunner ~ $</pre></td></tr></table></div>

</li>
<li>Recall the n-th line of the history

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p424code21'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p42421"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p424code21"><pre class="shell" style="font-family:monospace;">kattoo@roadrunner ~ $ history
[...]
  533  date
  534  date
  535  echo 1
  536  echo 2
  537  echo 3
  538  echo 1
  539  history
kattoo@roadrunner ~ $ !536
echo 2
2
kattoo@roadrunner ~ $</pre></td></tr></table></div>

</li>
</ul>
<h4>Re-using previous command line arguments</h4>
<ul>
<li>Re-use all the arguments of the previous command

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p424code22'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p42422"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p424code22"><pre class="shell" style="font-family:monospace;">kattoo@roadrunner ~ $ touch test-file.txt
kattoo@roadrunner ~ $ scp !* remote:/tmp
scp test-file.txt spaghetti:/tmp
test-file.txt                                             100%    0     0.0KB/s   00:00    
kattoo@roadrunner ~ $</pre></td></tr></table></div>

</li>
<li>Re-use the m-th argument from the n-th previous command line

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p424code23'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p42423"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p424code23"><pre class="shell" style="font-family:monospace;">kattoo@roadrunner ~ $ echo 1 2 3
1 2 3
kattoo@roadrunner ~ $ echo !-1:2
echo 2
2
kattoo@roadrunner ~ $</pre></td></tr></table></div>

</li>
<li>Re-run the previous command changing occurrences of X by Y

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p424code24'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p42424"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p424code24"><pre class="shell" style="font-family:monospace;">kattoo@roadrunner ~ $ echo test
test
kattoo@roadrunner ~ $ ^test^replaced
echo replaced
replaced
kattoo@roadrunner ~ $</pre></td></tr></table></div>

</li>
</ul>
<p>That&#8217;s about it&#8230; those are what I consider to be the most useful history expansion features of bash. </p>
<p>Do you have any other you find especially useful ? Share them in the comments !</p>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2010/03/28/bash-zsh-history-expansion/">Bash / zsh : Using the history expansion</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2010/03/28/bash-zsh-history-expansion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AIX : Use sar to check cpu usage</title>
		<link>http://www.sakana.fr/blog/2010/01/30/aix-use-sar-to-check-cpu-usage/</link>
		<comments>http://www.sakana.fr/blog/2010/01/30/aix-use-sar-to-check-cpu-usage/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 20:45:42 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[aix]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[sar]]></category>
		<category><![CDATA[top]]></category>
		<category><![CDATA[topas]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=405</guid>
		<description><![CDATA[If you&#8217;re looking for CPU usage statistics and system performance on IBM AIX, sar might just be the tool your looking for. It&#8217;ll display information for 5 minutes intervals from midnight to current time. The output looks like this : ?View Code TEXT1 2 3 4 5 6 7 8 9 10 11 12 13 [...]<p><a href="http://www.sakana.fr/blog/2010/01/30/aix-use-sar-to-check-cpu-usage/">AIX : Use sar to check cpu usage</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re looking for CPU usage statistics and system performance on IBM AIX, <tt>sar</tt> might just be the tool your looking for. It&#8217;ll display information for 5 minutes intervals from midnight to current time. The output looks like this :<br />
<span id="more-405"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p405code26'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p40526"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p405code26"><pre class="text" style="font-family:monospace;">login@servername:/&gt; sar
&nbsp;
AIX servername 3 5 00CFE81B4C00    01/25/10
&nbsp;
Configuration du système : lcpu=20 ent=8,00
&nbsp;
00:00:01    %usr    %sys    %wio   %idle   physc   %entc
00:05:01       2       2       0      96    0,40     5,0
00:10:01       3       2       0      94    0,48     6,0
00:15:00       1       1       0      98    0,21     2,6
00:20:01       1       1       0      98    0,23     2,9
00:25:01       2       1       1      97    0,25     3,2
00:30:01       1       1       0      98    0,23     2,9
00:35:00       2       1       1      96    0,31     3,8
00:40:01       1       1       0      98    0,21     2,6
00:45:01       1       1       0      98    0,22     2,7
00:50:00       1       1       0      98    0,23     2,8
00:55:00       1       1       0      98    0,21     2,6
01:00:00       1       1       0      98    0,21     2,6
01:05:00       2       1       0      96    0,35     4,4</pre></td></tr></table></div>

<p>The columns are the usual for this type of tools :</p>
<ol>
<li>%usr : the percent of time spent in user land. The higher the more CPU intensive processes you are running.</li>
<li>%sys : the percent of time spent in kernel. This is mostly due to I/O intensive processes and/or processes performing a lot of syscalls.</li>
<li>%wio : I&#8217;ve got no idea about that one &#8230; If you&#8217;ve got an explanation for this, feel free to hit the comments. I suspect this is the time spent waiting for I/Os to complete, or waiting after a busy device. This could be a sign of I/O (disk, network) bottlenecks</li>
<li>%idle : the percent of time spent doing &#8230; nothing. The higher this number, the more underused your machine</li>
<li>physc : no idea neither !</li>
<li>%entc : the number of CPU used to absorb the load</li>
</ol>
<p>If you&#8217;re looking for a <tt>top</tt> like tool, <tt>topas</tt> is the standard AIX equivalent.</p>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2010/01/30/aix-use-sar-to-check-cpu-usage/">AIX : Use sar to check cpu usage</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2010/01/30/aix-use-sar-to-check-cpu-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux / Unix : Disk usage and identifying biggest files</title>
		<link>http://www.sakana.fr/blog/2010/01/17/linux-unix-disk-usage-and-identifying-biggest-files/</link>
		<comments>http://www.sakana.fr/blog/2010/01/17/linux-unix-disk-usage-and-identifying-biggest-files/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 17:41:16 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[df]]></category>
		<category><![CDATA[du]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[fs full]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=381</guid>
		<description><![CDATA[When working as a systems administrator, you&#8217;ll always end up having to solve a file system full error in a hurry. Here are a few commands and hints to help you get out of it quickly on a UNIX like system. df command The df (disk free) command will report how much of each file [...]<p><a href="http://www.sakana.fr/blog/2010/01/17/linux-unix-disk-usage-and-identifying-biggest-files/">Linux / Unix : Disk usage and identifying biggest files</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>When working as a systems administrator, you&#8217;ll always end up having to solve a <i>file system full</i> error in a hurry. Here are a few commands and hints to help you get out of it quickly on a UNIX like system.<br />
<span id="more-381"></span></p>
<h4>df command</h4>
<p>The <tt>df</tt> (disk free) command will report how much of each file system is used. You can combine this with with the <tt>sort</tt> command to get the fullest file systems at the end :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p381code32'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38132"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p381code32"><pre class="text" style="font-family:monospace;">kattoo@roadrunner ~/Downloads $ df | sort -n -k 5,5
Filesystem           1K-blocks      Used Available Use% Mounted on
shm                    2029696         0   2029696   0% /dev/shm
/dev/sda6              1968588      3232   1865356   1% /tmp
udev                     10240       228     10012   3% /dev
/dev/sda12           367628876  28899532 338729344   8% /files
/dev/sda7              1989820    246300   1743520  13% /var
/dev/sda9              1999932    260996   1738936  14% /usr/portage
/dev/sda5               244176     52264    191912  22% /
/dev/sda8              9990188   3161340   6828848  32% /usr
/dev/sda11            99947736  32910756  67036980  33% /files/vservers
/dev/sda10             3989912   1699372   2290540  43% /usr/portage/distfiles</pre></td></tr></table></div>

<p>The <tt>sort</tt> arguments are :</p>
<ul>
<li>-n : order numerically</li>
<li>-k 5,5 : order by the 5th field</li>
</ul>
<h4>du command</h4>
<p>When you found out that a specific file system is full, you need to quickly analyze which folders are the biggest.<br />
You can use the <tt>du</tt> (disk usage) command. This command will report the space used by a directory and sub-directories. I usually run something like :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p381code33'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38133"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p381code33"><pre class="text" style="font-family:monospace;">kattoo@roadrunner /usr/portage $ du -sk * | sort -n | tail -20
5711	x11-misc
6056	app-misc
6224	dev-ruby
6320	app-dicts
7219	profiles
7428	net-analyzer
7686	app-text
8112	media-plugins
8777	kde-base
8883	media-libs
8943	sys-apps
9764	dev-util
9986	media-sound
10955	dev-libs
11295	dev-python
11479	dev-java
11645	net-misc
17553	dev-perl
112556	metadata
1705976	distfiles</pre></td></tr></table></div>

<p>This will show the 20 largest files or directories. <tt>du</tt> will display the size of each directories and sub-directories by default. The -s switch will make <tt>du</tt> display only the grand total for each arguments.</p>
<p>According to the results, you might want to go on repeating this command in the sub-directories, until you&#8217;ve narrowed down enough to find the culprit.</p>
<h4>find command</h4>
<p>The file system full error is more often than not due to a faulty script or program which logs are running wild due to a bug. This will usually lead to a huge file somewhere in a directory, hogging all the available space on the file system.</p>
<p>An easy way to spot it is to use the <tt>find</tt> command. The following snippet for example will search for files bigger than 10MB in the current directory and sub-directories and print the 10 largest ones :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p381code34'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38134"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p381code34"><pre class="text" style="font-family:monospace;">kattoo@roadrunner /usr/portage $ find . -type f -size +10000000c -exec ls -l \{} \; | sort -n -k 5,5 | tail -10
-rw-rw-r-- 1 portage portage 23416703 Oct  1 10:07 ./distfiles/samba-3.0.37.tar.gz
-rw-rw-r-- 1 portage portage 28749072 Jan 18  2008 ./distfiles/extremetuxracer-0.4.tar.gz
-rw-rw-r-- 1 portage portage 46905557 Oct 16 17:20 ./distfiles/firefox-3.5.4.source.tar.bz2
-rw-rw-r-- 1 portage portage 46914620 Dec  2 05:32 ./distfiles/firefox-3.5.6.source.tar.bz2
-rw-rw-r-- 1 portage portage 50380241 Oct  2 11:47 ./distfiles/VirtualBox-3.0.8-53138-Linux_amd64.run
-rw-rw-r-- 1 portage portage 50595281 Nov 17 10:44 ./distfiles/VirtualBox-3.0.12-54655-Linux_amd64.run
-rw-rw-r-- 1 portage portage 59368714 Aug  8 02:10 ./distfiles/gcc-4.3.4.tar.bz2
-rw-rw-r-- 1 portage portage 61494822 Sep 10 00:34 ./distfiles/linux-2.6.31.tar.bz2
-rw-rw-r-- 1 portage portage 125384668 Oct  1 13:58 ./distfiles/qt-x11-opensource-src-4.5.3.tar.gz
-rw-rw-r-- 1 portage portage 314942420 Jun 18  2008 ./distfiles/sauerbraten_2008_06_17_ctf_edition_linux.tar.bz2
kattoo@roadrunner /usr/portage $</pre></td></tr></table></div>

<p>I also like to filter out already compressed files, in order to collect the biggest files which I could compress to save some space with something like :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p381code35'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38135"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p381code35"><pre class="text" style="font-family:monospace;">find . -type f -size +10000000c \! -name &quot;*.Z&quot; \! -name &quot;*.gz&quot; \! -name &quot;*.bz2&quot; -exec ls -l \{} \;</pre></td></tr></table></div>

<p><strong>Tip</strong> : Set this as an alias in your profile by adding this to your <tt>.bashrc</tt> (if you&#8217;re using bash &#8230; otherwise check your shell documentation) :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p381code36'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38136"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p381code36"><pre class="text" style="font-family:monospace;">alias bigfiles='find . -type f -size +10000000c \! -name &quot;*.Z&quot; \! -name &quot;*.gz&quot; \! -name &quot;*.bz2&quot; -exec ls -l \{} \; | sort -n -k 5,5 | tail -10'</pre></td></tr></table></div>

<p>This will give you the 10 largest not-yet-compressed files in a single handy command.</p>
<p><!--adsense--></p>
<h4>Caveat</h4>
<p><b></i>&#8220;Too many arguments&#8221;</i> error</b> :</p>
<p>If you are working with directory holding an important number of files, you might get a &#8220;Too many arguments&#8221; error when using a star expansion (like in the <tt>du -sk *</tt> example above).</p>
<p>This is actually not the <tt>du</tt> command complaining, but the shell which gets too much data when expanding the star. When this happens, you are usually better off using the <tt>find</tt> command as explained above. </p>
<p>Another possibility is to pipe the output of <tt>find</tt> to the <tt>xargs</tt> command. Basically <tt>xargs</tt> will take everything on the standard input and give it as arguments to the specified command.</p>
<p><b>Deleting / compressing a file which is still open</b><br />
Also beware of this : if you delete or compress a file which is still being open by a process, then the space this file use won&#8217;t get freed before the process actually closes the file (I&#8217;ll explain why in a different post, this is an interesting topic on its own <img src='http://www.sakana.fr/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ).</p>
<p>If you deleted or compressed the file (so basically the big file disappeared or was replaced by a compressed version), but the space doesn&#8217;t get freed (which you can check with <tt>df</tt>), then you can bet that a process is still holding the file open. You can spot this with tools like lsof or fuser. Those tools vary greatly according to which variant of Unix you&#8217;re running. On <strong>IBM&#8217;s AIX</strong>, fuser had a handy -d option to spot files on the file system which have a link count of 0 and it will report the PID of the attached processes.</p>
<p>Better check those tools&#8217; man pages before you run into this situation !</p>
<h4>A word to the wise</h4>
<p>Those recipes will help you to find a way out when you are already facing a file system full problem. The best is of course to avoid them in the first place &#8230; The following ideas are a good start :</p>
<ul>
<li><strong>Set alerts</strong> to have an early warning and let you deal with it before applications start crashing. Tools like <a href="http://www.nagios.org/" target="_blank">Nagios</a> would be your friends here, but home made scripts running from cron and sending emails might be enough.</li>
<li><strong>Check the trends</strong> : You can use tools like <a href="http://www.cacti.net/">cacti</a> to graph the space occupation of your file systems over the time. This will let you anticipate when you&#8217;ll need to add more disks or if your log rotation and/or file archiving policies are adequate.</li>
</ul>
<p><strong>More ideas ? Tips to share ? Hit the comments !</strong></p>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2010/01/17/linux-unix-disk-usage-and-identifying-biggest-files/">Linux / Unix : Disk usage and identifying biggest files</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2010/01/17/linux-unix-disk-usage-and-identifying-biggest-files/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Gentoo Linux / Portage : How to know which package provided an installed file</title>
		<link>http://www.sakana.fr/blog/2009/12/03/gentoo-linux-portage-how-to-know-which-package-provided-an-installed-file/</link>
		<comments>http://www.sakana.fr/blog/2009/12/03/gentoo-linux-portage-how-to-know-which-package-provided-an-installed-file/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 08:33:37 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[equery]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[portage]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=364</guid>
		<description><![CDATA[If there&#8217;s a file installed on your disk for which you&#8217;d like to know what package provided it, you can use the equery command like below : ?View Code TEXT1 2 roadrunner ~ # equery belongs /etc/init.d/samba [ Searching for file(s) /etc/init.d/samba in *... ] net-fs/samba-3.0.37 (/etc/init.d/samba) equery is part of the gentoolkit package, which [...]<p><a href="http://www.sakana.fr/blog/2009/12/03/gentoo-linux-portage-how-to-know-which-package-provided-an-installed-file/">Gentoo Linux / Portage : How to know which package provided an installed file</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>If there&#8217;s a file installed on your disk for which you&#8217;d like to know what package provided it, you can use the equery command like below :<br />
<span id="more-364"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p364code39'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p36439"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p364code39"><pre class="text" style="font-family:monospace;">roadrunner ~ # equery belongs /etc/init.d/samba [ Searching for file(s) /etc/init.d/samba in *... ]
net-fs/samba-3.0.37 (/etc/init.d/samba)</pre></td></tr></table></div>

<p>equery is part of the gentoolkit package, which provides useful tools to maintain/investigate your gentoo packages.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p364code40'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p36440"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p364code40"><pre class="text" style="font-family:monospace;">roadrunner ~ # equery belongs /usr/bin/revdep-rebuild 
[ Searching for file(s) /usr/bin/revdep-rebuild in *... ]
app-portage/gentoolkit-0.2.4.5 (/usr/bin/revdep-rebuild)</pre></td></tr></table></div>

<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2009/12/03/gentoo-linux-portage-how-to-know-which-package-provided-an-installed-file/">Gentoo Linux / Portage : How to know which package provided an installed file</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2009/12/03/gentoo-linux-portage-how-to-know-which-package-provided-an-installed-file/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>VirtualBox : Cloning a virtual hard disk</title>
		<link>http://www.sakana.fr/blog/2009/11/18/virtualbox-cloning-a-virtual-hard-disk/</link>
		<comments>http://www.sakana.fr/blog/2009/11/18/virtualbox-cloning-a-virtual-hard-disk/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 09:50:22 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[clone]]></category>
		<category><![CDATA[clonehd]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[vm]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=358</guid>
		<description><![CDATA[If you&#8217;ve got a VirtualBox VM already installed and you wish to clone/copy it, follow the steps below : Clone the disk image with a similar command line (you will have to adjust your paths) : ?View Code TEXT1 2 3 4 5 6 7 8 kattoo@roadrunner /files/toSave/home/kattoo $ VBoxManage clonehd /files/vservers/{VM1/disk1.vdi,VM2/disk2.vdi} VirtualBox Command Line [...]<p><a href="http://www.sakana.fr/blog/2009/11/18/virtualbox-cloning-a-virtual-hard-disk/">VirtualBox : Cloning a virtual hard disk</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve got a VirtualBox VM already installed and you wish to clone/copy it, follow the steps below :<br />
<span id="more-358"></span></p>
<ol>
<li>Clone the disk image with a similar command line (you will have to adjust your paths) :

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p358code42'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p35842"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p358code42"><pre class="text" style="font-family:monospace;">kattoo@roadrunner /files/toSave/home/kattoo $ VBoxManage clonehd /files/vservers/{VM1/disk1.vdi,VM2/disk2.vdi}
VirtualBox Command Line Management Interface Version 3.0.10
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
&nbsp;
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 84956ae4-6c85-41cf-aa23-a265029d99a8
kattoo@roadrunner /files/toSave/home/kattoo $</pre></td></tr></table></div>

</li>
<li>Setup a new virtual machine through the virtualbox GUI or otherwise, with the same parameters as the original one and attach this new disk</li>
</ol>
<p>Note : This command doesn&#8217;t take care of potential snapshots you could have on the source disk image. It will only clone the base image, so you might have to merge the snapshots into the base image before cloning if you want those to be integrated in the copy.</p>
<p>References :</p>
<ul>
<li><a href="http://www.virtualbox.org/manual/UserManual.html#vboxmanage-clonevdi" target="_blank">VirtualBox manual : vboxmanage clonehd</a></li>
</ul>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2009/11/18/virtualbox-cloning-a-virtual-hard-disk/">VirtualBox : Cloning a virtual hard disk</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2009/11/18/virtualbox-cloning-a-virtual-hard-disk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSolaris : Exporting a ZFS filesystem with CIFS</title>
		<link>http://www.sakana.fr/blog/2009/11/11/opensolaris-exporting-a-zfs-filesystem-with-cifs/</link>
		<comments>http://www.sakana.fr/blog/2009/11/11/opensolaris-exporting-a-zfs-filesystem-with-cifs/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 15:15:57 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[cifs]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[zfs]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=347</guid>
		<description><![CDATA[If you need to export ZFS volumes through CIFS, follow this simple step by step procedure. Step 1 : install the packages (This step is optional if you already have them installed on the machine) ?View Code TEXT1 2 3 4 5 6 kattoo@backup3:~$ pfexec pkg install SUNWsmbskr DOWNLOAD PKGS FILES XFER (MB) Completed 2/2 [...]<p><a href="http://www.sakana.fr/blog/2009/11/11/opensolaris-exporting-a-zfs-filesystem-with-cifs/">OpenSolaris : Exporting a ZFS filesystem with CIFS</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>If you need to export ZFS volumes through CIFS, follow this simple step by step procedure.<br />
<span id="more-347"></span></p>
<h4>Step 1 : install the packages</h4>
<p>(This step is optional if you already have them installed on the machine)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code49'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34749"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p347code49"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ pfexec pkg install SUNWsmbskr
DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                                  2/2       35/35      2.0/2.0 
&nbsp;
PHASE                                        ACTIONS
Install Phase                                  90/90</pre></td></tr></table></div>

<p>At this point, you&#8217;ll need to perform a reboot (if you can&#8217;t afford that, check in the references for a link to the full procedure).</p>
<h4>Step 2 : Join a WORKGROUP</h4>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code50'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34750"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p347code50"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ pfexec smbadm join -w SAKANA
After joining SAKANA the smb service will be restarted automatically.
Would you like to continue? [no]: yes
Successfully joined SAKANA
kattoo@backup3:~$</pre></td></tr></table></div>

<h4>Step 3 : Set passwords for users who will access the shares</h4>
<p>Add the following line into <b>/etc/pam.conf</b> :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code51'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34751"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p347code51"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ grep smb /etc/pam.conf 
other 	password required 	pam_smb_passwd.so.1 nowarn</pre></td></tr></table></div>

<p>Now reset the passwords for the users who will be access the shares :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code52'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34752"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p347code52"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ pfexec passwd kattoo
New Password: 
Re-enter new Password: 
passwd: password successfully changed for kattoo</pre></td></tr></table></div>

<h4>Step 4 : Share the filesystems</h4>
<p>You can then share any zfs filesystem with the following :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code53'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34753"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p347code53"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ pfexec zfs set sharesmb=on backup</pre></td></tr></table></div>

<p>To check what is exported, you can do this :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code54'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34754"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p347code54"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ sharemgr show -pv
default nfs=()
zfs
    zfs/backup smb=()
	  backup=/backup
	  backup_roadrunner=/backup/roadrunner
	  backup_thekla=/backup/thekla
    zfs/storage smb=()
	  storage=/storage
kattoo@backup3:~$</pre></td></tr></table></div>

<p>Here, the backup_roadrunner and backup_thekla were automatically exported because the property sharesmb was inherited from backup.</p>
<p>References :</p>
<ul>
<li><a href="http://wiki.genunix.org/wiki/index.php/Getting_Started_With_the_Solaris_CIFS_Service" target="_blank">Genunix : Getting Started With the Solaris CIFS Service</a></li>
</ul>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2009/11/11/opensolaris-exporting-a-zfs-filesystem-with-cifs/">OpenSolaris : Exporting a ZFS filesystem with CIFS</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2009/11/11/opensolaris-exporting-a-zfs-filesystem-with-cifs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSolaris : Switching to the /dev development branch</title>
		<link>http://www.sakana.fr/blog/2009/11/08/opensolaris-switching-to-the-dev-development-branch/</link>
		<comments>http://www.sakana.fr/blog/2009/11/08/opensolaris-switching-to-the-dev-development-branch/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 17:13:37 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[dev branch]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=341</guid>
		<description><![CDATA[In OpenSolaris, switching to the /dev development branch is a bit like switching to the testing branch for some linux distros. So you might want to think twice before doing so, as it might sometimes break things. If you still want to do that, follow those instructions : Change the default packages publisher ?View Code [...]<p><a href="http://www.sakana.fr/blog/2009/11/08/opensolaris-switching-to-the-dev-development-branch/">OpenSolaris : Switching to the /dev development branch</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In OpenSolaris, switching to the /dev development branch is a bit like switching to the testing branch for some linux distros. So you might want to think twice before doing so, as it might sometimes break things.</p>
<p>If you still want to do that, follow those instructions :<br />
<span id="more-341"></span></p>
<h3>Change the default packages publisher</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p341code58'); return false;">View Code</a> TXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34158"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p341code58"><pre class="txt" style="font-family:monospace;">stephane@backup3:~$ pfexec pkg set-publisher -O http://pkg.opensolaris.org/dev opensolaris.org</pre></td></tr></table></div>

<h3>Update pkg</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p341code59'); return false;">View Code</a> TXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34159"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p341code59"><pre class="txt" style="font-family:monospace;">stephane@backup3:~$ pfexec pkg install SUNWipkg
DOWNLOAD                                    PKGS       FILES     XFER (MB)
Completed                                    3/3     113/113     0.49/0.49 
&nbsp;
PHASE                                        ACTIONS
Removal Phase                                  28/28 
Install Phase                                  12/12
Update Phase                                 227/227</pre></td></tr></table></div>

<h3>Finally, perform the update of the packages to the /dev branch</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p341code60'); return false;">View Code</a> TXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34160"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p341code60"><pre class="txt" style="font-family:monospace;">stephane@backup3:~$ pfexec  pkg image-update
DOWNLOAD                                    PKGS       FILES     XFER (MB)
FSWxorg-fonts-core                         2/666   872/44604   8.20/723.02 
[...]</pre></td></tr></table></div>

<p>This might take a while !</p>
<p>References :</p>
<ul>
<li><a href="http://pkg.opensolaris.org/dev/en/index.shtml">OpenSolaris Development Release Packaging Repository</a></li>
</ul>
<p><!--adsense--> </p>
<p><a href="http://www.sakana.fr/blog/2009/11/08/opensolaris-switching-to-the-dev-development-branch/">OpenSolaris : Switching to the /dev development branch</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2009/11/08/opensolaris-switching-to-the-dev-development-branch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

