<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Shell Tips ! &#187; Bash &#8211; GNU Shell</title>
	<atom:link href="http://www.shell-tips.com/category/bash-gnu-shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shell-tips.com</link>
	<description>Some useful tips about CLI tools, Shell scripts and batch files... GNU Bash, Windows XP, SQL, Help Sheets / Cheat Sheets, etc.</description>
	<lastBuildDate>Mon, 14 Jun 2010 08:56:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Performing Math calculation in Bash</title>
		<link>http://www.shell-tips.com/2010/06/14/performing-math-calculation-in-bash/</link>
		<comments>http://www.shell-tips.com/2010/06/14/performing-math-calculation-in-bash/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 08:56:44 +0000</pubDate>
		<dc:creator>Nicolas Brousse</dc:creator>
				<category><![CDATA[Bash - GNU Shell]]></category>
		<category><![CDATA[Common CLI]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bc]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.shell-tips.com/?p=184</guid>
		<description><![CDATA[I use math in bash scripts a lot, from simple crontab reports to Nagios monitoring plugins&#8230; Here is few small examples on how to do some maths in Bash with integers or float. Integer Math First way to do math with integer (and only integer) is to use the command &#8220;expr &#8212; evaluate expression&#8220;. Mac-n-Cheese:~ [...]]]></description>
			<content:encoded><![CDATA[<p>I use math in bash scripts a lot, from simple crontab reports to Nagios monitoring plugins&#8230; Here is few small examples on how to do some maths in Bash with integers or float.</p>
<p><span id="more-184"></span><strong>Integer Math<br />
</strong></p>
<p>First way to do math with integer (and only integer) is to use the command &#8220;<em>expr &#8212; evaluate expression</em>&#8220;.</p>
<pre class="brush:shell">Mac-n-Cheese:~ nicolas$ expr 1 + 1
2
Mac-n-Cheese:~ nicolas$ myvar=$(expr 1 + 1)
Mac-n-Cheese:~ nicolas$ echo $myvar
2
Mac-n-Cheese:~ nicolas$ expr $myvar + 1
3
Mac-n-Cheese:~ nicolas$ expr $myvar / 3
1
Mac-n-Cheese:~ nicolas$ expr $myvar \* 3
9
</pre>
<p>When doing a &#8220;multiply by&#8221; make sure to backslash the &#8220;asterisk&#8221;  as it&#8217;s a wildcard in Bash used for expansion.</p>
<p>Another alternative to <em>expr</em>, is to use the bash builtin command <em>let</em>.</p>
<pre class="brush:shell">Mac-n-Cheese:~ nicolas$ echo $myvar
6
Mac-n-Cheese:~ nicolas$ let myvar+=1
Mac-n-Cheese:~ nicolas$ echo $myvar
7
Mac-n-Cheese:~ nicolas$ let myvar+1
Mac-n-Cheese:~ nicolas$ echo $myvar
7
Mac-n-Cheese:~ nicolas$ let myvar2=myvar+1
Mac-n-Cheese:~ nicolas$ echo $myvar2
8
</pre>
<p>Also, you can simply use the parentheses or square brackets :</p>
<pre class="brush:shell">Mac-n-Cheese:~ nicolas$ echo $myvar
3
Mac-n-Cheese:~ nicolas$ echo $((myvar+2))
5
Mac-n-Cheese:~ nicolas$ echo $[myvar+2]
5
Mac-n-Cheese:~ nicolas$ myvar=$((myvar+3))
</pre>
<p>This allow you to use C-style programming :</p>
<pre class="brush:shell">Mac-n-Cheese:~ nicolas$ echo $myvar
3
Mac-n-Cheese:~ nicolas$ echo $((myvar++))
3
Mac-n-Cheese:~ nicolas$ echo $myvar
4
Mac-n-Cheese:~ nicolas$ echo $((++myvar))
5
Mac-n-Cheese:~ nicolas$ echo $myvar
5
</pre>
<p><strong>Floating point arithmetic</strong></p>
<p>If you need to do floating point arithmetic, you will have to use a command line tool, the most common one is &#8220;<em>bc &#8211; An arbitrary precision calculator language</em>&#8220;.</p>
<pre class="brush:shell">Mac-n-Cheese:~ nicolas$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
3*5.2+7/8
15.6
15.6+299.33*2.3/7.4
108.6
</pre>
<p>Of course you can use the STDIN to send your formula to &#8220;<em>bc</em>&#8221; then get the output on STDOUT.</p>
<pre class="brush:shell">Mac-n-Cheese:~ nicolas$ echo "3.4+7/8-(5.94*3.14)" | bc
-15.25
</pre>
<p>I encourage you too take a look at the man pages to get more detail on how it works (<em>man bc</em>).</p>
<blockquote><p>There are four special variables, scale, ibase, obase, and last.  scale defines how some operations use digits after the decimal point.  The default value of scale is 0. ibase and obase define the conver-<br />
sion base for input and output numbers.  The default for both input and output is base 10.  last (an extension) is a variable that has the value of the last printed number.</p></blockquote>
<p>The &#8220;scale&#8221; variable is really important for the precision of your results, especially when using integers only (Note: you can also use &#8220;bc -l&#8221; to use mathlib and see the result at max scale) .</p>
<pre class="brush:shell">Mac-n-Cheese:~ nicolas$ echo "2/3" | bc
0
Mac-n-Cheese:~ nicolas$ echo "scale=2; 2/3" | bc
.66
Mac-n-Cheese:~ nicolas$ echo "(2/3)+(7/8)" | bc
0
Mac-n-Cheese:~ nicolas$ echo "scale=2;(2/3)+(7/8)" | bc
1.53
Mac-n-Cheese:~ nicolas$ echo "scale=4;(2/3)+(7/8)" | bc
1.5416
Mac-n-Cheese:~ nicolas$ echo "scale=6;(2/3)+(7/8)" | bc
1.541666
Mac-n-Cheese:~ nicolas$ echo "(2/3)+(7/8)" | bc -l
1.54166666666666666666
</pre>
<p>You can also use the here-doc notation to pass your formula to bc :</p>
<pre class="brush:shell">Mac-n-Cheese:~ nicolas$ bc -l &lt;&lt;&lt; "(2/3)+(7/8)"
1.54166666666666666666
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F&amp;title=Performing+Math+calculation+in+Bash" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F&amp;title=Performing+Math+calculation+in+Bash" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F&amp;title=Performing+Math+calculation+in+Bash" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F&amp;headline=Performing+Math+calculation+in+Bash" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Performing+Math+calculation+in+Bash&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Performing+Math+calculation+in+Bash&amp;u=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Performing+Math+calculation+in+Bash&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Performing+Math+calculation+in+Bash&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Performing+Math+calculation+in+Bash&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F&amp;title=Performing+Math+calculation+in+Bash&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.shell-tips.com%2F2010%2F06%2F14%2Fperforming-math-calculation-in-bash%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.shell-tips.com/2010/06/14/performing-math-calculation-in-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using losetup and dd to secure sensitive data (encrypted block device)</title>
		<link>http://www.shell-tips.com/2008/07/13/using-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device/</link>
		<comments>http://www.shell-tips.com/2008/07/13/using-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 22:26:06 +0000</pubDate>
		<dc:creator>Nicolas Brousse</dc:creator>
				<category><![CDATA[Bash - GNU Shell]]></category>
		<category><![CDATA[Case Study]]></category>
		<category><![CDATA[dd]]></category>
		<category><![CDATA[device]]></category>
		<category><![CDATA[encrypt]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[losetup]]></category>
		<category><![CDATA[secure]]></category>

		<guid isPermaLink="false">http://www.shell-tips.com/?p=41</guid>
		<description><![CDATA[My previous post was made a long time ago, so here is a draft that I finally decide to post. Let&#8217;s see how to secure some of your data with an encrypted block device using losetup and dd. Steps will be : Create an image with dd Build a new device using the image with [...]]]></description>
			<content:encoded><![CDATA[<p>My previous post was made a long time ago, so here is a draft that I finally decide to post. Let&#8217;s see how to secure some of your data with an encrypted block device using losetup and dd.</p>
<p>Steps will be :</p>
<ol>
<li>Create an image with dd</li>
<li>Build a new device using the image with an encrypt algorythm by using losetup</li>
<li>Format the device using mkfs.ext3</li>
<li>Mount the device and start using it !</li>
</ol>
<p>Of course, when you have mounted the device, your data are readable to anyone who have access to the mounted directory.</p>
<p><span id="more-41"></span></p>
<p><strong>Create an image with dd</strong></p>
<pre class="brush:bash">root@vm-ubuntu-lamp:~# dd if=/dev/zero of=encrypted.img bs=4k count=1000 seek=4001
1000+0 records in
1000+0 records out
4096000 bytes (4,1 MB) copied, 0,10063 seconds, 40,7 MB/s
We now have a raw image file using 4MB.
<blockquote>

root@vm-ubuntu-lamp:~# ls -l encrypted.img
-rw-r--r-- 1 root root 20484096 2008-07-12 13:38 encrypted.img
root@vm-ubuntu-lamp:~# du -hs encrypted.img
4,0M    encrypted.img</blockquote>
</pre>
<p><strong>Create the encrypted device</strong></p>
<blockquote><p>root@vm-ubuntu-lamp:~# losetup -e aes /dev/loop0 encrypted.img<br />
Password:<br />
ioctl: LOOP_SET_STATUS: Invalid argument</p></blockquote>
<p>Ooops.. Something wrong. Our losetup bin isn&#8217;t patched to use AES. On ubuntu/debian based OS, it&#8217;s is to deal.</p>
<pre class="brush:bash">apt-get install loop-aes-utils
root@vm-ubuntu-lamp:~# losetup -e aes /dev/loop0 encrypted.img
Password:
ioctl: LOOP_SET_STATUS: Invalid argument, requested cipher or key length (128 bits) not supported by kernel</pre>
<p>Hmm.. Still not good, we need now to patch or change our kernel for support encryption. We have to check if the &#8220;aes&#8221; and &#8220;cryptoloop&#8221; modules are loaded, if not we will load them.</p>
<pre class="brush:bash">root@vm-ubuntu-lamp:~# lsmod | grep aes
root@vm-ubuntu-lamp:~# modprobe aes
root@vm-ubuntu-lamp:~# lsmod | grep aes
aes                    28608  0
root@vm-ubuntu-lamp:~# lsmod | grep cryptoloop
root@vm-ubuntu-lamp:~# modprobe cryptoloop
root@vm-ubuntu-lamp:~# lsmod | grep crypto
cryptoloop              4096  0
loop                   17928  1 cryptoloop</pre>
<p>If you don&#8217;t have the module with your current kernel, you will have to build it by activate the some kernel options.</p>
<pre class="brush:text">CONFIG_BLK_DEV_LOOP=m
CONFIG_BLK_DEV_CRYPTOLOOP=m
CONFIG_CRYPTO_AES=m
CONFIG_CRYPTO_AES_586=m</pre>
<p>Now we should be ok to load our encrypted image.<br />
root@vm-ubuntu-lamp:~# losetup -e aes /dev/loop0 encrypted.img<br />
Password:</p>
<p><strong>Format the device with a proper filesystem</strong></p>
<pre class="brush:bash">root@vm-ubuntu-lamp:~# mkfs.ext3 /dev/loop0
mke2fs 1.40-WIP (14-Nov-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
5016 inodes, 20004 blocks
1000 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=20709376
3 block groups
8192 blocks per group, 8192 fragments per group
1672 inodes per group
Superblock backups stored on blocks:
8193

Writing inode tables: done
Creating journal (1400 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.</pre>
<p><strong>Mount the device</strong></p>
<p>Easiest step, just have to use the mount command.</p>
<pre class="brush:bash">root@vm-ubuntu-lamp:~# mkdir /mnt/encrypted
root@vm-ubuntu-lamp:~# mount /dev/loop0 /mnt/encrypted

root@vm-ubuntu-lamp:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              7850996   1346292   6105892  19% /
varrun                   63052        40     63012   1% /var/run
varlock                  63052         0     63052   0% /var/lock
procbususb               63052        68     62984   1% /proc/bus/usb
udev                     63052        68     62984   1% /dev
devshm                   63052         0     63052   0% /dev/shm
/dev/loop0               19366      1578     16788   9% /mnt/encrypted

root@vm-ubuntu-lamp:~# df -H
Filesystem             Size   Used  Avail Use% Mounted on
/dev/sda1              8,1G   1,4G   6,3G  19% /
varrun                  65M    41k    65M   1% /var/run
varlock                 65M      0    65M   0% /var/lock
procbususb              65M    70k    65M   1% /proc/bus/usb
udev                    65M    70k    65M   1% /dev
devshm                  65M      0    65M   0% /dev/shm
/dev/loop0              20M   1,7M    18M   9% /mnt/encrypted</pre>
<p>If you want to go further on this subject : <a title="Encryption HOWTO" href="http://encryptionhowto.sourceforge.net/Encryption-HOWTO-4.html#losetup">Encryption HOWTO</a></p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F&amp;title=Using+losetup+and+dd+to+secure+sensitive+data+%28encrypted+block+device%29" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F&amp;title=Using+losetup+and+dd+to+secure+sensitive+data+%28encrypted+block+device%29" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F&amp;title=Using+losetup+and+dd+to+secure+sensitive+data+%28encrypted+block+device%29" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F&amp;headline=Using+losetup+and+dd+to+secure+sensitive+data+%28encrypted+block+device%29" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Using+losetup+and+dd+to+secure+sensitive+data+%28encrypted+block+device%29&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Using+losetup+and+dd+to+secure+sensitive+data+%28encrypted+block+device%29&amp;u=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Using+losetup+and+dd+to+secure+sensitive+data+%28encrypted+block+device%29&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Using+losetup+and+dd+to+secure+sensitive+data+%28encrypted+block+device%29&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Using+losetup+and+dd+to+secure+sensitive+data+%28encrypted+block+device%29&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F&amp;title=Using+losetup+and+dd+to+secure+sensitive+data+%28encrypted+block+device%29&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F07%2F13%2Fusing-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.shell-tips.com/2008/07/13/using-losetup-and-dd-to-secure-sensitive-data-encrypted-block-device/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Printing a sequence of letters or numbers</title>
		<link>http://www.shell-tips.com/2008/01/14/printing-a-sequence-of-letters-or-numbers/</link>
		<comments>http://www.shell-tips.com/2008/01/14/printing-a-sequence-of-letters-or-numbers/#comments</comments>
		<pubDate>Mon, 14 Jan 2008 14:50:07 +0000</pubDate>
		<dc:creator>Nicolas Brousse</dc:creator>
				<category><![CDATA[Bash - GNU Shell]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[sequence]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.shell-tips.com/2008/01/14/printing-a-sequence-of-letter-or-number/</guid>
		<description><![CDATA[Some times, while scripting in your favorite shell (I mean Bash !! :) you need to print a sequence of letters or numbers. Don&#8217;t write it yourself ! Script it using seq or curly braces ! Print a sequence of number nicolas@macvin:~$ seq 1 10 1 2 3 4 5 6 7 8 9 10 [...]]]></description>
			<content:encoded><![CDATA[<p>Some times, while scripting in your favorite shell (I mean Bash !! :) you need to print a sequence of letters or numbers. Don&#8217;t write it yourself ! Script it using <strong>seq</strong> or <strong>curly braces</strong> !</p>
<p><strong> Print a sequence of number</strong></p>
<pre class="brush:bash">nicolas@macvin:~$ seq 1 10
1 2 3 4 5 6 7 8 9 10
nicolas@macvin:~$ seq 0 2 10
0 2 4 6 8 10
nicolas@macvin:~$ echo {1..10}
1 2 3 4 5 6 7 8 9 10</pre>
<p><strong>Print a sequence of letters</strong></p>
<pre class="brush:bash">nicolas@macvin:~$ echo {a..g}
a b c d e f g</pre>
<p>Hope this will help you while doing a loop or building some hash directories :</p>
<pre class="brush:bash">nicolas@macvin:~$  mkdir -p test/{1..10}/{1..10}</pre>
<p>Enjoy !</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F&amp;title=Printing+a+sequence+of+letters+or+numbers" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F&amp;title=Printing+a+sequence+of+letters+or+numbers" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F&amp;title=Printing+a+sequence+of+letters+or+numbers" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F&amp;headline=Printing+a+sequence+of+letters+or+numbers" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Printing+a+sequence+of+letters+or+numbers&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Printing+a+sequence+of+letters+or+numbers&amp;u=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Printing+a+sequence+of+letters+or+numbers&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Printing+a+sequence+of+letters+or+numbers&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Printing+a+sequence+of+letters+or+numbers&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F&amp;title=Printing+a+sequence+of+letters+or+numbers&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.shell-tips.com%2F2008%2F01%2F14%2Fprinting-a-sequence-of-letters-or-numbers%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.shell-tips.com/2008/01/14/printing-a-sequence-of-letters-or-numbers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cheap SAN and secure backup solution for small-sized platform</title>
		<link>http://www.shell-tips.com/2007/11/26/cheap-secure-backup-solution-for-small-sized-platform/</link>
		<comments>http://www.shell-tips.com/2007/11/26/cheap-secure-backup-solution-for-small-sized-platform/#comments</comments>
		<pubDate>Mon, 26 Nov 2007 03:05:18 +0000</pubDate>
		<dc:creator>Nicolas Brousse</dc:creator>
				<category><![CDATA[Bash - GNU Shell]]></category>
		<category><![CDATA[Case Study]]></category>
		<category><![CDATA[mdadm]]></category>
		<category><![CDATA[nbd]]></category>
		<category><![CDATA[network device]]></category>
		<category><![CDATA[raid software]]></category>
		<category><![CDATA[raid5]]></category>
		<category><![CDATA[raid6]]></category>
		<category><![CDATA[san]]></category>

		<guid isPermaLink="false">http://www.shell-tips.com/2007/11/26/cheap-secure-backup-solution-for-small-sized-platform/</guid>
		<description><![CDATA[Here is a quick post about a cheap SAN and secure backup architecture solution for small-sized platform (5/10 servers). In this study case we will see how to use Network Block Devices (nbd) and soft-raid with mdadm. I design it for my personal web platform which is a small one. Last day, I was missing [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick post about a cheap <a title="Wikipedia - SAN" href="http://en.wikipedia.org/wiki/Storage_area_network">SAN</a> and secure backup architecture solution for small-sized platform (5/10 servers). In this study case we will see how to use Network Block Devices (<a title="Network Block Devices" href="http://nbd.sf.net">nbd</a>) and soft-raid with <a title="Linux tools - MDADM" href="http://neil.brown.name/blog/mdadm">mdadm</a>. I design it for my personal web platform which is a small one. Last day, I was missing of free space on my backup server and I was angry by the idea to rent a most expensive server to store my backup while I had lot of unused space on my other servers.</p>
<blockquote><p><a href="http://www.shell-tips.com/2007/11/26/cheap-secure-backup-solution-for-small-sized-platform/#one">1. Initial platform</a><br />
<a href="http://www.shell-tips.com/2007/11/26/cheap-secure-backup-solution-for-small-sized-platform/#two">2. New platform</a><br />
<a href="http://www.shell-tips.com/2007/11/26/cheap-secure-backup-solution-for-small-sized-platform/#three">3. How to do it ?</a></p></blockquote>
<p><span id="more-38"></span></p>
<p><strong><a title="one" name="one"></a>1. Initial platform</strong></p>
<p>The initial platform is made of five production servers (Apache, PHP, MySQL, Postfix), one &#8220;monitoring server&#8221; running with cacti, nagios, POP3, IMAP, Subversion, Trac, Primary DNS, etc. and one &#8220;backup server&#8221; used as Secondary DNS, MySQL Slave and finally <a title="Rsync tools - rsnapshot" href="http://www.rsnapshot.org">rsnapshot</a> server. Of course I manage all this remotely with my old laptop. In this schema the Backup server can deal only 100 Go of backup.</p>
<p><img title="Current Platform" src="/dl/current_pf.png" alt="Current Platform" /></p>
<blockquote><p><em><strong>Cons</strong></em></p>
<ul>
<li>Backup server is a single point of failure (SPOF). If i lost my HD, I lost all my backup data</li>
<li>Don&#8217;t use all my disk space on all my server</li>
<li>When I need more space on my backup server, I have to rent and move to a new and more expensive server</li>
<li>Backup server represent 15% of all my monthly cost (Really hudge for so small platform !)</li>
</ul>
</blockquote>
<p><strong><a title="two" name="two"></a>2. New platform</strong></p>
<p>I look at a quantity of open project for using <a title="Wikipedia - Distributed Filesystem (DFS)" href="http://en.wikipedia.org/wiki/Distributed_file_system">distributed filesystem</a> (Coda, AFS, LegionFS, MogileFS, DRDB, etc.), but I finally conclude that my needs wasn&#8217;t in the ability to distribute data to many clients with hudge load. I need a way to :</p>
<ol>
<li>grow my available backup disk space easily</li>
<li>store my backup data in a redundant maner and most secure way (removing SPOF)</li>
<li>less expensive structure</li>
</ol>
<p>I have lot of space unused on all my production servers. So, I choose to use Network Block Devices (NBD) with Raid 6 implementation. In this schema I currently have 4&#215;100 Go (Raid device) that give me 200 Go of available space for my backups.</p>
<p><em><strong>Why Raid 6 instead of Raid 5 ?</strong></em></p>
<p><em>As I write earlier, my goal isn&#8217;t read/write performance, but security aspect. Due to the risk of lost a network member, I choose to use Raid 6 Implementation that let me the possibility to lost two node at the same time.</em></p>
<p><img title="Cheap secure backup platform (nbd + raid)" src="/dl/new_pf.png" alt="Cheap secure backup platform (nbd + raid)" width="480" height="384" /></p>
<blockquote><p><em><strong>Pros</strong></em></p>
<ul>
<li>Distributed backup data between all the array members</li>
<li>No more SPOF if I crash the backup server (This structure let me the possibility to mount the array on another server or my laptop)</li>
<li>Use all available space on my servers</li>
<li>Less expensive platform and easy to upgrade</li>
</ul>
<p><em><strong>Cons </strong></em></p>
<ul>
<li>If you crash more than two node of your RAID Array you will lost all your data, this mean that you must take care when you choose to reboot a server : RAID reconstruction is not fast !</li>
<li>When writing to the RAID device that will does many network i/o and probably use some CPU on your nbd-server</li>
</ul>
</blockquote>
<p><strong><a title="three" name="three"></a>3. How to do it ?</strong></p>
<p>first of all, I install <strong>nbd-server</strong> on each server with unused disk space. I choose three server from my five production servers. I&#8217;m using Ubuntu Server distrib, so I just have to do an &#8220;<em>apt-get install nbd-server</em>&#8220;. Now I have to build an image disk on each server that will be used for the network block device. I use <strong>dd</strong> for build a 100 Go file image then I start nbd-server on each server (node).</p>
<blockquote><p>dd if=/dev/zero of=/home/nbd/backup.img bs=1024 count=100000000</p>
<p>nbd-server 10130 /home/nbd/backup.img</p></blockquote>
<p>I encourage you to look at the man page of nbd-server for know more about all the available option.</p>
<p>Next, we have to setup the main server for building the RAID Array. I choose RAID 6. We previously setup 3 servers for doing 3 Network Block Devices. I need one more server for implementing my RAID 6 Array. I choose to setup a file image on the local server where I build the RAID Array, I just need to use loop device with <strong>losetup</strong>. Then we &#8220;mount&#8221; the network block devices locally with <strong>nbd-client</strong> (look at the man page too).</p>
<blockquote><p>dd if=/dev/zero of=/home/nbd/backup.img bs=1024 count=100000000</p>
<p>losetup /dev/loop0 /home/nbd/backup.img</p>
<p>modprobe nbd</p>
<p>nbd-client serv1.example.com 10130 /dev/nbd0 -persist</p>
<p>nbd-client serv2.example.com 10130 /dev/nbd1 -persist</p>
<p>nbd-client serv3.example.com 10130 /dev/nbd2 -persist</p></blockquote>
<p>We have all our device up on our main server, we just need to use mdadm to build our array and mount our file system to use it like any other partition.</p>
<blockquote><p>mdadm &#8211;create /dev/md0 &#8211;raid-devices=4 &#8211;level=6 &#8211;spare-devices=0 &#8211;chunk=256 /dev/nbd[012] /dev/loop0</p>
<p>mkfs.ext3 /dev/md0 -b 4096 -E stride=64</p>
<p>mount /dev/md0 /.snapshots</p></blockquote>
<p>That&#8217;s all folks ! I can now run <strong>rsnapshot</strong> using my distributed RAID 6 implementation and stopping to lost my unused spaces. NB : I use a chunk size of 256k because of the RAID 6 implementation and the network constraint, performance looks better. Due to this chunk size, I use a block size of 4k and stride of 64 while building the file system (4k x 64 = 256k).<em><strong></strong></em></p>
<p><em><strong>I need more space, how can I do ?</strong></em></p>
<p>It&#8217;s easy ! You just need to install a new nbd-server on a server having enough space then load a new nbd-client on your server running the RAID Array. When it&#8217;s done, just use mdadm to grow your array.</p>
<blockquote><p>mdadm &#8211;grow /dev/md0 &#8211;raid-disks=5<em><strong></strong></em></p>
<p>mdadm &#8211;add /dev/md0 /dev/nbd4</p></blockquote>
<p><em><strong>The server running the RAID Device crashed. How can I get my backup ??</strong></em></p>
<p>It&#8217;s easy ! You just need to build a new device on another server or on your laptop.</p>
<blockquote><p>mdadm &#8211;create /dev/md0 &#8211;assume-clean &#8211;raid-devices=4 &#8211;chunk=256 &#8211;level=6 /dev/nbd[012] missing</p></blockquote>
<p>&#8220;missing&#8221; mean that our last device of our array (/dev/loop0) is missing, the RAID Array will start in degraded mode.</p>
<p><strong><em>I have a big external HD at home for doing a second site backup. What I have to do for copying and read it ?</em></strong></p>
<p>You will just need to copy all the file image (&#8220;backup.img&#8221;) to your external disk . Take care to stop your RAID Array before (except if you are sure to don&#8217;t have any write on your images while doing your copy). Then You will just have to load each images with <strong>losetup</strong> locally and building a RAID Array with <strong>mdadm</strong>.</p>
<p><strong>To sum up</strong></p>
<p>I think that this platform design is really useful for small sized (5/10 servers) platform because you get a distributed data backup solution at low cost. You don&#8217;t need to have dedicated server to manage your backup. However, you have to take care of the touchy aspect of any raid implementation, a wrong manipulation with mdadm or too many server crash could lead you to the lost of all your data. You have to keep in mind that RAID 6 need lot of time to rebuild large storage. If you plan to reboot lot of your servers, don&#8217;t forget to stop your RAID Array.</p>
<p>If you are interested in this kind of platform for build your SAN, I encourage you to look at the <a title="Wikipedia - iSCSI" href="http://en.wikipedia.org/wiki/iSCSI">iSCSI</a> or <a title="Wikipedia - ATA over Ethernet" href="http://en.wikipedia.org/wiki/ATA_over_Ethernet">AoE</a> Protocols.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F&amp;title=Cheap+SAN+and+secure+backup+solution+for+small-sized+platform" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F&amp;title=Cheap+SAN+and+secure+backup+solution+for+small-sized+platform" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F&amp;title=Cheap+SAN+and+secure+backup+solution+for+small-sized+platform" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F&amp;headline=Cheap+SAN+and+secure+backup+solution+for+small-sized+platform" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Cheap+SAN+and+secure+backup+solution+for+small-sized+platform&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Cheap+SAN+and+secure+backup+solution+for+small-sized+platform&amp;u=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Cheap+SAN+and+secure+backup+solution+for+small-sized+platform&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Cheap+SAN+and+secure+backup+solution+for+small-sized+platform&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Cheap+SAN+and+secure+backup+solution+for+small-sized+platform&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F&amp;title=Cheap+SAN+and+secure+backup+solution+for+small-sized+platform&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F11%2F26%2Fcheap-secure-backup-solution-for-small-sized-platform%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.shell-tips.com/2007/11/26/cheap-secure-backup-solution-for-small-sized-platform/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with Bash Aliases (Alias/Unalias)</title>
		<link>http://www.shell-tips.com/2007/08/25/working-with-bash-aliases-aliasunalias/</link>
		<comments>http://www.shell-tips.com/2007/08/25/working-with-bash-aliases-aliasunalias/#comments</comments>
		<pubDate>Sat, 25 Aug 2007 00:28:46 +0000</pubDate>
		<dc:creator>Nicolas Brousse</dc:creator>
				<category><![CDATA[Bash - GNU Shell]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[shopt]]></category>
		<category><![CDATA[shortcut]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[unalias]]></category>

		<guid isPermaLink="false">http://www.shell-tips.com/2007/08/25/working-with-bash-aliases-aliasunalias/</guid>
		<description><![CDATA[Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. The shell maintains a list of aliases that may be set and unset with the alias and unalias builtin commands. You can set your aliases into your .bashrc file. Following some common aliases: [...]]]></description>
			<content:encoded><![CDATA[<p>Aliases  allow  a  string to be substituted for a word when it is used as the first word of a simple command.  The shell maintains a list of aliases that may be set and unset with the <strong>alias</strong> and <strong>unalias</strong> builtin  commands.</p>
<p><span id="more-34"></span></p>
<p>You can set your aliases into your <em>.bashrc</em> file. Following some common aliases:</p>
<blockquote><p>alias ls=&#8217;ls &#8211;color=auto&#8217;<br />
alias dir=&#8217;ls &#8211;color=auto &#8211;format=vertical&#8217;<br />
alias vdir=&#8217;ls &#8211;color=auto &#8211;format=long&#8217;<br />
alias ll=&#8217;ls -l&#8217;<br />
alias la=&#8217;ls -A&#8217;<br />
alias l=&#8217;ls -CF&#8217;</p></blockquote>
<p>All this is nice but how can you unset all this stuff ? Simple ! Use <strong>unalias</strong> builtin command.</p>
<blockquote><p># unset &#8220;ll&#8221; alias<br />
unalias ll</p>
<p># unset all aliases<br />
unalias -a</p></blockquote>
<p>Aliases are not expanded when shell isn&#8217;t interactive,  unless the <strong>expand_aliases</strong> shell option is set using <strong>shopt</strong>.</p>
<blockquote><p>shopt -s expand_aliases</p></blockquote>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F&amp;title=Working+with+Bash+Aliases+%28Alias%2FUnalias%29" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F&amp;title=Working+with+Bash+Aliases+%28Alias%2FUnalias%29" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F&amp;title=Working+with+Bash+Aliases+%28Alias%2FUnalias%29" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F&amp;headline=Working+with+Bash+Aliases+%28Alias%2FUnalias%29" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Working+with+Bash+Aliases+%28Alias%2FUnalias%29&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Working+with+Bash+Aliases+%28Alias%2FUnalias%29&amp;u=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Working+with+Bash+Aliases+%28Alias%2FUnalias%29&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Working+with+Bash+Aliases+%28Alias%2FUnalias%29&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Working+with+Bash+Aliases+%28Alias%2FUnalias%29&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F&amp;title=Working+with+Bash+Aliases+%28Alias%2FUnalias%29&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.shell-tips.com%2F2007%2F08%2F25%2Fworking-with-bash-aliases-aliasunalias%2F" ><img class="lightsocial_img" src="http://www.shell-tips.com/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.shell-tips.com/2007/08/25/working-with-bash-aliases-aliasunalias/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
