<?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 &#187; How To</title>
	<atom:link href="http://rajaseelan.com/category/howto/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.2</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>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>
		<item>
		<title>How to install a Dynamic DNS client for Fedora Linux</title>
		<link>http://rajaseelan.com/2009/07/10/how-to-install-a-dynamic-dns-client-for-fedora-linux/</link>
		<comments>http://rajaseelan.com/2009/07/10/how-to-install-a-dynamic-dns-client-for-fedora-linux/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 14:56:36 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[dynamic dns]]></category>
		<category><![CDATA[dyndns]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[inadyn]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=197</guid>
		<description><![CDATA[Many people use dynamic dns for different purposes. I use it to give my home machine a public presence. I choose DynDNS for my needs. Its a leader in this segment and have been around for a long time.
First, you&#8217;ll need to register for a free account at their site. Once you&#8217;ve chosen a domain [...]]]></description>
			<content:encoded><![CDATA[<p>Many people use <a href="http://en.wikipedia.org/wiki/Dynamic_DNS">dynamic dns</a> for different purposes. I use it to give my home machine a public presence. I choose <a href="http://www.dyndns.com/">DynDNS</a> for my needs. Its a leader in this segment and have been around for a long time.</p>
<p>First, you&#8217;ll need to register for a free account at their site. Once you&#8217;ve chosen a domain name and setup your details, you&#8217;ll need a dynamic dns client to update your IP, which probably changes every time you sign on to your ISP.</p>
<p>I use <a href="http://inadyn-mt.sourceforge.net">inadyn</a>, a free dynamic dns update client that works in linux.</p>
<p>The Inadyn package name is <code>inadyn-mt</code>. Install inadyn using yum:</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">yum install inadyn-mt</pre>
</div>
</div>
<p>Then edit the <code>/etc/inadyn.conf</code> file with your details.</p>
<p>Then turn on the service.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">service inadyn start</pre>
</div>
</div>
<p>Check <code>/var/log/messages</code>. you should get some entires showing whether you edited the config file properly, and the update was successful.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">Jul 10 22:50:43 atom INADYN[8251]: Fri Jul 10 22:50:43 2009: I:INADYN: Alias 'your-hostname.dyndns.org' to IP '12.34.56.78' updated successfully.</pre>
</div>
</div>
<p>Once you know the client works, dont forget to turn it on permanently on startup.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">chkconfig inadyn on</pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/10/how-to-install-a-dynamic-dns-client-for-fedora-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to enable the Windows Key in Linux</title>
		<link>http://rajaseelan.com/2009/07/10/how-to-enable-the-windows-key-in-linux/</link>
		<comments>http://rajaseelan.com/2009/07/10/how-to-enable-the-windows-key-in-linux/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 11:55:12 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[shortcuts]]></category>
		<category><![CDATA[windows key]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=185</guid>
		<description><![CDATA[After installing Fedora, or most linuxes, you may realise that the Windows key that you used during the unenlightened days doesnt work anymore. Even worse, you cannot seem to use it as part of you Keyboard shortcuts. Gives some weird irony when reading about Dead Keys.
Enabling the Windows Key is easy, Just go to System [...]]]></description>
			<content:encoded><![CDATA[<p>After installing Fedora, or most linuxes, you may realise that the <a href="http://en.wikipedia.org/wiki/Windows_key">Windows key</a> that you used during the unenlightened days doesnt work anymore. Even worse, you cannot seem to use it as part of you Keyboard shortcuts. Gives some weird irony when reading about <a href="http://en.wikipedia.org/wiki/Dead_key">Dead Keys</a>.</p>
<p>Enabling the Windows Key is easy, Just go to <strong>System</strong> -> <strong>Preferences</strong> -> <strong>Keyboard</strong>.<br />
<a target="blank" href="http://rajaseelan.com/wp-content/uploads/2009/07/gnome_keyboard.jpg">
<div id="attachment_186" class="wp-caption aligncenter" style="width: 310px"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/gnome_keyboard-300x240.jpg" alt="The Keyboard Menu under Preferences" title="The Keyboard Menu under Preferences" width="300" height="240" class="size-medium wp-image-186" />
<p class="wp-caption-text">The Keyboard Menu under Preferences</p>
</div>
<p></a></p>
<p>You will get the <strong>Keyboard Preferences</strong> window up. Choose the <strong>Layouts</strong> tab.</p>
<div id="attachment_187" class="wp-caption aligncenter" style="width: 294px"><a href="http://rajaseelan.com/wp-content/uploads/2009/07/kbd02.png"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/kbd02-284x300.png" alt="The Keyboard type used" title="The Keyboard type used" width="284" height="300" class="size-medium wp-image-187" /></a>
<p class="wp-caption-text">The Keyboard type used</p>
</div>
<p>Then choose <strong>Layout Options</strong>. A new <strong>Keyboard Layout Options</strong> window comes out. </p>
<div id="attachment_188" class="wp-caption aligncenter" style="width: 310px"><a target="blank" href="http://rajaseelan.com/wp-content/uploads/2009/07/kbd03.png"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/kbd03-300x220.png" alt="Keyboard Layout Options" title="Keyboard Layout Options" width="300" height="220" class="size-medium wp-image-188" /></a>
<p class="wp-caption-text">Keyboard Layout Options</p>
</div>
<p>Expand the <strong>Alt/Win Key Behavior</strong> menu, and choose <strong>Super is mapped to Win Keys</strong> Then close all the menus. You know have a functional Windows key.</p>
<div id="attachment_189" class="wp-caption aligncenter" style="width: 310px"><a target="blank" href="http://rajaseelan.com/wp-content/uploads/2009/07/kbd04.png"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/kbd04-300x220.png" alt="Choose the Super is mapped to Win Keys" title="Choose the Super is mapped to Win Keys" width="300" height="220" class="size-medium wp-image-189" /></a>
<p class="wp-caption-text">Choose the Super is mapped to Win Keys</p>
</div>
<p>You can now assign shortcuts using the <strong>Keyboard Shortcuts</strong> menu. In this screenshot, I assigned Windows key + R to opening a new terminal.</p>
<div id="attachment_190" class="wp-caption aligncenter" style="width: 310px"><a target="blank" href="http://rajaseelan.com/wp-content/uploads/2009/07/kbd045.png"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/kbd045-300x285.png" alt="A Sample Shortcut Using the Windows Key" title="A Sample Shortcut Using the Windows Key" width="300" height="285" class="size-medium wp-image-190" /></a>
<p class="wp-caption-text">A Sample Shortcut Using the Windows Key</p>
</div>
<p>Pretty handy for me. I&#8217;m sure you will be able to think of other shortcuts that suite your fancy.</p>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/10/how-to-enable-the-windows-key-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to print usernames with a userid greater than 500</title>
		<link>http://rajaseelan.com/2009/07/09/how-to-print-usernames-with-a-userid-greater-than-500/</link>
		<comments>http://rajaseelan.com/2009/07/09/how-to-print-usernames-with-a-userid-greater-than-500/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 13:37:53 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[uid]]></category>
		<category><![CDATA[usernames]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=100</guid>
		<description><![CDATA[Occasionally, you need to print out a list of usernames, greater than a certain user id. This is usually useful an a slightly larger setup, or when you want to chain more commands to certain users.
Use the awk command.


awk -F&#34;:&#34; ' $3 &#62; 200  {print $1} '  /etc/passwd


]]></description>
			<content:encoded><![CDATA[<p>Occasionally, you need to print out a list of usernames, greater than a certain <em>user id</em>. This is usually useful an a slightly larger setup, or when you want to chain more commands to certain users.</p>
<p>Use the awk command.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">awk -F&quot;:&quot; ' $3 &gt; 200  {print $1} '  /etc/passwd</pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/09/how-to-print-usernames-with-a-userid-greater-than-500/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2 CLI ways to determine which rpm package has a program you wish to install in Fedora Linux</title>
		<link>http://rajaseelan.com/2009/07/08/2-cli-ways-to-determine-which-rpm-package-has-a-program-you-wish-to-install-in-fedora-linux/</link>
		<comments>http://rajaseelan.com/2009/07/08/2-cli-ways-to-determine-which-rpm-package-has-a-program-you-wish-to-install-in-fedora-linux/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 18:11:07 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[provides]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[yum.]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=177</guid>
		<description><![CDATA[There are 2 ways I know of to search for a particular program to install in Linux. As usual, I&#8217;ll be focusing on the Command Line Interface (CLI).
So, you&#8217;ve heard about the versatile port scanning tool called nmap and want to install it in Fedora Linux. The only problem is, you don&#8217;t know if it [...]]]></description>
			<content:encoded><![CDATA[<p>There are 2 ways I know of to search for a particular program to install in Linux. As usual, I&#8217;ll be focusing on the Command Line Interface (CLI).</p>
<p>So, you&#8217;ve heard about the versatile port scanning tool called <a href="http://nmap.org/">nmap</a> and want to install it in Fedora Linux. The only problem is, you don&#8217;t know if it has been pre-packaged and is available as an rpm binary. No worries, all you need to do is search for using <code>yum</code>.</p>
<p>Use the yum search command.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">yum search nmap</pre>
</div>
</div>
<p>Based on its output, you know there are packages available, and all you need to do is <code>yum install nmap</code></p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides ~]$ yum search nmap
Loaded plugins: fastestmirror, presto, refresh-packagekit
================================ Matched: nmap =================================
nmap.i586 : Network exploration tool and security scanner
nmap-frontend.i586 : the GTK+ frontend for nmap
onesixtyone.i586 : An efficient SNMP scanner
perl-Nmap-Parser.noarch : Parse nmap scan data with perl
psad.i586 : Port Scan Attack Detector (psad) watches for suspect traffic</pre>
</div>
</div>
<p>Or, you might know that its called <code>nmap</code>, and want to search through you yum repositories to find if any of the available rpms have a file called nmap. To do that, use the <code>yum provides */
<program_name> command. e.g.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">yum provides */nmap</pre>
</div>
</div>
<p>Look at what it gives:</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">[raja@atreides ~]$ yum provides */nmap
Loaded plugins: fastestmirror, presto, refresh-packagekit
2:nmap-4.76-4.fc11.i586 : Network exploration tool and security scanner
Repo        : fedora
Matched from:
Filename    : /usr/share/nmap
Filename    : /usr/bin/nmap</pre>
</div>
</div>
<p>From this, you know that the <code>nmap-4.76-4.fc11.i586</code> rpm contains these files, and by installing it, you get nmap.</program_name></code></p>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/08/2-cli-ways-to-determine-which-rpm-package-has-a-program-you-wish-to-install-in-fedora-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use a download accelerator with a Rapidshare Premium Account in Fedora Linux</title>
		<link>http://rajaseelan.com/2009/07/08/how-to-use-a-download-accelerator-with-a-rapidshare-premium-account-in-fedora-linux/</link>
		<comments>http://rajaseelan.com/2009/07/08/how-to-use-a-download-accelerator-with-a-rapidshare-premium-account-in-fedora-linux/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 17:24:52 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[aria2]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[download accelator]]></category>
		<category><![CDATA[rapidshare]]></category>
		<category><![CDATA[yum.]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=123</guid>
		<description><![CDATA[After reading my previous post, the next question that&#8217;s bound to crop up is How do I use a download accelerator with my premium rapidshare share account in linux?  
Being a command line junkie, I prefer using the terminal for my downloading needs. Let me introduce you to Aria2. As from the website. 
aria2 [...]]]></description>
			<content:encoded><![CDATA[<p>After reading my previous <a href="http://rajaseelan.com/2009/06/30/how-to-download-using-a-rapidshare-premium-account-in-linux/">post</a>, the next question that&#8217;s bound to crop up is <strong>How do I use a download accelerator with my premium rapidshare share account in linux?</strong>  </p>
<p>Being a command line junkie, I prefer using the terminal for my downloading needs. Let me introduce you to <a href="http://aria2.sourceforge.net/">Aria2</a>. As from the website. </p>
<blockquote><p>aria2 is a multi-protocol &#038; multi-source, cross platform download utility. The supported protocols are HTTP(S), FTP, BitTorrent  (DHT, PEX, MSE/PE), and Metalink. </p></blockquote>
<p>Using Fedora, my favourite distro of choice, you first have to install it via yum.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">yum install aria2</pre>
</div>
</div>
<p>Next, you&#8217;ll need to have your cookies saved. Refer to the <a href="http://rajaseelan.com/2009/06/30/how-to-download-using-a-rapidshare-premium-account-in-linux/">previous</a> post for more details.</p>
<p>Now comes the fun part, actually downloading the files.</p>
<p>Here&#8217;s a file which I uploaded, a movie trailer for a recent movie:-</p>
<p><code>http://rapidshare.com/files/207110649/terminatorsalvation-tlr1_h1080p.mov</code></p>
<p>To download with aria2, type in the following command:-</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">aria2c -s 5 -j 1 -c --load-cookies=/home/raja/cookies.txt http://rapidshare.com/files/207110649/terminatorsalvation-tlr1_h1080p.mov</pre>
</div>
</div>
<p>The switches for this explained:-</p>
<ul>
<li><strong>-s 5</strong> Split the download into 5 connections</li>
<li><strong>-j 1</strong> How many files to download at once.</li>
<li><strong>-c</strong> Continue any paused / cancelled downloads</li>
<li><strong>&#8211;load-cookies /path/to/cookie</strong> The rapidshare cookie file that was created earlier. This has to be an absolute path</li>
<li>And finally the actual URL of the file</li>
</ul>
<p>If you have a list of files to download, you can enter them in to a text file, and pass them to aria2 for batch downloading via the <strong>-i list_file_name</strong> option. e.g.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">aria2c -s 5 -j 1 -c --load-cookies=/home/raja/cookies.txt -i lists.txt</pre>
</div>
</div>
<p>Happy batch downloading!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/08/how-to-use-a-download-accelerator-with-a-rapidshare-premium-account-in-fedora-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
