Shell Scripting Tutorial on Kindle

March 29, 2013

Unix & Linux Shell Scripting Tutorial on Kindle

Unix & Linux Shell Scripting Tutorial on Kindle

The Shell Scripting tutorial at is now available natively on the Kindle!


UK (

Similarly, you can search for “B00C2EGNSA” on any Amazon site, or just go to (where “COUNTRY” is .fr, .de, etc) for your local equivalent.


Persian translation of Shell Scripting Tutorial

December 15, 2012

Mahmood Pahlevani has translated my Shell Scripting tutorial at into Persian, at

Any feedback on this work is welcome here, I will pass on all praise to Mahmood,


Track memory usage on Solaris

November 15, 2012

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 (“steve”) but by omitting the “-u steve” flag to ps, the whole system will be checked.

$ps -ea -o pid,rss -u steve | sort -n -k 2 | while read pid rss
> do
> echo -en "RSS : ${rss} Kb: "
> pmap -x $pid | tail -1
> done
RSS: 50104 Kb: total Kb 1384400 712744 494312 -
RSS: 669296 Kb: total Kb 1414648 819496 657584 -

This uses the pmap tool to inspect the actual memory usage, which as the ps(1) man page says, is more accurate than just the RSS field of ps.

I suspect that a method using pmap alone might be possible, but this is just a quick note as I go…

Updated CheatSheet

September 5, 2012

I have updated the cheatsheet at – it’s still a single-page PDF, or a PNG at, but it squeezes a bit more content in than the previous one had, and is slightly more Linux/Bash biased.

rm -rf /

February 1, 2012

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’d try it on a virtual machine.

The classic rm -rf / gets the message “rm of / is not allowed” and a return code of 2. Some variations get the same, whilst others (such as cd /; rm -rf .) get no message, a return code of zero, but nothing happens. Here is a transcript:

$ ssh sunflare
Last login: Tue Jan 31 21:38:05 2012 from goldie
Oracle Corporation SunOS 5.10 Generic Patch January 2005
steve@sunflare:~$ su -
Oracle Corporation SunOS 5.10 Generic Patch January 2005
# bash
root@sunflare:/# df -h .

Filesystem             size   used  avail capacity  Mounted on
/dev/md/dsk/d10        9.6G   3.6G   5.9G    38%    /
root@sunflare:/# rm -rf /
rm of / is not allowed
root@sunflare:/# echo $?
root@sunflare:/# cd /usr
root@sunflare:/usr# rm -rf ../
rm of / is not allowed
root@sunflare:/usr# cd /tmp
root@sunflare:/tmp# rm -rf ../
rm of / is not allowed
root@sunflare:/tmp# cd /usr/sfw/bin
root@sunflare:/usr/sfw/bin# rm -rf ../../..
root@sunflare:/usr/sfw/bin# cd /
root@sunflare:/# rm -rf .
root@sunflare:/# echo $?
root@sunflare:/# pwd
root@sunflare:/# df -h .

/dev/md/dsk/d10        9.6G   3.6G   5.9G    38%    /
root@sunflare:/# cd /dev
root@sunflare:/dev# rm -rf ../tmp/../
rm of / is not allowed
root@sunflare:/dev# rm -rf ../tmp/..
root@sunflare:/dev# exit
steve@sunflare:~$ logout
Connection to sunflare closed.

Shell Scripting book – out now

September 24, 2011

In case you hadn’t heard via other channels, my 564-page book, Shell Scripting: Expert Recipes for Linux, Bash and more is on sale now.

Paper books:
Amazon USA
Amazon UK
Also available at Barnes & Noble, WH Smiths, Waterstones, Supermarkets (online, if not in-store), and as the saying goes, every good bookshop (and some others too).

Kindle: Kindle

iPad / etc: iTunes

Nook: Nook

There’s also a Facebook page at

Arcade Games written in a Shell Script

July 13, 2011

Yes, it is perfectly possible. Do watch this YouTube Video

Space Game

Space Game

Space Invaders – 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 (, I attempt to throw a new perspective on this; the shell can be used in lots of creative and imaginative ways.

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.

Shell Scripting by Steve Parker. ISBN 1118024486

You can get the code for the game here. The description and explanation is in the book, of course. But at least the code itself is available online for inspection.