<?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>rajaseelan.com</title>
	<atom:link href="http://rajaseelan.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://rajaseelan.com</link>
	<description>junk food for the brain ...</description>
	<lastBuildDate>Tue, 28 Jul 2009 16:37:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Generate Files with Random Content and Size in Bash</title>
		<link>http://rajaseelan.com/2009/07/29/generate-files-with-random-content-and-size-in-bash/</link>
		<comments>http://rajaseelan.com/2009/07/29/generate-files-with-random-content-and-size-in-bash/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 16:37:17 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[dd]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[generate]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=244</guid>
		<description><![CDATA[Occasionally you need to generate a bunch of random files with random content, usually for testing compression, user quotas or miscellaneous stuff.
Here&#8217;s one way, using the bash shell and a few handy linux utilities.

The bash $RANDOM function. It generates a random number between 0 &#8211; 32767.
Linux DD utility, to output files.
/dev/(h&#124;s)da, your hard drive in [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally you need to generate a bunch of random files with random content, usually for testing compression, user quotas or miscellaneous stuff.</p>
<p>Here&#8217;s one way, using the bash shell and a few handy linux utilities.</p>
<ol>
<li>The bash <code>$RANDOM</code> function. It generates a random number between 0 &#8211; 32767.</li>
<li>Linux <code>DD</code> utility, to output files.</li>
<li><code>/dev/(h|s)da</code>, your hard drive in linux.</li>
<li>All wrapped in a bash <code>while</code> loop.</li>
</ol>
<p>So lets start. First define a bash variable with the number of files we wish to create, lets say 10.</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #007800;">no_of_files</span>=<span style="color: #000000;">10</span></pre>
</div>
</div>
<p>Then we&#8217;ll assign the a bash variable for the counter.</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #007800;">counter</span>=<span style="color: #000000;">1</span></pre>
</div>
</div>
<p>As for the <code>dd</code> command, this creates a file with random content from your hard disk. (Mine&#8217;s <code>/dev/sda</code>)  which is 1KB in size. The <code>count</code> switch tells dd to repeat  1024 bytes 1 time, thus the 1Kb file size. <code>skip</code> makes <code>dd</code> skip an <em>x</em> amount of bytes before reading further. Since this requires raw access to your hard drive, you&#8217;ll have to run this as root unfortunately. <img src='http://rajaseelan.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">dd bs=1024 count=1 skip=0 if=/dev/sda of=random-file</pre>
</div>
</div>
<p>So now imagine, if we let bash assign the count and skip random numbers, we get random file contents. (Light bulbs flashing eh?)</p>
<p>Of course, all of it will be written to a single file called random-file in my case. To add just slight amount of variety, we can add the counter variable that we will use in our <code>while</code> loop as an extension. The <code>dd</code> command will now be:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">bs</span>=<span style="color: #000000;">1024</span> <span style="color: #007800;">count</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$RANDOM</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">skip</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$RANDOM</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">if</span></span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda <span style="color: #007800;">of</span>=random-file.<span style="color: #007800;">$counter</span></pre>
</div>
</div>
<p>Finally, we will wrap it up in a bash while loop like this:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #007800;">no_of_files</span>=<span style="color: #000000;">10</span>;
<span style="color: #007800;">counter</span>=<span style="color: #000000;">1</span>;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$counter</span> <span style="color: #660033;">-le</span> <span style="color: #007800;">$no_of_files</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
 <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> Creating <span style="color: #c20cb9; font-weight: bold;">file</span> no <span style="color: #007800;">$counter</span>;
  <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">bs</span>=<span style="color: #000000;">1024</span> <span style="color: #007800;">count</span>=<span style="color: #007800;">$RANDOM</span> <span style="color: #007800;">skip</span>=<span style="color: #007800;">$RANDOM</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">if</span></span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda <span style="color: #007800;">of</span>=random-file.<span style="color: #007800;">$counter</span>;
  <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;counter += 1&quot;</span>;
 <span style="color: #000000; font-weight: bold;">done</span></pre>
</div>
</div>
<p>When you run it, you will get output like this:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">Creating file no 1
16614+0 records in
16614+0 records out
17012736 bytes (17 MB) copied, 0.29308 s, 58.0 MB/s
Creating file no 2
14456+0 records in
14456+0 records out
14802944 bytes (15 MB) copied, 0.100101 s, 148 MB/s
.................
Creating file no 10
25224+0 records in
25224+0 records out
25829376 bytes (26 MB) copied, 0.492113 s, 52.5 MB/s</pre>
</div>
</div>
<p>when you do a directory listing, you&#8217;ll see this:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[root@atreides rd-test]# ls -lh
total 226M
-rw-r--r-- 1 root root 17M 2009-07-29 00:25 random-file.1
-rw-r--r-- 1 root root 25M 2009-07-29 00:25 random-file.10
-rw-r--r-- 1 root root 15M 2009-07-29 00:25 random-file.2
-rw-r--r-- 1 root root 20M 2009-07-29 00:25 random-file.3
-rw-r--r-- 1 root root 21M 2009-07-29 00:25 random-file.4
-rw-r--r-- 1 root root 30M 2009-07-29 00:25 random-file.5
-rw-r--r-- 1 root root 22M 2009-07-29 00:25 random-file.6
-rw-r--r-- 1 root root 27M 2009-07-29 00:25 random-file.7
-rw-r--r-- 1 root root 25M 2009-07-29 00:25 random-file.8
-rw-r--r-- 1 root root 29M 2009-07-29 00:25 random-file.9</pre>
</div>
</div>
<p>For more info, refer to the $RANDOM function from the <a target="blank" href="http://tldp.org/LDP/abs/html/randomvar.html">Advanced Bash Scripting Guide.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/29/generate-files-with-random-content-and-size-in-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Enable Flash in Google Chrome for Fedora 11 i686</title>
		<link>http://rajaseelan.com/2009/07/27/how-to-enable-flash-in-google-chrome-for-fedora-11-i686/</link>
		<comments>http://rajaseelan.com/2009/07/27/how-to-enable-flash-in-google-chrome-for-fedora-11-i686/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 15:45:41 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[fedora 11]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flash-plugin]]></category>
		<category><![CDATA[install]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=240</guid>
		<description><![CDATA[So you&#8217;ve installed the latest development builds of Chromium for Fedora Linux. The only thing lacking is that youtube is not loading. If not, what are you waiting for? Refer to one of my previous posts.
First make sure you install the Adobe yum repository.
As root:-


rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm


Then install the flash plugin.


yum install flash-plugin.i386


The flash plugin [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;ve installed the latest development builds of Chromium for Fedora Linux. The only thing lacking is that youtube is not loading. If not, what are you waiting for? Refer to one of my <a href="http://rajaseelan.com/2009/07/04/how-to-install-google-chrome-in-fedora-10-or-fedora-11/">previous posts</a>.</p>
<p>First make sure you install the Adobe yum repository.</p>
<p>As root:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm</pre>
</div>
</div>
<p>Then install the flash plugin.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">yum install flash-plugin.i386</pre>
</div>
</div>
<p>The flash plugin will be installed in <code>/usr/lib/flash-plugin/libflashplayer.so</code></p>
<p>Chrome plugins are supposed to be located in <code>/usr/lib/chromium-browser/plugins</code>. So lets create a symbolic link, so that whenever your Adobe flash plugin is updated, your Chrome automatically gets the latest version.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">n -sv /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/chromium-browser/plugins/libflashplayer.so</pre>
</div>
</div>
<p>Now start your Chrome browser from the command line, with the <code>--enable-plugins</code> switch. This will enable the flash plugin. </p>
<p>Here&#8217;s a screenshot of me watching a video from youtube on chrome:-</p>
<div id="attachment_241" class="wp-caption aligncenter" style="width: 310px"><a href="http://rajaseelan.com/wp-content/uploads/2009/07/chromium-flash-in-action.png"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/chromium-flash-in-action-300x211.png" alt="Flash Player in Google Chrome for Linux" title="Flash Player in Google Chrome for Linux" width="300" height="211" class="size-medium wp-image-241" /></a>
<p class="wp-caption-text">Flash Player in Google Chrome for Linux</p>
</div>
<p>Say goodbye to geek productivity once this is done <img src='http://rajaseelan.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/27/how-to-enable-flash-in-google-chrome-for-fedora-11-i686/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Temporarily Disable a Yum Repository</title>
		<link>http://rajaseelan.com/2009/07/24/temporarily-disable-a-yum-repository/</link>
		<comments>http://rajaseelan.com/2009/07/24/temporarily-disable-a-yum-repository/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:52:10 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[repo]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[temporary]]></category>
		<category><![CDATA[yum.]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=237</guid>
		<description><![CDATA[Sometimes, you may run into problems updating Fedora via yum.  What you could do is temporarily disable the offending repository, and update everything else while the errors are being fixed upstream.

List out your enabled yum repositories.


$ yum repolist


You would get something like this:


[raja@atreides ~]$ yum repolist
Loaded plugins: fastestmirror, presto, refresh-packagekit
repo id    [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, you may run into problems updating Fedora via yum.  What you could do is temporarily disable the offending repository, and update everything else while the errors are being fixed upstream.</p>
<ol>
<li>List out your enabled yum repositories.
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">$ yum repolist</pre>
</div>
</div>
<p>You would get something like this:</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides ~]$ yum repolist
Loaded plugins: fastestmirror, presto, refresh-packagekit
repo id                   repo name                              status
adobe-linux-i386          Adobe Systems Incorporated             enabled:     17
chromium                  Chromium Test Packages                 enabled:      7
fedora                    Fedora 11 - i386                       enabled: 13,289
rpmfusion-free            RPM Fusion for Fedora 11 - Free        enabled:    377
rpmfusion-free-updates    RPM Fusion for Fedora 11 - Free - Upda enabled:    210
rpmfusion-nonfree         RPM Fusion for Fedora 11 - Nonfree     enabled:    110
rpmfusion-nonfree-updates RPM Fusion for Fedora 11 - Nonfree - U enabled:    115
updates                   Fedora 11 - i386 - Updates             enabled:  3,451
repolist: 17,576</pre>
</div>
</div>
</li>
<li>The names on the left are the repo ids. To disable a particular one, for example <code>rpmfusion-nonfree-updates</code> while doing updates, run your yum like this:-
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;"># yum upgrade --disablerepo=rpmfusion-free-updates</pre>
</div>
</div>
</li>
<li>This will help you upgrade the rest of the packages in the mean time.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/24/temporarily-disable-a-yum-repository/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Configure a Caching-Only Name Server in a Chroot Environment for Fedora 11</title>
		<link>http://rajaseelan.com/2009/07/18/configure-a-caching-only-name-server-in-a-chroot-environment-for-fedora-11/</link>
		<comments>http://rajaseelan.com/2009/07/18/configure-a-caching-only-name-server-in-a-chroot-environment-for-fedora-11/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 12:39:35 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[caching-nameserver]]></category>
		<category><![CDATA[caching-only]]></category>
		<category><![CDATA[chroot]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[fedora 11]]></category>
		<category><![CDATA[named]]></category>
		<category><![CDATA[nameserver]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=231</guid>
		<description><![CDATA[Having a caching only name-server on your local Machine speeds up your browsing. Here&#8217;s how to set up a slightly more secure caching server using ISC Bind in Fedora 11.

Install bind and bind-chroot packages


# yum install bind bind-chroot



Edit your /etc/sysconfig/named file.


# vim /etc/sysconfig/named


Add the following line:


ROOTDIR=&#34;/var/named/chroot&#34;



Edit your /etc/named.conf file.


# vim /etc/named.conf



Change the following line:


listen-on port [...]]]></description>
			<content:encoded><![CDATA[<p>Having a caching only name-server on your local Machine speeds up your browsing. Here&#8217;s how to set up a slightly more secure caching server using ISC Bind in Fedora 11.</p>
<ol>
<li>Install <code>bind</code> and <code>bind-chroot</code> packages
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;"># yum install bind bind-chroot</pre>
</div>
</div>
</li>
<li>Edit your <code>/etc/sysconfig/named file.
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;"># vim /etc/sysconfig/named</pre>
</div>
</div>
<p>Add the following line:</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">ROOTDIR=&quot;/var/named/chroot&quot;</pre>
</div>
</div>
<p></code></li>
<li>Edit your <code>/etc/named.conf</code> file.
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;"># vim /etc/named.conf</pre>
</div>
</div>
</li>
<li>Change the following line:
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">listen-on port 53 { 127.0.0.1; };</pre>
</div>
</div>
<p>to</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">listen-on port 53 { any; };</pre>
</div>
</div>
<p>This allows the bind daemon to listen on all your network IPs, not just your loopback(127.0.0.1) address.</li>
<li>Change this line:
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">allow-query     { localhost; };</pre>
</div>
</div>
<p>to</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">allow-query     { 192.168.0.0/24; };</pre>
</div>
</div>
<p>You now allow all the machines in your home LAN to use your DNS server.
</li>
<li>Make sure it starts at boot time.
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;"># chkconfig named on</pre>
</div>
</div>
<p>Restart your DNS server.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;"># service named restart</pre>
</div>
</div>
</li>
<li>Make sure its listening on the correct ports.
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;"># netstat -ntupl | grep named</pre>
</div>
</div>
<p>In my case, the DNS server IP is 192.168.0.10. So, as seen here, the line <code>udp        0      0 192.168.0.10:53       0.0.0.0:*      2851/named</code> shows it is listening correctly.</li>
<li>Then test your server from another machine in your network. Most probably another linux box or laptop.
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;"># dig @192.168.0.10 google.com</pre>
</div>
</div>
<p>The dig command, with the &#8216;@&#8217; instructs it to get the IP address for google.com from your newly set up server. On my machine, it looked like this:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[root@atreides ~]# dig @192.168.0.10 google.com
&nbsp;
; &lt; &lt;&gt;&gt; DiG 9.6.1-RedHat-9.6.1-2.fc11 &lt; &lt;&gt;&gt; @192.168.0.10 google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt; &lt;- opcode: QUERY, status: NOERROR, id: 6515
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 4, ADDITIONAL: 0
&nbsp;
;; QUESTION SECTION:
;google.com.			IN	A
&nbsp;
;; ANSWER SECTION:
google.com.		300	IN	A	74.125.127.100
google.com.		300	IN	A	74.125.45.100
google.com.		300	IN	A	74.125.67.100
&nbsp;
;; AUTHORITY SECTION:
google.com.		171853	IN	NS	ns3.google.com.
google.com.		171853	IN	NS	ns1.google.com.
google.com.		171853	IN	NS	ns2.google.com.
google.com.		171853	IN	NS	ns4.google.com.
&nbsp;
;; Query time: 82 msec
;; SERVER: 192.168.0.10#53(192.168.0.10)
;; WHEN: Sat Jul 18 20:14:59 2009
;; MSG SIZE  rcvd: 148</pre>
</div>
</div>
<p>Note the <code>SERVER:</code> line. that shows you the answer for the query came from my DNS server (192.168.0.10).
</pre>
</li>
<li>Finally, set up your <code>/etc/resolv.conf</code> accordingly.
<p>On the server:</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">nameserver 127.0.0.1</pre>
</div>
</div>
<p>And on all your other machines:</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">nameserver 192.168.0.10</pre>
</div>
</div>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/18/configure-a-caching-only-name-server-in-a-chroot-environment-for-fedora-11/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Change Your MAC Address in Linux</title>
		<link>http://rajaseelan.com/2009/07/16/change-your-mac-address-in-linux/</link>
		<comments>http://rajaseelan.com/2009/07/16/change-your-mac-address-in-linux/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 08:38:58 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[ethernet]]></category>
		<category><![CDATA[how]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[hwaddr]]></category>
		<category><![CDATA[ifconfig]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=227</guid>
		<description><![CDATA[Some times it necessary to change your network MAC address on your linux box.
Unlike Windows, which requires some registry editing or even specialized tools, its just a command line away in Linux.
For example, lets change the MAC address of your first netwrok card, usually called eth0.
Let&#8217;s swith to being the root user and view the [...]]]></description>
			<content:encoded><![CDATA[<p>Some times it necessary to change your network MAC address on your linux box.</p>
<p>Unlike Windows, which requires some registry editing or even specialized tools, its just a command line away in Linux.</p>
<p>For example, lets change the MAC address of your first netwrok card, usually called <code>eth0</code>.</p>
<p>Let&#8217;s swith to being the root user and view the current MAC address:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">ifconfig eth0</pre>
</div>
</div>
<p>You should get something similiar:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[root@rhel-5new ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 08:00:27:2C:D2:B5
          inet addr:192.168.0.108  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe2c:d2b5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:20545 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18348 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:10083277 (9.6 MiB)  TX bytes:7489363 (7.1 MiB)
          Interrupt:11 Base address:0xd020</pre>
</div>
</div>
<p>The MAC address is listed next to the <code>HWAddr</code> column, which is <code>08:00:27:2C:D2:B5</code> in this case.</p>
<p>We&#8217;ll change it. First shutdown the network interface.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">ifconfig eth0 down</pre>
</div>
</div>
<p>Now change it to say, <code>08:00:27:2C:D2:B4</code>.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">ifconfig eth0 hw ether 00:00:27:2c:d2:b4</pre>
</div>
</div>
<p>Bring the interface back up.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">ifconfig eth0 up</pre>
</div>
</div>
<p>Finally, lets have a look at the new mac address.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[root@rhel-5new ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:00:27:2C:D2:B4
          inet addr:192.168.0.108  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::200:27ff:fe2c:d2b4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:20957 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18642 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:10146055 (9.6 MiB)  TX bytes:7520724 (7.1 MiB)
          Interrupt:11 Base address:0xd020</pre>
</div>
</div>
<p>You can see that the HWaddr field now reports <code>00:00:27:2C:D2:B4</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/16/change-your-mac-address-in-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Find a Cheap VPS Hosting Provider</title>
		<link>http://rajaseelan.com/2009/07/16/find-a-cheap-vps-provider/</link>
		<comments>http://rajaseelan.com/2009/07/16/find-a-cheap-vps-provider/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 02:34:26 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[cheap]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=220</guid>
		<description><![CDATA[With VPS hosting becoming a more popular option among the techies, I&#8217;ve been tempted to get one.
 Among the reasons you&#8217;ve like to get a VPS include:-

You need root access
You wish to install a distro of your choice
Want more capabilities than offered by standard shared hosting
You have Ruby On Rails or Python Based Web Apps [...]]]></description>
			<content:encoded><![CDATA[<p>With VPS hosting becoming a more popular option among the techies, I&#8217;ve been tempted to get one.<br />
 Among the reasons you&#8217;ve like to get a VPS include:-</p>
<ul>
<li>You need root access</li>
<li>You wish to install a distro of your choice</li>
<li>Want more capabilities than offered by standard shared hosting</li>
<li>You have Ruby On Rails or Python Based Web Apps you want to host</li>
<li>Because you can <img src='http://rajaseelan.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </li>
</ul>
<p>This diagram, taken from Google Trends shows VPS Hosting search to be picking up since late 2004. I think is times pefectly with the release of Ruby On Rails to the masses.</p>
<div id="attachment_221" class="wp-caption aligncenter" style="width: 310px"><a target="blank" href="http://rajaseelan.com/wp-content/uploads/2009/07/vps-trends.png"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/vps-trends-300x134.png" alt="VPS Hosting Search Trends Based on Google Trends" title="VPS Hosting Search Trends Based on Google Trends" width="300" height="134" class="size-medium wp-image-221" /></a>
<p class="wp-caption-text">VPS Hosting Search Trends Based on Google Trends</p>
</div>
<p>Anyway, I found this site with cheap VPS hosting, some going for as low as US$3 a month. The reliability of these providers maybe questionable, and I don&#8217;t think they can compare to the big guns. </p>
<p>Here&#8217;s the <a href="http://www.lowendbox.com/">link</a>, do comment on your experiences.</p>
<p>*sigh* Now to prepare for trackbacks from bots tracking the word *VPS* <img src='http://rajaseelan.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/16/find-a-cheap-vps-provider/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Check Your Spelling in Linux using the Command Line</title>
		<link>http://rajaseelan.com/2009/07/15/check-your-spelling-in-linux-using-the-command-line/</link>
		<comments>http://rajaseelan.com/2009/07/15/check-your-spelling-in-linux-using-the-command-line/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 07:51:18 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[aspell]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[ispell]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[spell check]]></category>
		<category><![CDATA[spellcheck]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=216</guid>
		<description><![CDATA[You can do a spell check on from the command line in Linux. 
First, make sure you have aspell installed. In Fedora, just yum install it.


$ yum install aspell


You&#8217;ll also need a dictionary, from which aspell can search for words.
A yum search aspell will give you a list.


[raja@atreides visilon]$ yum search aspell
-----------------------------------------------------------
aspell-af.i586 : Afrikaans dictionaries [...]]]></description>
			<content:encoded><![CDATA[<p>You can do a spell check on from the command line in Linux. </p>
<p>First, make sure you have <a href="http://aspell.net/">aspell</a> installed. In Fedora, just <code>yum install</code> it.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">$ yum install aspell</pre>
</div>
</div>
<p>You&#8217;ll also need a dictionary, from which aspell can search for words.<br />
A <code>yum search aspell</code> will give you a list.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides visilon]$ yum search aspell
-----------------------------------------------------------
aspell-af.i586 : Afrikaans dictionaries for Aspell
aspell-bg.i586 : Bulgarian dictionaries for Aspell
aspell-br.i586 : Breton dictionaries for Aspell
aspell-ca.i586 : Catalan dictionaries for Aspell
aspell-cs.i586 : Czech dictionaries for Aspell
aspell-cy.i586 : Welsh dictionaries for Aspell
aspell-da.i586 : Danish dictionaries for Aspell
aspell-de.i586 : German dictionaries for Aspell
aspell-el.i586 : Greek dictionaries for Aspell
aspell-en.i586 : English dictionaries for Aspell
aspell-es.i586 : Spanish dictionaries for Aspell
aspell-fr.i586 : French dictionaries for Aspell
aspell-ga.i586 : Irish dictionaries for Aspell
aspell-gl.i586 : Galician dictionaries for Aspell
aspell-hr.i586 : Croatian dictionaries for Aspell
aspell-id.i586 : Indonesian dictionaries for Aspell
aspell-is.i586 : Icelandic dictionaries for Aspell
aspell-it.i586 : Italian dictionaries for Aspell
aspell-no.i586 : Norwegian dictionaries for Aspell
aspell-pl.i586 : Polish dictionaries for Aspell
aspell-pt.i586 : Portuguese dictionaries for Aspell
aspell-ru.i586 : Russian dictionaries for Aspell
aspell-sl.i586 : Slovenian dictionaries for Aspell
aspell-sr.i586 : Serbian dictionaries for Aspell
aspell-sv.i586 : Swedish dictionaries for Aspell
aspell-fo.i586 : Faeroese dictionaries for Aspell
aspell-gd.i586 : Gaelic dictionaries for Aspell
aspell-nl.i586 : Dutch dictionaries for Aspell
aspell-ar.i586 : Arabic dictionary for Aspell
aspell-bn.i586 : GNU Aspell Bengali Dictionary Package
aspell-gu.i586 : GNU Aspell Gujarati Dictionary Package
aspell-he.i586 : Hebrew dictionary for Aspell
aspell-hi.i586 : GNU Aspell Hindi Dictionary Package
aspell-ml.i586 : GNU Aspell Malayalam Dictionary Package
aspell-mr.i586 : GNU Aspell Marathi Dictionary Package
aspell-or.i586 : GNU Aspell Oriya Dictionary Package
aspell-pa.i586 : GNU Aspell Punjabi Dictionary Package
aspell-sk.i586 : Slovak dictionaries for Aspell
aspell-ta.i586 : GNU Aspell Tamil Dictionary Package
aspell-te.i586 : GNU Aspell Telugu Dictionary Package</pre>
</div>
</div>
<p>That&#8217;s a lot of languages. I&#8217;ll just install the English dictionaries.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">yum install aspell-en.i586</pre>
</div>
</div>
<p>Now the fun part. Checking your spelling via command line.<br />
Just type <code>aspell -a</code> and it will give you a prompt. I&#8217;ll intentionally type a misspelled word and see what it returns:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides visilon]$ aspell -a
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.6)
psychatrist
&amp; psychatrist 5 0: psychiatrist, psychiatrists, psychiatrist's, psychiatry's, psychiatric</pre>
</div>
</div>
<p>I spelt &#8216;psychiatrist&#8217; wrongly, and it gave me back a few suggested corrections. (Ok I admit, I didn&#8217;t know how to spell it in the first place. <img src='http://rajaseelan.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  )</p>
<p>Lets see what happens when you give it a correctly spelled word:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides visilon]$ aspell -a
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.6)
disapprove
*</pre>
</div>
</div>
<p>Yes, it returns an asterisk(*), showing you&#8217;re spelling is correct.<br />
Press <code>Ctrl + D</code> when you&#8217;re done, to bring you back to the command line.</p>
<p>If you have a text file, you could check that using aspell as well. For example, here&#8217;s some sample text:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">Mary had a little lamb. It's fleede was whote as snow.</pre>
</div>
</div>
<p>We&#8217;ll save it as <code>mary.txt</code> and run aspell like this to check the file:</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">aspell check mary.txt</pre>
</div>
</div>
<p>You&#8217;ll get a interface like this, highlighting every misspelled word, with the suggested actions.</p>
<div id="attachment_217" class="wp-caption aligncenter" style="width: 310px"><a target="blank" href="http://rajaseelan.com/wp-content/uploads/2009/07/aspell-in-action.png"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/aspell-in-action-300x186.png" alt="Aspell in action" title="Aspell in action" width="300" height="186" class="size-medium wp-image-217" /></a>
<p class="wp-caption-text">Aspell in action</p>
</div>
<p>When done with the checking, aspell will exit, saving the previous copy with a <code>.bak</code> extension. <img src='http://rajaseelan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/15/check-your-spelling-in-linux-using-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stop Vim from Highlighting Search Results</title>
		<link>http://rajaseelan.com/2009/07/14/stop-vim-from-highlighting-search-results/</link>
		<comments>http://rajaseelan.com/2009/07/14/stop-vim-from-highlighting-search-results/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 10:40:42 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[highlight]]></category>
		<category><![CDATA[higlighting]]></category>
		<category><![CDATA[hlsearch]]></category>
		<category><![CDATA[no higlights]]></category>
		<category><![CDATA[nohl]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[vi]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=211</guid>
		<description><![CDATA[You can search to words in vim using the &#8216;/&#8217; key when you&#8217;re in command mode. Unfortunately, new admins in their desperation to find a word may inadvertently specify a term too generic.
Vim provides search highlighting, but sometimes, the results are just plain fugly. For example, when searching for the word module in a httpd.conf [...]]]></description>
			<content:encoded><![CDATA[<p>You can search to words in vim using the &#8216;/&#8217; key when you&#8217;re in command mode. Unfortunately, new admins in their desperation to find a word may inadvertently specify a term too generic.</p>
<p>Vim provides search highlighting, but sometimes, the results are just plain fugly. For example, when searching for the word <code>module</code> in a <code>httpd.conf</code> file, this is what could happen:</p>
<div id="attachment_212" class="wp-caption aligncenter" style="width: 310px"><a target="blank" href="http://rajaseelan.com/wp-content/uploads/2009/07/vim-highlight-module.png"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/vim-highlight-module-300x186.png" alt="Vim showing Highlights" title="Vim showing Highlights" width="300" height="186" class="size-medium wp-image-212" /></a>
<p class="wp-caption-text">Vim showing Highlights</p>
</div>
<p>Yeah, not really the the most visually pleasing. To temporarily turn of highlighting, just type</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">:nohlsearch</pre>
</div>
</div>
<p>in vim command mode.</p>
<p>The next time you search for something, or press the &#8216;n&#8217; key, it will be automatically turned back on. </p>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/14/stop-vim-from-highlighting-search-results/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Police report against Al-Islam</title>
		<link>http://rajaseelan.com/2009/07/14/police-report-against-al-islam/</link>
		<comments>http://rajaseelan.com/2009/07/14/police-report-against-al-islam/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 05:01:51 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[the-why-cant-we-just-get-along-dept]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=207</guid>
		<description><![CDATA[Sigh. Never thought I&#8217;d bog about this. 
Can&#8217;t people just live together?
Henotheism (Greek εἷς θεός heis theos &#8220;one god&#8221;) is a term coined by Max Müller, to mean worshiping a single god while accepting the existence or possible existence of other deities.
Fully explained here, in the one &#038; only Wikipedia.  
]]></description>
			<content:encoded><![CDATA[<p>Sigh. Never thought I&#8217;d bog about <a href="http://www.malaysiakini.tv/video/17392.html">this</a>. </p>
<p>Can&#8217;t people just live together?</p>
<blockquote><p><strong>Henotheism </strong>(Greek εἷς θεός heis theos &#8220;one god&#8221;) is a term coined by Max Müller, to mean worshiping a single god while accepting the existence or possible existence of other deities.</p></blockquote>
<p>Fully explained <a href="http://en.wikipedia.org/wiki/Henotheism">here</a>, in the one &#038; only Wikipedia. <img src='http://rajaseelan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/14/police-report-against-al-islam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Mass Rename Files in Linux</title>
		<link>http://rajaseelan.com/2009/07/12/how-to-mass-rename-files-in-linux/</link>
		<comments>http://rajaseelan.com/2009/07/12/how-to-mass-rename-files-in-linux/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 14:12:15 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[mass rename]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=203</guid>
		<description><![CDATA[When entrusted with the chore of renaming multiple file, the convenience of a script shines. After all, we ain&#8217;t robots designed to do just one thing. Today, I&#8217;ll show one method of renaming files, using a for loop in bash.
First, the task we are going to do:
We have a list of files:


[raja@atreides test]$ ls
data_file_1  [...]]]></description>
			<content:encoded><![CDATA[<p>When entrusted with the chore of renaming multiple file, the convenience of a script shines. After all, we ain&#8217;t robots designed to do just one thing. Today, I&#8217;ll show one method of renaming files, using a <strong>for loop</strong> in bash.</p>
<p>First, the task we are going to do:</p>
<p>We have a list of files:</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides test]$ ls
data_file_1   data_file_2  data_file_4  data_file_6  data_file_8
data_file_10  data_file_3  data_file_5  data_file_7  data_file_9</pre>
</div>
</div>
<p>We have been instructed to replace the underscores (<strong>_</strong>) in the file names with hyphens (<strong>-</strong>).</p>
<p>A menial task not really suited for humans. We&#8217;ll start building a script for this, one piece at a time.</p>
<ol>
<li>Check which type of shell you are using.
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">echo $SHELL</pre>
</div>
</div>
<p>As I am using bash scripting, make sure the result is <code>/bin/bash</code></li>
<li>List out all the file that you wish to rename
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">$ ls data_file_*</pre>
</div>
</div>
<p>It should give you output like this:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides test]$ ls data_file_*
data_file_1   data_file_2  data_file_4  data_file_6  data_file_8
data_file_10  data_file_3  data_file_5  data_file_7  data_file_9</pre>
</div>
</div>
</li>
<li>Lets display each one of this in a for loop.
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> file_name <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> data_file_<span style="color: #000000; font-weight: bold;">*`</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;The file:&quot;</span> <span style="color: #007800;">$file_name</span>; <span style="color: #000000; font-weight: bold;">done</span></pre>
</div>
</div>
<p>What this for loop does is take each of the file names given by the <code>ls</code> command and store it in the <code>$file_name</code> bash variable. You&#8217;ll see this:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides test]$ for file_name in `ls data_file_*`; do echo &quot;The file:&quot; $file_name; done
The file: data_file_1
The file: data_file_10
The file: data_file_2
The file: data_file_3
The file: data_file_4
The file: data_file_5
The file: data_file_6
The file: data_file_7
The file: data_file_8
The file: data_file_9</pre>
</div>
</div>
</li>
<li>Now that we&#8217;ve stored the file names in variables, we can use the <code>sed</code> command to edit it, replacing the underscores with a hyphen. I&#8217;ll <code>echo</code> the file name and pipe it to sed, to make sure it replaces the file name, and not modify the files itself.
<p>I used the sed replace command, <code>s</code> with a global option behind, the <code>g</code>, to make sure it replaces all occurrences of the underscore. Without the &#8216;g&#8217;, sed will only replace the first underscore and ignore the rest.</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> file_name <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> data_file_<span style="color: #000000; font-weight: bold;">*`</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;The file:&quot;</span> <span style="color: #007800;">$file_name</span>; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$file_name</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/_/-/g'</span> ; <span style="color: #000000; font-weight: bold;">done</span></pre>
</div>
</div>
<p>When you run this command in your console, you will see this output:</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides test]$ for file_name in `ls data_file_*`; do echo &quot;The file:&quot; $file_name; echo $file_name | sed 's/_/-/g' ; done
The file: data_file_1
data-file-1
The file: data_file_10
data-file-10
The file: data_file_2
data-file-2
The file: data_file_3
data-file-3
The file: data_file_4
data-file-4
The file: data_file_5
data-file-5
The file: data_file_6
data-file-6
The file: data_file_7
data-file-7
The file: data_file_8
data-file-8
The file: data_file_9
data-file-9</pre>
</div>
</div>
</li>
<li>Of course, all this script is doing right now is editing the file name in the $file_name variable itself. Even though you can see what the modified file name will look like, we have not actually renamed the files on your hard disk yet. (This can be a good method of testing your sed-fu, before you really do it <img src='http://rajaseelan.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</li>
<li>In order to actually rename the file, I&#8217;ll put the results of sed&#8217;s transformation in a variable called <code>$new_file_name</code>.I&#8217;ll also print this out to the terminal, so you can see the changes that are about to take place.
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> file_name <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> data_file_<span style="color: #000000; font-weight: bold;">*`</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;The file:&quot;</span> <span style="color: #007800;">$file_name</span>; <span style="color: #007800;">new_file_name</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$file_name</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/_/-/g'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;New name:&quot;</span> <span style="color: #007800;">$new_file_name</span> ; <span style="color: #000000; font-weight: bold;">done</span></pre>
</div>
</div>
<p>You&#8217;ll then see this being output on the terminal:</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides test]$ for file_name in `ls data_file_*`; do echo &quot;The file:&quot; $file_name; new_file_name=$(echo $file_name | sed 's/_/-/g'); echo &quot;New name:&quot; $new_file_name ; done
The file: data_file_1
New name: data-file-1
The file: data_file_10
New name: data-file-10
The file: data_file_2
New name: data-file-2
The file: data_file_3
New name: data-file-3
The file: data_file_4
New name: data-file-4
The file: data_file_5
New name: data-file-5
The file: data_file_6
New name: data-file-6
The file: data_file_7
New name: data-file-7
The file: data_file_8
New name: data-file-8
The file: data_file_9
New name: data-file-9</pre>
</div>
</div>
</li>
<li> Now that we&#8217;ve got both the old AND new file names, nicely stored in variables, its time to actually rename them using the <code>mv</code> command. The syntax for renaming is <code>mv current_file_name new_file_name</code>. I think you&#8217;re starting to see where these variables come in handy. <img src='http://rajaseelan.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> file_name <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> data_file_<span style="color: #000000; font-weight: bold;">*`</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;The file:&quot;</span> <span style="color: #007800;">$file_name</span>; <span style="color: #007800;">new_file_name</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$file_name</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/_/-/g'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;New name:&quot;</span> <span style="color: #007800;">$new_file_name</span> ; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">$file_name</span> <span style="color: #007800;">$new_file_name</span>; <span style="color: #000000; font-weight: bold;">done</span></pre>
</div>
</div>
<p>I&#8217;ve added a <code>-v</code> to the <code>mv</code>, so it displays what it is changing. As I always say, a little more verbosity is always good, especially on the terminal. Your final output will be something like this:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides test]$ for file_name in `ls data_file_*`; do echo &quot;The file:&quot; $file_name; new_file_name=$(echo $file_name | sed 's/_/-/g'); echo &quot;New name:&quot; $new_file_name ; mv -v $file_name $new_file_name; done
The file: data_file_1
New name: data-file-1
`data_file_1' -&gt; `data-file-1'
The file: data_file_10
New name: data-file-10
`data_file_10' -&gt; `data-file-10'
The file: data_file_2
New name: data-file-2
`data_file_2' -&gt; `data-file-2'
The file: data_file_3
New name: data-file-3
`data_file_3' -&gt; `data-file-3'
The file: data_file_4
New name: data-file-4
`data_file_4' -&gt; `data-file-4'
The file: data_file_5
New name: data-file-5
`data_file_5' -&gt; `data-file-5'
The file: data_file_6
New name: data-file-6
`data_file_6' -&gt; `data-file-6'
The file: data_file_7
New name: data-file-7
`data_file_7' -&gt; `data-file-7'
The file: data_file_8
New name: data-file-8
`data_file_8' -&gt; `data-file-8'
The file: data_file_9
New name: data-file-9
`data_file_9' -&gt; `data-file-9'</pre>
</div>
</div>
<p>An <code>ls</code> will reveal that all files have really been changed this time.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides test]$ ls
data-file-1   data-file-2  data-file-4  data-file-6  data-file-8
data-file-10  data-file-3  data-file-5  data-file-7  data-file-9</pre>
</div>
</div>
<p>This should give you an idea on how to mass rename files. Of course there are probably better ways. Please do comment if you know some.
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/12/how-to-mass-rename-files-in-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
