<?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" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>*nix Shell</title>
	<atom:link href="http://nixshell.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://nixshell.wordpress.com</link>
	<description>UNIX / Linux Shell Hints and Tips&#160;&#160;&#160;&#160;&#160;&#160;(a http://steve-parker.org/sh/sh.shtml subproject)</description>
	<lastBuildDate>Fri, 26 Apr 2013 11:27:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='nixshell.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>*nix Shell</title>
		<link>http://nixshell.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://nixshell.wordpress.com/osd.xml" title="*nix Shell" />
	<atom:link rel='hub' href='http://nixshell.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Shell Scripting Tutorial on Kindle</title>
		<link>http://nixshell.wordpress.com/2013/03/29/shell-scripting-tutorial-on-kindle/</link>
		<comments>http://nixshell.wordpress.com/2013/03/29/shell-scripting-tutorial-on-kindle/#comments</comments>
		<pubDate>Fri, 29 Mar 2013 23:40:46 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[faq]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[kindle]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pipes]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=244</guid>
		<description><![CDATA[The Shell Scripting tutorial at http://steve-parker.org is now available natively on the Kindle! USA (amazon.com) UK (amazon.co.uk) Similarly, you can search for &#8220;B00C2EGNSA&#8221; on any Amazon site, or just go to http://www.amazon.COUNTRY/dp/B00C2EGNSA (where &#8220;COUNTRY&#8221; is .fr, .de, etc) for your local equivalent.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=244&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><div id="attachment_245" class="wp-caption alignleft" style="width: 255px"><a href="http://nixshell.files.wordpress.com/2013/03/title3.jpg"><img src="http://nixshell.files.wordpress.com/2013/03/title3.jpg?w=245&#038;h=300" alt="Unix &amp; Linux Shell Scripting Tutorial on Kindle" width="245" height="300" class="size-medium wp-image-245" /></a><p class="wp-caption-text">Unix &amp; Linux Shell Scripting Tutorial on Kindle</p></div>The Shell Scripting tutorial at <a href="http://steve-parker.org" rel="nofollow">http://steve-parker.org</a> is now available natively on the Kindle!</p>
<p><a href="http://www.amazon.com/gp/product/B00C2EGNSA/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B00C2EGNSA&amp;linkCode=as2&amp;tag=steveparkeror-20">USA (amazon.com)</a></p>
<p><a href="http://www.amazon.co.uk/gp/product/B00C2EGNSA/ref=as_li_ss_tl?ie=UTF8&amp;camp=1634&amp;creative=19450&amp;creativeASIN=B00C2EGNSA&amp;linkCode=as2&amp;tag=steveparkeror-21">UK (amazon.co.uk)</a></p>
<p>Similarly, you can search for &#8220;B00C2EGNSA&#8221; on any Amazon site, or just go to <a href="http://www.amazon.COUNTRY/dp/B00C2EGNSA" rel="nofollow">http://www.amazon.COUNTRY/dp/B00C2EGNSA</a> (where &#8220;COUNTRY&#8221; is .fr, .de, etc) for your local equivalent.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/244/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=244&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2013/03/29/shell-scripting-tutorial-on-kindle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>

		<media:content url="http://nixshell.files.wordpress.com/2013/03/title3.jpg?w=245" medium="image">
			<media:title type="html">Unix &#38; Linux Shell Scripting Tutorial on Kindle</media:title>
		</media:content>
	</item>
		<item>
		<title>Persian translation of Shell Scripting Tutorial</title>
		<link>http://nixshell.wordpress.com/2012/12/15/233/</link>
		<comments>http://nixshell.wordpress.com/2012/12/15/233/#comments</comments>
		<pubDate>Sat, 15 Dec 2012 00:35:36 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=233</guid>
		<description><![CDATA[Mahmood Pahlevani has translated my Shell Scripting tutorial at http://steve-parker.org/sh/sh.shtml into Persian, at http://bashlinux.persiangig.com/stev/sh/index.shtml Any feedback on this work is welcome here, I will pass on all praise to Mahmood, Steve<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=233&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Mahmood Pahlevani has translated my Shell Scripting tutorial at <a href="http://steve-parker.org/sh/sh.shtml" rel="nofollow">http://steve-parker.org/sh/sh.shtml</a> into Persian, at <a href="http://bashlinux.persiangig.com/stev/sh/index.shtml" rel="nofollow">http://bashlinux.persiangig.com/stev/sh/index.shtml</a></p>
<p>Any feedback on this work is welcome here, I will pass on all praise to Mahmood,</p>
<p>Steve</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/233/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=233&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2012/12/15/233/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Track memory usage on Solaris</title>
		<link>http://nixshell.wordpress.com/2012/11/15/track-memory-usage-on-solaris/</link>
		<comments>http://nixshell.wordpress.com/2012/11/15/track-memory-usage-on-solaris/#comments</comments>
		<pubDate>Thu, 15 Nov 2012 12:09:38 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[pipes]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=237</guid>
		<description><![CDATA[When a Solaris server is overloaded, this is one way to check what actual memory each process is using. Here I am restricting the checks to one user (&#8220;steve&#8221;) but by omitting the &#8220;-u steve&#8221; flag to ps, the whole system will be checked. $ps -ea -o pid,rss -u steve &#124; sort -n -k 2 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=237&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>When a Solaris server is overloaded, this is one way to check what actual memory each process is using. Here I am restricting the checks to one user (&#8220;steve&#8221;) but by omitting the &#8220;<code>-u steve</code>&#8221; flag to <code>ps</code>, the whole system will be checked.</p>
<p><code>$ps -ea -o pid,rss -u steve | sort -n -k 2 | while read pid rss<br />
&gt; do<br />
&gt;   echo -en "RSS : ${rss} Kb: "<br />
&gt;   pmap -x $pid | tail -1<br />
&gt; done<br />
RSS: 50104 Kb: total Kb 1384400 712744 494312 -<br />
RSS: 669296 Kb: total Kb 1414648 819496 657584 -</code></p>
<p>This uses the <code>pmap</code> tool to inspect the actual memory usage, which as the <code>ps(1)</code> man page says, is more accurate than just the RSS field of <code>ps</code>.</p>
<p>I suspect that a method using <code>pmap</code> alone might be possible, but this is just a quick note as I go&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/237/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=237&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2012/11/15/track-memory-usage-on-solaris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Updated CheatSheet</title>
		<link>http://nixshell.wordpress.com/2012/09/05/updated-cheatsheet/</link>
		<comments>http://nixshell.wordpress.com/2012/09/05/updated-cheatsheet/#comments</comments>
		<pubDate>Wed, 05 Sep 2012 23:27:01 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=226</guid>
		<description><![CDATA[I have updated the cheatsheet at http://steve-parker.org/sh/cheatsheet.pdf &#8211; it&#8217;s still a single-page PDF, or a PNG at http://steve-parker.org/sh/cheatsheet.png, but it squeezes a bit more content in than the previous one had, and is slightly more Linux/Bash biased.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=226&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I have updated the cheatsheet at <a href="http://steve-parker.org/sh/cheatsheet.pdf">http://steve-parker.org/sh/cheatsheet.pdf</a> &#8211; it&#8217;s still a single-page PDF, or a PNG at <a href="http://steve-parker.org/sh/cheatsheet.png">http://steve-parker.org/sh/cheatsheet.png</a>, but it squeezes a bit more content in than the previous one had, and is slightly more Linux/Bash biased.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/226/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=226&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2012/09/05/updated-cheatsheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>What shell am I running?</title>
		<link>http://nixshell.wordpress.com/2012/03/18/what-shell-am-i-running/</link>
		<comments>http://nixshell.wordpress.com/2012/03/18/what-shell-am-i-running/#comments</comments>
		<pubDate>Sun, 18 Mar 2012 23:58:27 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[faq]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=217</guid>
		<description><![CDATA[Whether you&#8217;ve got an interactive shell session, or are writing a shell script, it is very difficult to be certain. It&#8217;s better to check for the capabilities that you require. If you find yourself in a shell session, but don&#8217;t know what type of shell it is, there are a few ways to find out [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=217&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Whether you&#8217;ve got an interactive shell session, or are writing a shell script, it is very difficult to be certain. It&#8217;s better to check for the capabilities that you require.</p>
<p>If you find yourself in a shell session, but don&#8217;t know what type of shell it is, there are a few ways to find out whether it&#8217;s Bourne shell, Bash, ksh, csh, zsh, tcsh, or whatever.</p>
<p>The simple answer is that you type in the command</p>
<pre class="brush: plain; title: ; notranslate">echo $SHELL</pre>
<p>which should tell you the path to your current shell; if it&#8217;s /bin/ksh or /usr/bin/ksh then it&#8217;s the KornShell; if it&#8217;s /bin/csh then it&#8217;s the C shell, and so on.</p>
<p>However, it&#8217;s not always that simple; Bash will set $SHELL only if it was not already set, so if you were running csh and use that to call bash, then Bash&#8217;s $SHELL will still say csh, not bash. However, Bash will set the $BASH_VERSION variable, but that&#8217;s not really a guarantee that you have that version; it only tells you that there exists a variable which specifies that version. You may not even be running bash at all.</p>
<p>Similarly, some shells (particularly /bin/sh) are symbolic links to others &#8211; whether to bash (GNU/Linux and newer Solaris), dash (some Linux distros more recently), or ksh (AIX).</p>
<p>So $SHELL is a useful start, but not at all definitive. You can search for your UserID in the /etc/passwd file:</p>
<pre class="brush: plain; title: ; notranslate">$ grep steve /etc/passwd
steve:x:1000:1000:Steve Parker,,,:/home/steve:/bin/bash
$ </pre>
<p>But there may be many entries containing the text &#8220;steve&#8221;, and you could be using NIS, LDAP, AD or some other authentication mechanism. $UID should be a read-only variable containing your UserID, and you can search your system-specific passwd via the getent command:</p>
<pre class="brush: plain; title: ; notranslate">$ getent passwd $UID
steve:x:1000:1000:Steve Parker,,,:/home/steve:/bin/bash
$ </pre>
<p>However, as my UID is 1000, this would match any line containing &#8220;1000&#8243; such as an account called &#8220;HAL1000&#8243;. So this should be one way to get your shell:</p>
<pre class="brush: plain; title: ; notranslate">$ getent passwd $UID | cut -d: -f3,7|grep &quot;^${UID}:&quot;
1000:/bin/bash
$ </pre>
<p>Still, you could have run another shell after picking up your default shell. You can always check $0 &#8211; that should tell you how your current shell was called. You don&#8217;t know what the $PATH variable was when that was called &#8211; if $0 says &#8220;/usr/bin/zsh&#8221; then that&#8217;s what was called (of course, it is possible that/usr/bin/zsh could have changed since your shell was invoked!). If it just says &#8220;sh&#8221; then it&#8217;s whatever &#8220;sh&#8221; was found first in the $PATH of the calling shell. And of course, you can&#8217;t find out for sure what state that shell was in at that time.</p>
<p>On a Linux system, &#8220;cat /proc/$$/cmdline&#8221; should also give a good clue; &#8220;ls -l /proc/$$/exe&#8221; is better (but not definitive; it may be marked &#8220;(deleted)&#8221; if it&#8217;s been deleted, so you should check if it&#8217;s been subsequently replaced by some other shell.</p>
<p>So &#8211; it depends why you need to know. If you need to know for sure, on an unknown system, exactly what shell you are in, then I&#8217;m sorry, it&#8217;s not possible to be absolutely certain. To be reasonably confident, check $SHELL or $0. If you need to be more certain than that, then check for the features you require.</p>
<p>If you&#8217;re writing a shell script which requires arrays, then define and access an array, check that the results are as expected, and if not, bail out with a message along the lines of &#8220;an array-capable shell is expected &#8211; we suggest bash or ksh&#8221;.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/217/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=217&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2012/03/18/what-shell-am-i-running/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>rm -rf /</title>
		<link>http://nixshell.wordpress.com/2012/02/01/rm-rf/</link>
		<comments>http://nixshell.wordpress.com/2012/02/01/rm-rf/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 01:56:41 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=207</guid>
		<description><![CDATA[It is commonly said that Solaris 10 will not allow you to issue a rm -rf / command. Few get to try it, but it was being discussed in the office today, so I thought I&#8217;d try it on a virtual machine. The classic rm -rf / gets the message &#8220;rm of / is not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=207&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>It is commonly said that Solaris 10 will not allow you to issue a <code>rm -rf /</code> command. Few get to try it, but it was being discussed in the office today, so I thought I&#8217;d try it on a virtual machine.</p>
<p>The classic <code>rm -rf /</code> gets the message &#8220;rm of / is not allowed&#8221; and a return code of 2. Some variations get the same, whilst others (such as <code>cd /; rm -rf .</code>) get no message, a return code of zero, but nothing happens. Here is a transcript:</p>
<p><code>$ <strong>ssh sunflare</strong><br />
Password:<br />
Last login: Tue Jan 31 21:38:05 2012 from goldie<br />
Oracle Corporation SunOS 5.10 Generic Patch January 2005<br />
steve@sunflare:~$ <strong>su -</strong><br />
Password:<br />
Oracle Corporation SunOS 5.10 Generic Patch January 2005<br />
# bash<br />
<code>root@sunflare:/# <strong>df -h .<br />
</strong></code></code></p>
<p><code>Filesystem             size   used  avail capacity  Mounted on<br />
/dev/md/dsk/d10        9.6G   3.6G   5.9G    38%    /<br />
root@sunflare:/# <strong>rm -rf /</strong><br />
rm of / is not allowed<br />
root@sunflare:/# <strong>echo $?</strong><br />
2<br />
root@sunflare:/# <strong>cd /usr</strong><br />
root@sunflare:/usr# <strong>rm -rf ../</strong><br />
rm of / is not allowed<br />
root@sunflare:/usr# <strong>cd /tmp</strong><br />
root@sunflare:/tmp# <strong>rm -rf ../</strong><br />
rm of / is not allowed<br />
root@sunflare:/tmp# <strong>cd /usr/sfw/bin</strong><br />
root@sunflare:/usr/sfw/bin# <strong>rm -rf ../../..</strong><br />
root@sunflare:/usr/sfw/bin# <strong>cd /</strong><br />
root@sunflare:/# <strong>rm -rf .</strong><br />
root@sunflare:/# <strong>echo $?</strong><br />
0<br />
root@sunflare:/# <strong>pwd</strong><br />
/<br />
root@sunflare:/# <strong>df -h .</strong></code></p>
<p><code><code>/dev/md/dsk/d10        9.6G   3.6G   5.9G    38%    /</code><br />
root@sunflare:/# <strong>cd /dev</strong><br />
root@sunflare:/dev# <strong>rm -rf ../tmp/../</strong><br />
rm of / is not allowed<br />
root@sunflare:/dev# <strong>rm -rf ../tmp/..</strong><br />
root@sunflare:/dev# <strong>exit</strong><br />
steve@sunflare:~$ logout<br />
Connection to sunflare closed.<br />
$</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/207/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=207&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2012/02/01/rm-rf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Shell Scripting book &#8211; out now</title>
		<link>http://nixshell.wordpress.com/2011/09/24/shell-scripting-book-out-now/</link>
		<comments>http://nixshell.wordpress.com/2011/09/24/shell-scripting-book-out-now/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 00:08:17 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=201</guid>
		<description><![CDATA[In case you hadn't heard via other channels, my 564-page book, <i>Shell Scripting: Expert Recipes for Linux, Bash and more</i> is on sale now.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=201&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In case you hadn&#8217;t heard via other channels, my 564-page book, <i>Shell Scripting: Expert Recipes for Linux, Bash and more</i> is on sale now.</p>
<p>Paper books:<br />
<a href="http://www.amazon.com/dp/1118024486/ref=as_li_qf_sp_asin_til?tag=steveparkeror-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=1118024486&amp;adid=03791AEZR7KW17HZ81QR&amp;">Amazon USA</a><br />
<a href="http://www.amazon.co.uk/dp/1118024486/ref=as_li_tf_til?tag=steveparkeror-21&amp;camp=1406&amp;creative=6394&amp;linkCode=as1&amp;creativeASIN=1118024486&amp;adid=0J34QQA8JY54S2K2Q5E4&amp;">Amazon UK</a><br />
Also available at Barnes &amp; Noble, WH Smiths, Waterstones, Supermarkets (online, if not in-store), and as the saying goes, every good bookshop (and some others too).</p>
<p>Kindle: <a href="http://www.amazon.com/dp/B005J58LSO/ref=as_li_tf_til?tag=steveparkeror-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=B005J58LSO&amp;adid=0JB9N2PYHY5MY0JRB0PY&amp;">Kindle</a></p>
<p>iPad / etc: <a href="http://itunes.apple.com/gb/book/shell-scripting/id458591992?mt=11&amp;ign-mpt=uo%3D4">iTunes</a></p>
<p>Nook: <a href="http://www.barnesandnoble.com/w/shell-scripting-steve-parker/1103878597?ean=9781118166321&amp;itm=1&amp;usri=shell%2bscripting">Nook</a></p>
<p>There&#8217;s also a Facebook page at <a href="http://facebook.com/shellscript">facebook.com/shellscript</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/201/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=201&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2011/09/24/shell-scripting-book-out-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Arcade Games written in a Shell Script</title>
		<link>http://nixshell.wordpress.com/2011/07/13/arcade-games-written-in-a-shell-script/</link>
		<comments>http://nixshell.wordpress.com/2011/07/13/arcade-games-written-in-a-shell-script/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 22:08:32 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=194</guid>
		<description><![CDATA[Yes, it is perfectly possible. Do watch this YouTube Video http://www.youtube.com/watch?v=WNPm3aKzPdg Space Invaders &#8211; written entirely in the Bash shell, in a 248-line shell script. The shell is often seen as old hat, hard to use, green screens and no interaction. In my new book, Shell Scripting (http://facebook.com/shellscript), I attempt to throw a new perspective [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=194&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Yes, it is perfectly possible.  Do watch this YouTube Video<br />
<a href="http://www.youtube.com/watch?v=WNPm3aKzPdg">http://www.youtube.com/watch?v=WNPm3aKzPdg</a><br />
<div id="attachment_198" class="wp-caption alignright" style="width: 266px"><a href="http://nixshell.files.wordpress.com/2011/07/space.gif"><img src="http://nixshell.files.wordpress.com/2011/07/space.gif?w=450" alt="Space Game" title="Space Game"   class="size-full wp-image-198" /></a><p class="wp-caption-text">Space Game</p></div><br />
Space Invaders &#8211; written entirely in the Bash shell, in a 248-line shell script.</p>
<p>The shell is often seen as old hat, hard to use, green screens and no interaction. In my new book, Shell Scripting (<a href="http://facebook.com/shellscript">http://facebook.com/shellscript</a>), I attempt to throw a new perspective on this; the shell can be used in lots of creative and imaginative ways.</p>
<p>The book also covers creating CSV files to easily plot complex data in spreadsheets, creating HTML as well as parsing HTML documents; I plan to post more updates before its launch on 12th August 2011.</p>
<p>Shell Scripting by Steve Parker. ISBN 1118024486</p>
<p><a href="http://amzn.com/1118024486">http://amzn.com/1118024486</a><br />
<a href="http://facebook.com/shellscript">http://facebook.com/shellscript</a><br />
<a href="http://sgpit.com/book">http://sgpit.com/book</a></p>
<p>You can get the code for the game <a href="http://media.wiley.com/product_ancillary/86/11180244/DOWNLOAD/Chapter%2017%20code.zip">here</a>. The description and explanation is in the book, of course. But at least the code itself is available online for inspection.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/194/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=194&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2011/07/13/arcade-games-written-in-a-shell-script/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>

		<media:content url="http://nixshell.files.wordpress.com/2011/07/space.gif" medium="image">
			<media:title type="html">Space Game</media:title>
		</media:content>
	</item>
		<item>
		<title>Shell Scripting page on Facebook</title>
		<link>http://nixshell.wordpress.com/2011/07/11/shell-scripting-page-on-facebook/</link>
		<comments>http://nixshell.wordpress.com/2011/07/11/shell-scripting-page-on-facebook/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 17:09:36 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pipes]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=187</guid>
		<description><![CDATA[My Shell Scripting book, due out on August 12th by Wrox, now has a page on Facebook: http://www.facebook.com/pages/Shell-Scripting/175263275869249. Feel free to &#8220;Like&#8221; it, and get the latest updates on the project. I have the final pages to proofread this week, ready to go to the printers. It&#8217;s looking like 576 pages, a little bit over [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=187&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><div id="attachment_189" class="wp-caption alignright" style="width: 190px"><a href="http://nixshell.files.wordpress.com/2011/07/ss.jpg"><img src="http://nixshell.files.wordpress.com/2011/07/ss.jpg?w=450" alt="Shell Scripting" title="Shell Scripting"   class="size-full wp-image-189" /></a><p class="wp-caption-text">Shell Scripting</p></div>My Shell Scripting book, due out on August 12th by Wrox, now has a page on Facebook: <a href="http://www.facebook.com/pages/Shell-Scripting/175263275869249">http://www.facebook.com/pages/Shell-Scripting/175263275869249</a>. Feel free to &#8220;Like&#8221; it, and get the latest updates on the project.</p>
<p>I have the final pages to proofread this week, ready to go to the printers. It&#8217;s looking like 576 pages, a little bit over the target of 504 pages, but close enough.</p>
<p>I will update the Table of Contents at <a href="http://sgpit.com/book/">http://sgpit.com/book/</a> once the page count is finalised.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/187/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=187&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2011/07/11/shell-scripting-page-on-facebook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>

		<media:content url="http://nixshell.files.wordpress.com/2011/07/ss.jpg" medium="image">
			<media:title type="html">Shell Scripting</media:title>
		</media:content>
	</item>
		<item>
		<title>Fork Bomb!</title>
		<link>http://nixshell.wordpress.com/2011/06/03/fork-bomb/</link>
		<comments>http://nixshell.wordpress.com/2011/06/03/fork-bomb/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 00:18:21 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=185</guid>
		<description><![CDATA[A few days ago I had to deal with my first ever real-life fork-bombed server. By logging in to the console, I was somehow able to get a shell (one process). Having got that shell, even though I was root, it was difficult to be able to spawn other processes. It turned out that this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=185&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A few days ago I had to deal with my first ever real-life fork-bombed server.</p>
<p>By logging in to the console, I was somehow able to get a shell (one process). Having got that shell, even though I was root, it was difficult to be able to spawn other processes. It turned out that this was because we had restricted the CPU count on the kernel command line (maxcpus=2) so that a dual processor, 16-core machine had only one eighth of its processing power available. The dynamic change to the nproc value does not take this into account, so this unprivileged user was able to fork-bomb the entire machine.</p>
<p>The first thing you might want to do in this situation is to run ps -eaf. That&#8217;s another process, and even as root, you don&#8217;t get to do it. Being Linux, you can see how many processes exist on the system by listing /proc:<br />
<code>cd /proc<br />
echo *<br />
</code><br />
Neither of these commands spawn a new shell, they are both shell builtin commands, so they will work. In this case, with over 69,000 processes, I killed the output before I got too bored. Since there are usually around 200 processes running, that was enough to tell me that something was wrong.</p>
<p>After many attempts, a ps command did work, and confirmed that a certain shell script was being run a lot of times. I couldn&#8217;t cat that file, and didn&#8217;t even have its full name (ps truncates output to match the terminal&#8217;s width). I had the PID, so /proc/$PID/fd gave the filename.</p>
<p>It&#8217;s not possible to cat the script to see what it&#8217;s doing, so more builtin commands are required.<br />
<code>$ while read f<br />
&gt; do<br />
&gt; echo $f<br />
&gt; done &lt; /path/to/script.sh</code><br />
This uses all builtin commands, and tells you what the script is. From there, you may have some insight into what it is doing, and how to stop it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=185&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2011/06/03/fork-bomb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Shell Scripting Recipes &#8211; Expert Ingredients for Linux, Bash and more</title>
		<link>http://nixshell.wordpress.com/2011/05/29/shell-scripting-recipes-expert-ingredients-for-linux-bash-and-more/</link>
		<comments>http://nixshell.wordpress.com/2011/05/29/shell-scripting-recipes-expert-ingredients-for-linux-bash-and-more/#comments</comments>
		<pubDate>Sun, 29 May 2011 00:36:51 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=178</guid>
		<description><![CDATA[Another update on the upcoming Shell Scripting Recipes book. The writing is complete, the editing formatting and reviewing is now almost totally complete. In the meantime, Amazon&#8217;s UK discount has dropped to £4.80; Amazon.com is still offering a whopping $19.76 (40%) off the pre-order price. The trend seems to be that the prices are going [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=178&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Another update on the upcoming Shell Scripting Recipes book. The writing is complete, the editing formatting and reviewing is now almost totally complete. In the meantime, Amazon&#8217;s UK discount has dropped to £4.80; Amazon.com is still offering a whopping $19.76 (40%) off the pre-order price. The trend seems to be that the prices are going back upwards towards the list price as the launch date (12th August 2011) comes closer so you may save more by ordering a copy now.</p>
<p>The full chapter list is at <a href="http://sgpit.com/book" title="http://sgpit.com/book" target="_blank">http://sgpit.com/book/</a> along with links to other pages with more details about the book.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/178/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=178&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2011/05/29/shell-scripting-recipes-expert-ingredients-for-linux-bash-and-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Update on Shell Scripting Recipes book</title>
		<link>http://nixshell.wordpress.com/2011/04/23/update-on-shell-scripting-recipes-book/</link>
		<comments>http://nixshell.wordpress.com/2011/04/23/update-on-shell-scripting-recipes-book/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 01:06:52 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MLP]]></category>
		<category><![CDATA[pipes]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=167</guid>
		<description><![CDATA[Wow, it's been nearly two months since I last made a post about the upcoming book on shell scripting. I'm really sorry, I had intended to give much more real-time updates here. The book focusses on GNU/Linux and the Bash shell in particular, but it does cover the other environments too - Solaris, Bourne Shell, as well as mentions for ksh, zsh, *BSD and the rest of the Unix family. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=167&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Wow, it&#8217;s been nearly two months since I last made a post about the upcoming book on shell scripting. I&#8217;m really sorry, I had intended to give much more real-time updates here. The book focusses on GNU/Linux and the Bash shell in particular, but it does cover the other environments too &#8211; Solaris, Bourne Shell, as well as mentions for ksh, zsh, *BSD and the rest of the Unix family. </p>
<p>In terms of page count, it is currently 89% finished. There is still the proof-reading to be done, and whatever delivery details the publishers need to deal with, so the availability date of some time in August is still on schedule. I notice that <a href="http://amzn.com/1118024486">http://amzn.com/1118024486</a> is already offering a massive discount on the cover price; I have no idea what that is about, I&#8217;m trying not to take offence &#8211;  they can&#8217;t have dismissed the book already as I have not quite finished writing it yet! So hopefully you can get a bargain while it&#8217;s cheap.</p>
<p>The subject matter has the potential to be quite boring if presented as a list of tedious system administration tasks, so I have tried to make it light and fun whenever I can; it&#8217;s still with Legal at the moment, but I hope to have a Space Invaders clone written entirely in the shell published in the book. People don&#8217;t tend to see the Shell as being capable of doing anything interactive at all, so it is nice to write a playable interactive game in the shell. The main problem in terms of playability is in working out how much to slow it down, and at what stage! Of course, being a shell script, you can tweak the starting value, the level at which it speeds up, and anything else about the gameplay. If the game doesn&#8217;t make it in to the book, I&#8217;ll post it here anyway, and will welcome your contributions on gameplay.</p>
<p>Other than games, I&#8217;ve got recipes for init scripts, conditional execution, translating scripts into other (human) languages, even writing CGI scripts in the shell. There is coverage of arrays, functions, libraries, process control, wildcards and filename expansion, pipes and pipelines, exec and redirection of input and output; this book aims to cover pretty much all that you need to know about shell scripting without being a tedious list of what the bash shell can do.</p>
<p>There is a status page at <a href="http://sgpit.com/book">http://sgpit.com/book</a> which also has order information; you can pre-order your copy from there.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=167&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2011/04/23/update-on-shell-scripting-recipes-book/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Shell Scripting Recipes</title>
		<link>http://nixshell.wordpress.com/2011/03/03/shell-scripting-recipes/</link>
		<comments>http://nixshell.wordpress.com/2011/03/03/shell-scripting-recipes/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 01:13:32 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=163</guid>
		<description><![CDATA[This is just a heads-up that my Shell Scripting Recipes book is due out in August 2011.

I hope to publish more details here as things progress; for now, it is well on the way, but it is not too late for readers to contact me (steve@steve-parker.org) if there is anything that you see as vital for a Shell Scripting Recipes book which was maybe missing from some other book you saw.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=163&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is just a heads-up that my Shell Scripting Recipes book is due out in August 2011.</p>
<p>I hope to publish more details here as things progress; for now, it is well on the way, but it is not too late for readers to contact me (steve@steve-parker.org) if there is anything that you see as vital for a Shell Scripting Recipes book which was maybe missing from some other book you saw.</p>
<p><a href="http://amzn.com/1118024486">http://amzn.com/1118024486</a><br />
<img src="http://ecx.images-amazon.com/images/I/51LgcTSaucL._SL500_AA300_.jpg" alt="Shell Scripting Recipes by Steve Parker" /></p>
<p>Part I covers Language and Usage; all of the concepts of the Shell and how it works.<br />
Part II is Recipes using System Tools. This covers the commands that are necessary for shell scripting, and includes quite a few surprising ways to use them.<br />
Part III is Recipes using Shell Features. This is similar to Part II but it gives concrete uses for the theory presented in Part I.<br />
Part IV is Recipes for Systems Administration. This provides (and explains) various recipes for real-world systems administration tasks of and  beyond the ordinary.  </p>
<p>I do intend to keep you appraised of progress; you can also follow my personal blog at <a href="http://steve-parker.org/urandom/">http://steve-parker.org/urandom/</a> for more detailed updates. The RSS feed for that blog is <a href="http://steve-parker.org/urandom/rss.php">http://steve-parker.org/urandom/rss.php</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=163&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2011/03/03/shell-scripting-recipes/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>

		<media:content url="http://ecx.images-amazon.com/images/I/51LgcTSaucL._SL500_AA300_.jpg" medium="image">
			<media:title type="html">Shell Scripting Recipes by Steve Parker</media:title>
		</media:content>
	</item>
		<item>
		<title>lsof, fuser, nohup, disown, bg, fg, and jobs</title>
		<link>http://nixshell.wordpress.com/2011/02/04/lsof-fuser-nohup-disown-bg-fg-and-jobs/</link>
		<comments>http://nixshell.wordpress.com/2011/02/04/lsof-fuser-nohup-disown-bg-fg-and-jobs/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 01:55:47 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=161</guid>
		<description><![CDATA[lsof is great, but almost only GNU/Linux; fuser is good, but restricted in how much it actually tells you - you have to go digging into PIDs to see what has to be KILLed or otherwise dealt with.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=161&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Bit of a cheeky one here &#8211; what does anybody want to know about these topics?</p>
<p>There is a book in the pipeline, and I have lots to say about all these things, but am very interested to hear what you think is easy / hard / intuitive / arcane / stupid about these commands and the whole job control side of Unix/Linux and the different shells.</p>
<p>lsof is great, but almost only GNU/Linux; fuser is good, but restricted in how much it actually tells you &#8211; you have to go digging into PIDs to see what has to be KILLed or otherwise dealt with.</p>
<p>What, oh faithful few who may still be following this terribly intermittent blog, do you want to see on the subject of processes and job control in the *nix shell?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/161/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=161&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2011/02/04/lsof-fuser-nohup-disown-bg-fg-and-jobs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>2010 in review</title>
		<link>http://nixshell.wordpress.com/2011/01/02/2010-in-review/</link>
		<comments>http://nixshell.wordpress.com/2011/01/02/2010-in-review/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 12:12:42 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=157</guid>
		<description><![CDATA[The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here&#8217;s a high level summary of its overall blog health: The Blog-Health-o-Meter&#8482; reads Fresher than ever. Crunchy numbers A helper monkey made this abstract painting, inspired by your stats. About 3 million people visit the Taj Mahal every year. This [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=157&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[
<p>The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here&#8217;s a high level summary of its overall blog health:</p>
<p align="center"><img style="border:1px solid #ddd;background:#f5f5f5;padding:20px;" src="http://s0.wp.com/i/annual-recap/meter-healthy3.gif" width="250" height="183" alt="Healthy blog!"></p>
<p align="center">The <em>Blog-Health-o-Meter&trade;</em> reads Fresher than ever.</p>
<h2>Crunchy numbers</h2>
<div style="width:288px;float:right;border:1px solid #ddd;background:#fff;margin:0 0 1em 1em;padding:6px;">
<p>				<img src="http://s0.wp.com/i/annual-recap/abstract-stats-6.png" alt="Featured image" /><br />
				<br /><em>A helper monkey made this abstract painting, inspired by your stats.</em></p></div>
<p>About 3 million people visit the Taj Mahal every year.  This blog was viewed about <strong>26,000</strong> times in 2010.  If it were the Taj Mahal, it would take about 3 days for that many people to see it.</p>
<p><p>The busiest day of the year was November 9th with <strong>142</strong> views. The most popular post that day was <a style="color:#08c;" href="http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/">Simple Maths in the Unix Shell</a>.</p>
<p></p>
<h2>Where did they come from?</h2>
<p>The top referring sites in 2010 were <strong>steve-parker.org</strong>, <strong>google.com</strong>, <strong>google.co.in</strong>, <strong>ubuntuforums.org</strong>, and <strong>rackerhacker.com</strong>.</p>
<p>Some visitors came searching, mostly for <strong>bash maths</strong>, <strong>suid bit</strong>, <strong>shell script timestamp</strong>, <strong>awk one liners</strong>, and <strong>bash field separator</strong>.</p>
<div style="clear:both;"></div>
<h2>Attractions in 2010</h2>
<p>These are the posts and pages that got the most views in 2010.</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">1</div>
<p>					<a style="margin-right:10px;" href="http://nixshell.wordpress.com/2007/01/29/simple-maths-in-the-unix-shell/">Simple Maths in the Unix Shell</a> <span style="color:#999;font-size:8pt;">January 2007</span><br />12 comments											</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">2</div>
<p>					<a style="margin-right:10px;" href="http://nixshell.wordpress.com/2007/03/11/timestamps-for-log-files/">Timestamps for Log Files</a> <span style="color:#999;font-size:8pt;">March 2007</span><br />4 comments											</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">3</div>
<p>					<a style="margin-right:10px;" href="http://nixshell.wordpress.com/2007/04/21/suid-shell-scripts-setting-the-sticky-bit/">suid shell scripts &#8211; setting &#8220;the SUID bit&#8221;</a> <span style="color:#999;font-size:8pt;">April 2007</span><br />5 comments											</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">4</div>
<p>					<a style="margin-right:10px;" href="http://nixshell.wordpress.com/2007/09/26/ifs-internal-field-separator/">IFS &#8211; Internal Field Separator</a> <span style="color:#999;font-size:8pt;">September 2007</span><br />10 comments											</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">5</div>
<p>					<a style="margin-right:10px;" href="http://nixshell.wordpress.com/2007/03/26/calculating-averages/">Calculating Averages</a> <span style="color:#999;font-size:8pt;">March 2007</span><br />7 comments											</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/157/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=157&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2011/01/02/2010-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>

		<media:content url="http://s0.wp.com/i/annual-recap/meter-healthy3.gif" medium="image">
			<media:title type="html">Healthy blog!</media:title>
		</media:content>

		<media:content url="http://s0.wp.com/i/annual-recap/abstract-stats-6.png" medium="image">
			<media:title type="html">Featured image</media:title>
		</media:content>
	</item>
		<item>
		<title>inodes &#8211; ctime, mtime, atime</title>
		<link>http://nixshell.wordpress.com/2010/10/07/inodes-ctime-mtime-atime/</link>
		<comments>http://nixshell.wordpress.com/2010/10/07/inodes-ctime-mtime-atime/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 23:04:04 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=152</guid>
		<description><![CDATA[http://www.unix.com/tips-tutorials/20526-mtime-ctime-atime.html has a really good explanation of the different timestamps in a Unix/Linux inode. GNU/Linux has a useful utility called &#8220;stat&#8221; which displays most of the inode contents: $ stat .bashrc File: `.bashrc' Size: 3219 Blocks: 8 IO Block: 4096 regular file Device: fe00h/65024d Inode: 33 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ steve) Gid: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=152&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.unix.com/tips-tutorials/20526-mtime-ctime-atime.html">http://www.unix.com/tips-tutorials/20526-mtime-ctime-atime.html</a> has a really good explanation of the different timestamps in a Unix/Linux inode. GNU/Linux has a useful utility called &#8220;stat&#8221; which displays most of the inode contents:<br />
<code>$ stat .bashrc<br />
  File: `.bashrc'<br />
  Size: 3219      	Blocks: 8          IO Block: 4096   regular file<br />
Device: fe00h/65024d	Inode: 33          Links: 1<br />
Access: (0644/-rw-r--r--)  Uid: ( 1000/   steve)   Gid: ( 1000/   steve)<br />
Access: 2010-10-07 01:11:21.000000000 +0100<br />
Modify: 2010-08-19 21:22:20.000000000 +0100<br />
Change: 2010-08-19 21:22:21.000000000 +0100<br />
$ </code><br />
As Perderabo explains in the above-linked post:</p>
<blockquote><p>
Unix keeps 3 timestamps for each file: mtime, ctime, and atime. Most people seem to understand atime (access time), it is when the file was last read. There does seem to be some confusion between mtime and ctime though. ctime is the inode change time while mtime is the file modification time. &#8220;Change&#8221; and &#8220;modification&#8221; are pretty much synonymous. There is no clue to be had by pondering those words. Instead you need to focus on what is being changed. mtime changes when you write to the file. It is the age of the data in the file. Whenever mtime changes, so does ctime. But ctime changes a few extra times. For example, it will change if you change the owner or the permissions on the file.</p>
<p>Let&#8217;s look at a concrete example. We run a package called Samba that lets PC&#8217;s access files. To change the Samba configuration, I just edit a file called smb.conf. (This changes mtime and ctime.) I don&#8217;t need to take any other action to tell Samba that I changed that file. Every now and then Samba looks at the mtime on the file. If the mtime has changed, Samba rereads the file. Later that night our backup system runs. It uses ctime, which also changed so it backs up the file. But let&#8217;s say that a couple of days later I notice that the permissions on smb.conf are 666. That&#8217;s not good..anyone can edit the file. So I do a &#8220;chmod 644 smb.conf&#8221;. This changes only ctime. Samba will not reread the file. But later that night, our backup program notices that ctime has changes, so it backs up the file. That way, if we lose the system and need to reload our backups, we get the new improved permission setting.</p>
<p>Here is a second example. Let&#8217;s say that you have a data file called employees.txt which is a list of employees. And you have a program to print it out. The program not only prints the data, but it obtains the mtime and prints that too. Now someone has requested an employee list from the end of the year 2000 and you found a backup tape that has that file. Many restore programs will restore the mtime as well. When you run that program it will print an mtime from the end of the year 2000. But the ctime is today. So again, our backup program will see the file as needing to be backed up.</p>
<p>Suppose your restore program did not restore the mtime. You don&#8217;t want your program to print today&#8217;s date. Well no problem. mtime is under your control. You can set it to what ever you want. So just do:<br />
$ touch -t 200012311800 employees.txt<br />
This will set mtime back to the date you want and it sets ctime to now. You have complete control over mtime, but the system stays in control of ctime. So mtime is a little bit like the date on a letter while ctime is like the postmark on the envelope.</p></blockquote>
<p>This is a really clear, thorough explanation of ctime and mtime. Unfortunately, it is not possible to find the original creation time of a file, though that is somewhat meaningless as things are copied, moved, linked, changed; what is the creation time of a file which was created, removed, then created afresh, for example?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/152/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=152&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2010/10/07/inodes-ctime-mtime-atime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Interview with Steve Bourne</title>
		<link>http://nixshell.wordpress.com/2010/08/26/145/</link>
		<comments>http://nixshell.wordpress.com/2010/08/26/145/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 23:45:39 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=145</guid>
		<description><![CDATA[ARNnet have an Interview with Steve Bourne I believe you can write shell scripts that will run either in the Bourne shell or Bash. It may have some additional features that aren’t in the Bourne shell. I believe Bash was intended as a strictly compatible open source version of the Bourne shell. Honestly I haven’t [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=145&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>ARNnet have an <a href="http://www.arnnet.com.au/article/279011/a-z_programming_languages_bourne_shell_sh/">Interview with Steve Bourne</a></p>
<blockquote><p>    I believe you can write shell scripts that will run either in the Bourne shell or Bash. It may have some additional features that aren’t in the Bourne shell. I believe Bash was intended as a strictly compatible open source version of the Bourne shell. Honestly I haven’t looked at it in any detail so I could be wrong. I have used Bash myself because I run a Linux/Gnu system at home and it appears to do what I would expect.</p></blockquote>
<p>I have nearly finished reading <a href="http://www.codersatwork.com/">Coders At Work</a> &#8211; Steve Bourne could have been an interesting interviewee for that book.</p>
<p> When I first posted this link at <a href="http://steve-parker.org/urandom/comment.php?art=879">urandom</a>, I was not aware that I myself was quoted, at the top of page 5 of the 7-page interview:</p>
<blockquote><p> Unix Specialist Steve Parker has posted <a href="http://steve-parker.org/sh/sh.shtml">&#8216;Steve&#8217;s Bourne / Bash scripting tutorial&#8217;</a> in which he writes: &#8220;Shell script programming has a bit of a bad press amongst some Unix systems administrators. This is normally because of one of two things: a) The speed at which an interpreted program will run as compared to a C program, or even an interpreted Perl program; b) Since it is easy to write a simple batch-job type shell script, there are a lot of poor quality shell scripts around.&#8221; Do you agree?</p>
<p>    It would be hard to disagree because he probably knows more about it than I do. The truth of the matter is you can write bad code in any language, or most languages anyway, and so the shell is no exception to that. Just as you can write obfuscated C you can write obfuscated shell. It may be that it is easier to write obfuscated shell than it is to write obfuscated C. I don’t know. But that’s the first point.</p>
<p>    The second point is that the shell is a string processing language and the string processing is fairly simple. So there is no fundamental reason why it shouldn’t run fairly efficiently for those tasks. I am not familiar with the performance of Bash and how that is implemented. Perhaps some of the people that he is talking about are running Bash versus the shell but again I don’t have any performance comparisons for them. But that is where I would go and look. I know when I wrote the original implementation of the shell I spent a lot of time making sure that it was efficient. And in particular with respect to the string processing but also just the reading of the command file. In the original implementation that I wrote, the command file was pre-loaded and pre-digested so when you executed it you didn’t have to do any processing except the string substitutions and any of the other semantics that would change values. So that was about as efficient as you could get in an interpretive language without generating code.</p></blockquote>
<p>I think that the points were presented to Steve Bourne in reverse order; his answer to the first point seems to relate to &#8220;b&#8221; (quality of scripts), and his longer answer to the second point seems to relate to &#8220;a&#8221; (performance).</p>
<p>Regarding performance, as he says, the real cost is of the Unix exec() call, which makes &#8220;cat /etc/hosts | grep localhost&#8221; half as fast as &#8220;grep localhost /etc/hosts&#8221;. There is nothing that the shell itself can do about that.</p>
<p>Regarding quality, deliberately obfusacated C is an institution; my point was merely that it is easy to write a bad shell script simply by not knowing how to write a better shell script. As this quote was from the introduction to a shell scripting tutorial, it should hopefully be clear from the context that the tutorial aims to enable the reader to write better shell scripts.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=145&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2010/08/26/145/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Solaris 10 SMF Manifests</title>
		<link>http://nixshell.wordpress.com/2010/07/17/solaris-10-smf-manifests/</link>
		<comments>http://nixshell.wordpress.com/2010/07/17/solaris-10-smf-manifests/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 23:56:07 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=142</guid>
		<description><![CDATA[I have recently written a web service which creates Solaris 10 SMF manifests based on the information you give it. It creates a ZIP file with the XML Manifest file, and the startup/shutdown script, based on what you tell it. There is much more that SMF can do &#8211; create entire new runlevels, and so [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=142&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I have recently written a web service which creates <a href="http://sgpit.com/smf/">Solaris 10 SMF manifests</a> based on the information you give it.</p>
<p>It creates a ZIP file with the XML Manifest file, and the startup/shutdown script, based on what you tell it.</p>
<p>There is much more that SMF can do &#8211; create entire new runlevels, and so on &#8211; but this does the basic single-instance startup and shutdown stuff that /etc/init.d scripts did.</p>
<p>Feel free to go and check it out at <a href="http://sgpit.com/smf/">sgpit.com/smf/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/142/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=142&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2010/07/17/solaris-10-smf-manifests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Useful GNU/Linux Commands</title>
		<link>http://nixshell.wordpress.com/2010/06/23/useful-gnulinux-commands/</link>
		<comments>http://nixshell.wordpress.com/2010/06/23/useful-gnulinux-commands/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 01:08:45 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=137</guid>
		<description><![CDATA[Pádraig Brady has some useful, if somewhat basic hints, at http://www.pixelbeat.org/cmdline.html. He has updated them to include more powerful commands at http://www.pixelbeat.org/docs/linux_commands.html. Here are a few of my favourites (I have taken the liberty of slightly altering some of the code and/or descriptions): From the original: Search recursively for &#8220;expr&#8221; in all *.c and *.h [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=137&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Pádraig Brady has some useful, if somewhat basic hints, at <a href="http://www.pixelbeat.org/cmdline.html">http://www.pixelbeat.org/cmdline.html</a>. He has updated them to include more powerful commands at <a href="http://www.pixelbeat.org/docs/linux_commands.html">http://www.pixelbeat.org/docs/linux_commands.html</a>.</p>
<p>Here are a few of my favourites (I have taken the liberty of slightly altering some of the code and/or descriptions):<br />
<b>From the original:</b><br />
Search recursively for &#8220;expr&#8221; in all *.c and *.h files:<br />
<code>find -name '*.[ch]' | xargs grep -E 'expr'</code></p>
<p>Concatenate lines with training backslash:<br />
<code>sed ':a; /\\$/N; s/\\\n//; ta'</code></p>
<p>Delete line 42 from .known_hosts:<br />
<code>sed -i 42d ~/.ssh/known_hosts</code></p>
<p><b>From the new post:</b><br />
Echo the path one item per line (assumes GNU tr):<br />
<code>echo $PATH | tr : '\n'</code></p>
<p>Top for Network:<br />
<code>iftop</code><br />
Top for Input/Output (I/O):<br />
<code>iotop</code></p>
<p>Get SSL website Certificate:<br />
<code>openssl s_client -connect <a href="http://www.google.com:443" rel="nofollow">http://www.google.com:443</a> &lt; /dev/null</code></p>
<p>List processes with Port 80 open:<br />
<code>lsof -i tcp:80</code></p>
<p>Edit a remote file directly in vim:<br />
<code>vim scp://user@remote//path/to/file</code></p>
<p>Add 20ms latency to loopback device (for testing):<br />
<code>tc qdisc add dev lo root handle 1:0 netem delay 20msec</code><br />
Remove the latency:<br />
<code>tc qdisc del dev lo root</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=137&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2010/06/23/useful-gnulinux-commands/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Ten Good Unix Habits</title>
		<link>http://nixshell.wordpress.com/2010/06/22/ten-good-unix-habits/</link>
		<comments>http://nixshell.wordpress.com/2010/06/22/ten-good-unix-habits/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 00:45:46 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MLP]]></category>
		<category><![CDATA[pipes]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=134</guid>
		<description><![CDATA[IBM&#8217;s DeveloperWorks has 10 Good Unix Habits, which apply to GNU/Linux at least as much as to Unix. I would expect that most experienced admins can second-guess the content to 5-7 of these 10 points, just from the title (for example, item 1 is a reference to &#8220;mkdir -p&#8221;, plus another related syntax available to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=134&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>IBM&#8217;s DeveloperWorks has <a href="http://www.ibm.com/developerworks/aix/library/au-badunixhabits.html?ca=lnxw01GoodUnixHabits">10 Good Unix Habits</a>, which apply to GNU/Linux at least as much as to Unix.</p>
<p>I would expect that most experienced admins can second-guess the content to 5-7 of these 10 points, just from the title (for example, item 1 is a reference to &#8220;mkdir -p&#8221;, plus another related syntax available to Bash users). I would be surprised if you knew all ten:</p>
<p>   1. Make directory trees in a single swipe.<br />
   2. Change the path; do not move the archive.<br />
   3. Combine your commands with control operators.<br />
   4. Quote variables with caution.<br />
   5. Use escape sequences to manage long input.<br />
   6. Group your commands together in a list.<br />
   7. Use xargs outside of find .<br />
   8. Know when grep should do the counting &#8212; and when it should step aside.<br />
   9. Match certain fields in output, not just lines.<br />
  10. Stop piping cats.</p>
<p>How many did you get?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=134&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2010/06/22/ten-good-unix-habits/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Unix / Linux Training Courses in the UK</title>
		<link>http://nixshell.wordpress.com/2010/05/11/unix-linux-training-courses-in-the-uk/</link>
		<comments>http://nixshell.wordpress.com/2010/05/11/unix-linux-training-courses-in-the-uk/#comments</comments>
		<pubDate>Tue, 11 May 2010 22:38:54 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[training]]></category>
		<category><![CDATA[uk]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=126</guid>
		<description><![CDATA[.... The kind of training session I would envisage us providing, would involve a fairly small class size (less than 6 people), allowing us to focus on your current issues, and tailor the course around the needs, interests and skills of the attendees.....<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=126&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>After a few customers requesting it, my consultancy firm, <a href="http://sgpit.com/">SGP IT</a>, is planning to run some technical training courses this Summer; in the Manchester area initially, though any location is possible.</p>
<p>Now would be a very good time to get in touch (<a href="mailto:training@sgpit.com">training@sgpit.com</a>) as things are at a very early stage and very fluid &#8211; if you can bring a few people along, we can even run a bespoke course for you, and tailor everything to your need.</p>
<p>Depending on subject, duration, location and so on, it should be possible to run the first few courses for as little as £250 &#8211; £300 per person per day &#8211; much less than the £400 &#8211; £500 or so you&#8217;d pay for a corporate course where you all get is a trainer who has no experience of the actual situation you face at work, and who delivers powerpoint slides to you, then doles out the free mousepads and t-shirts at the end of the course.</p>
<p>None of us have been overly impressed by many of the available training courses &#8211; we are hoping to redefine how personal IT training can be delivered. Here&#8217;s how:</p>
<p>The kind of training session I would envisage us providing, would involve a fairly small class size (certainly fewer than 6 people), allowing us to focus on your current issues, and tailor the course around the needs, interests and skills of the attendees. The courses are likely to be between 2 and 5 days, most being 2-3 day courses.</p>
<p>Of course, there will be no corners cut &#8211; we will insist on great location and facilities, free internet access, PCs for all candidates (preinstalled with Linux, Solaris, *BSD, you name it &#8211; contact us before the course and we&#8217;ll build the PC to suit you), tons of good quality course notes, including certificates and the obligatory full VAT receipts, of course. I&#8217;m sure that we can find a few freebies to throw in, too!</p>
<p>If you have specific queries or concerns that you would like to be addressed in the course, let us know up-front, and we can find a way to work it in to the course.</p>
<p>If any of this sounds vaguely interesting, please do get in touch (<a href="mailto:training@sgpit.com">training@sgpit.com</a>) and we can mold things around your requirements.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/126/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=126&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2010/05/11/unix-linux-training-courses-in-the-uk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Use of pipes, and other nifty tricks</title>
		<link>http://nixshell.wordpress.com/2009/12/18/use-of-pipes-and-other-nifty-tricks/</link>
		<comments>http://nixshell.wordpress.com/2009/12/18/use-of-pipes-and-other-nifty-tricks/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 00:05:09 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MLP]]></category>
		<category><![CDATA[pipes]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=124</guid>
		<description><![CDATA[These hints go on and on; hardly any of them are the generic stuff you often see on Ubuntu forums, stumbleupon, and so on.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=124&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.tuxradar.com/content/command-line-tricks-smart-geeks">http://www.tuxradar.com/content/command-line-tricks-smart-geeks</a> has some useful tricks. A lot of it is presented as being bash-specific, but isn&#8217;t. Also, a lot seems Linux-specific, but isn&#8217;t. Lots of useful info for all Unix/Linux admins here. These hints go on and on; hardly any of them are the generic stuff you often see on Ubuntu forums, stumbleupon, and so on.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/124/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=124&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2009/12/18/use-of-pipes-and-other-nifty-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>Flushing Cache to Disk under Linux</title>
		<link>http://nixshell.wordpress.com/2009/11/04/flushing-cache-to-disk-under-linux/</link>
		<comments>http://nixshell.wordpress.com/2009/11/04/flushing-cache-to-disk-under-linux/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 01:06:03 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=121</guid>
		<description><![CDATA[There are lots of well-written articles, such as this [westnet.com] and especially this [kerneltrap] on Page Cacheing and pdflush, but RackerHacker (although the title says &#8220;reads&#8221;, it really seems to address lots of small writes) summarises it very well: vm.dirty_ratio – The highest % of your memory that can be used to hold dirty data. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=121&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>There are lots of well-written articles, such as <a href="http://www.westnet.com/~gsmith/content/linux-pdflush.htm">this</a> [westnet.com] and especially <a href="http://kerneltrap.org/node/3000">this</a> [kerneltrap] on Page Cacheing and pdflush, but <a href="http://rackerhacker.com/2008/08/07/reduce-disk-io-for-small-reads-using-memory/">RackerHacker</a> (although the title says &#8220;reads&#8221;, it really seems to address lots of small writes) summarises it very well:</p>
<blockquote><p><strong>vm.dirty_ratio</strong> – The highest % of your memory that can be used to hold dirty data. If you set this to a low value, the kernel will flush small writes to the disk more often. Higher values allow the small writes to stack up in memory. They’ll go to the disk in bigger chunks.</p>
<p><strong>vm.dirty_background_ratio</strong> – The lowest % of your memory where pdflush is told to stop when it is writing dirty data. You’ll want to keep this set as low as possible.</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=121&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2009/11/04/flushing-cache-to-disk-under-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>find, locate, whereis, which, type</title>
		<link>http://nixshell.wordpress.com/2009/09/16/find-locate-whereis-which-type/</link>
		<comments>http://nixshell.wordpress.com/2009/09/16/find-locate-whereis-which-type/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 00:13:15 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=117</guid>
		<description><![CDATA[I suspect that most Linux admins know 3 or 4 of these five commands, and regularly use 2 or 3 of them. linuxhaxor has a useful introduction to all five, with the most common uses for each of them. Note that locate requires a regular run of updatedb &#8211; the article says that &#8220;The database [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=117&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I suspect that most Linux admins know 3 or 4 of these five commands, and regularly use 2 or 3 of them.</p>
<p><a href="http://www.linuxhaxor.net/2008/09/25/5-ways-to-search-for-files-using-the-terminal-in-linux/">linuxhaxor</a> has a useful introduction to all five, with the most common uses for each of them.</p>
<p>Note that <code>locate</code> requires a regular run of <code>updatedb</code> &#8211; the article says that &#8220;The database is automatically created and updated daily&#8221; which is true for most distributions, but it depends on your <code>cron</code> setup &#8211; you can update the locate db as frequently as you wish. Another thing to note about <code>locate</code> is that it will not use the (normally <code>root</code>-generated) database to tell you (as a non-privileged user) about files which you would not otherwise know about.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=117&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2009/09/16/find-locate-whereis-which-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
		<item>
		<title>get the width of the terminal</title>
		<link>http://nixshell.wordpress.com/2009/09/08/get-the-width-of-the-terminal/</link>
		<comments>http://nixshell.wordpress.com/2009/09/08/get-the-width-of-the-terminal/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 15:43:32 +0000</pubDate>
		<dc:creator>unixshell</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://nixshell.wordpress.com/?p=112</guid>
		<description><![CDATA[A quick and easy way to get the width of your Linux terminal is the command <code>stty size</code><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=112&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A quick and easy way to get the width of your terminal is the command <code>stty size</code>. I have used it with <code>diff</code> like this:</p>
<blockquote><p>diff -y -W `stty size | cut -d&#8221; &#8221; -f2` &#8211;suppress-common-lines oldfile newfile</p></blockquote>
<p>Note: This stty option is not available on Solaris, however, if you have it installed, the /usr/openwin/bin/resize command sets the COLUMNS variable.</p>
<p><strong>update:</strong> This post originally said &#8220;width of your Linux terminal&#8221; but as noted in the comments, this feature of <code>stty</code> is also available in *BSD implementations, even though it is not part of the <code>POSIX</code> standard. So you should expect this to work on GNU and BSD systems (eg, most GNU/Linux distros, most *BSDs, including OSX) but not on all POSIX-compliant systems (eg, Solaris). I would assume that AIX, HPUX, SCO, the other &#8220;traditional&#8221; UNIX systems would also not support this, though I have not (yet) tested any of them. YMMV.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nixshell.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nixshell.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nixshell.wordpress.com&#038;blog=691157&#038;post=112&#038;subd=nixshell&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nixshell.wordpress.com/2009/09/08/get-the-width-of-the-terminal/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8ab417ce7eba8048dd89d99088e7b7e5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">unixshell</media:title>
		</media:content>
	</item>
	</channel>
</rss>
