<?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>Technology: Learn and Share &#187; Linux Tips</title>
	<atom:link href="http://crazytoon.com/category/linux-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://crazytoon.com</link>
	<description>Enterprise level solutions, LAMP, Linux, Apache, MySQL, PHP, Perl, Windows, Cache, Optimization</description>
	<lastBuildDate>Fri, 16 Jul 2010 20:24:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How do you print number of files for each folder in a directory [Linux]</title>
		<link>http://crazytoon.com/2010/04/05/get-file-counts-for-folders-linux/</link>
		<comments>http://crazytoon.com/2010/04/05/get-file-counts-for-folders-linux/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 20:37:06 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=208</guid>
		<description><![CDATA[I have been annoyed by the fact that I couldn&#8217;t easily print file count for all of the folders in certain directory.  Most of the time I just want to see what space each folder is using (du -hs *) but there are times when I need to know how many files are in each [...]]]></description>
			<content:encoded><![CDATA[<p>I have been annoyed by the fact that I couldn&#8217;t easily print file count for all of the folders in certain directory.  Most of the time I just want to see what space each folder is using (du -hs *) but there are times when I need to know how many files are in each folder (checking cache folder, session folders etc).   So I whipped together a command line which does just that for me:</p>
<p><code>for i in `find -maxdepth 1 -type d`; do  echo -n $i " ";find $i|wc -l; done</code></p>
<p>I am sure there are many different ways to show file count for each folder in a directory and I am curious to see what people do so please do post comments with what you do.</p>
<p>Above command is pretty simple and can be expanded to do whatever you need.  For example, you can throw it into a bash script and be able to pass parameters.  For example:  count_files /home/  In this case your command line would look like:</p>
<p><code>for i in `find /home/ -maxdepth 1 -type d`; do  echo -n $i " ";find $i|wc  -l; done</code></p>
<p>only difference would be that /home/ would be argument you passed and therefore will be $1.  Here is a sample script for above example:</p>
<p><code>#!/bin/bash<br />
for i in `find $1 -maxdepth 1 -type d`; do<br />
echo -n $i " ";<br />
find $i|wc -l;<br />
done</code></p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet  carefully. Make backups often. And yeah.. last but not least.. I am not  responsible for any damage caused by this posting. <strong>Use at your  own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2010/04/05/get-file-counts-for-folders-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Telnet: shell script to issue commands to telnet session.</title>
		<link>http://crazytoon.com/2009/01/03/telnet-shell-script-to-issue-commands-to-telnet-session/</link>
		<comments>http://crazytoon.com/2009/01/03/telnet-shell-script-to-issue-commands-to-telnet-session/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 15:25:43 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[telnet]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=159</guid>
		<description><![CDATA[This is a quick post to show how one can issue commands to telnet session from a shell script or command line with out going into interactive mode.  I use this to get stats from our memcache servers or issue a flush_all via telnet from a script/cron.
So without further delay, following command will telnet [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick post to show how one can issue commands to <a title="man telnet - man page for telnet " href="http://www.lamp-tips.com/man-pages/telnet /" target="_blank">telnet</a> session from a shell script or command line with out going into interactive mode.  I use this to get stats from our memcache servers or issue a flush_all via <a title="man telnet - man page for telnet " href="http://www.lamp-tips.com/man-pages/telnet /" target="_blank">telnet</a> from a script/cron.</p>
<p>So without further delay, following command will telnet to local memcached server on port 11211 and issue one of the memcached commands, stats</p>
<p><code>(sleep .5;echo stats) | telnet localhost 11211</code><br />
You may have to play with the sleep timer to get it to work for your environment but in our .5 was the sweet spot.  Good luck and let me know if you have another shell command.  Obviously we can do this from perl, php, python, etc but the beauty of this is that you do not need any other dependencies plus its a very short command.</p>
<p>Since &#8220;jsled&#8221; commented about <a title="man nc - man page for nc" href="http://www.lamp-tips.com/man-pages/nc/" target="_blank">nc</a> (thanks jsled), here is the syntax to do the same thing with <a title="man nc - man page for nc" href="http://www.lamp-tips.com/man-pages/nc/" target="_blank">nc</a>:</p>
<p><code>echo "stats" | nc localhost 11211</code></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2009/01/03/telnet-shell-script-to-issue-commands-to-telnet-session/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SVN:  How do you use svn command line on Windows with ssh tunneling?</title>
		<link>http://crazytoon.com/2008/11/19/svn-how-do-you-use-svn-command-line-on-windows-with-ssh-tunneling/</link>
		<comments>http://crazytoon.com/2008/11/19/svn-how-do-you-use-svn-command-line-on-windows-with-ssh-tunneling/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 14:58:03 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[Windows System]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=151</guid>
		<description><![CDATA[If you ever used svn command line, you know it is not optimal to type in your password every time you do checkout, checkin, info, etc.  In linux world, it is very easy to setup keys to get around this.  Of course in the world of Windows it is not as easy.  Here are the steps [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever used svn command line, you know it is not optimal to type in your password every time you do checkout, checkin, info, etc.  In linux world, it is very easy to <a title="SSH: setting up public key authentication over SSH" href="http://crazytoon.com/2007/08/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/" target="_blank">setup keys</a> to get around this.  Of course in the world of Windows it is not as easy.  Here are the steps you need to follow to get private/public keys working with your SVN under Windows using ssh tunneling.</p>
<p><strong>Assumptions</strong>:  you will be connecting as user &#8220;root&#8221; to svn server located at &#8220;10.0.0.1&#8243;.  All your files will be saved at c:\ including your svn command line utility</p>
<p>First we will have to generate a key.  We can accomplish this by using a free utility called <a title="puttygen: free key generator" href="http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe" target="_blank">puttygen</a>.  Run puttygen and click on &#8220;Generate&#8221; button.  You will have a key similar to below example:</p>
<div id="attachment_153" class="wp-caption alignnone" style="width: 310px"><a href="http://crazytoon.com/wp-content/uploads/2008/11/puttygen_key.gif"><img class="size-medium wp-image-153" title="puttygen key example" src="http://crazytoon.com/wp-content/uploads/2008/11/puttygen_key-300x288.gif" alt="Example of a key generated by puttygen" width="300" height="288" /></a><p class="wp-caption-text">Example of a key generated by puttygen</p></div>
<p>Copy this, you will need it in few mins.  At this point, go ahead and create a private key by clicking on:  &#8220;Save private key&#8221;.  Save this as private.ppk on your C:\.  </p>
<p>Now let us log in to the svn server and add this public key to the authorized_keys2 (see <a title="SSH: setting up public key authentication over SSH" href="http://crazytoon.com/2007/08/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/" target="_blank">setting up keys</a> for step by step instructions).  I will assume you are using &#8220;root&#8221; as login.</p>
<p><code>vi /root/.ssh/authorized_keys2</code></p>
<p>Make sure when you paste, it is not broken into different lines.  All of the key should be one line.</p>
<p>Ok now back to your Windows machine.  Now we need to set up ssh tunnel to our server.  There are few ways of doing this but for our purpose, we will use another free program provided by the same developers as puttygen: <a title="plink: used to create ssh tunnel" href="http://the.earth.li/~sgtatham/putty/latest/x86/plink.exe" target="_blank">download plink</a> to C:\.  If you do not do this step, you will get following error:</p>
<p><code>svn: Can't create tunnel: The system cannot find the file specified.</code></p>
<p>Ok let us set the variables for svn.  Go to command prompt and type (you can also set this in your scripts and inside windows environment.  But since this post is to show you an example, we will just do this):</p>
<p><code>set SVN_SSH="/plink.exe" -i /private.ppk -l root</code></p>
<p>Now let&#8217;s run this one time manually to cache key:</p>
<p><code>/plink.exe -i /private.ppk -l root 10.0.0.1</code></p>
<p>Press &#8220;y&#8221; when it asks you to save.  Type exit and get back to your prompt.</p>
<p>Ok now we can test our svn utility.</p>
<p><code>/svn info svn+ssh://10.0.0.1/svn/testrepo/trunk/</code></p>
<p>This should display output similar to:</p>
<p><code>Path: trunk<br />
URL: svn+ssh://10.0.0.1/svn/testrepo/trunk<br />
Repository Root: svn+ssh://10.0.0.1/svn/testrepo<br />
Repository UUID: b9143312-b1a1-11ba-a111-11cdcd1d2222<br />
Revision: 10<br />
Node Kind: directory<br />
Last Changed Author: root<br />
Last Changed Rev: 4<br />
Last Changed Date: 2008-11-18 15:18:47 -0800 (Tue, 18 Nov 2008)</code></p>
<p>Now you are ready to script your checkouts, do checkin&#8217;s with out having to type in your password, etc.</p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/11/19/svn-how-do-you-use-svn-command-line-on-windows-with-ssh-tunneling/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>sshfs: How do you install sshfs and fuse? [CentOS/Linux/Redhat]</title>
		<link>http://crazytoon.com/2008/10/07/sshfs-how-do-you-install-sshfs-and-fuse-centoslinuxredhat/</link>
		<comments>http://crazytoon.com/2008/10/07/sshfs-how-do-you-install-sshfs-and-fuse-centoslinuxredhat/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 23:06:50 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[fuse]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[sshfs]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=84</guid>
		<description><![CDATA[One may wonder what is sshfs and why would you want it?  Well simply put, sshfs allows you to mount another server&#8217;s filesystem into a folder on your local system which in the background is doing ssh commands and transfers.  As a mounted folder, you are able to move about and copy files back and [...]]]></description>
			<content:encoded><![CDATA[<p>One may wonder what is sshfs and why would you want it?  Well simply put, sshfs allows you to mount another server&#8217;s filesystem into a folder on your local system which in the background is doing ssh commands and transfers.  As a mounted folder, you are able to move about and copy files back and forth as everything was on local server.  As you can see this makes it very easy for you to work with files on multiple servers.</p>
<p><strong>Note</strong>:  you only have to do the following installations on the server where you are doing the mounts on.</p>
<p>Let us download and install the filesystem framework which is a requirement for sshfs called fuse.</p>
<p><code>wget http://voxel.dl.sourceforge.net/sourceforge/fuse/fuse-2.7.4.tar.gz<br />
tar zxpfv fuse-*.gz<br />
cd fuse*<br />
./configure</code></p>
<p>If you get the following error, you will either have to point to the location of the kernel source or install it if needed.</p>
<p><code>checking kernel source directory... Not found<br />
configure: error:<br />
*** Please specify the location of the kernel source with<br />
*** the '--with-kernel=SRCDIR' option<br />
configure: error: ./configure failed for kernel</code></p>
<p>In our case here, we will be installing the source using yum.</p>
<p><code>yum -y install kernel-devel</code></p>
<p>Once installed, you will have to find out the directory it is installed in</p>
<p><code>ls -l /usr/src/kernels/<br />
total 4.0K<br />
drwxr-xr-x 18 root root 4.0K Oct  7 14:50 <strong>2.6.18-92.1.13.el5-x86_64</strong>/</code></p>
<p><code>./configure --with-kernel=/usr/src/kernels/<strong>2.6.18-92.1.13.el5-x86_64</strong><br />
make &amp;&amp; make install<br />
cd ..</code></p>
<p>Now let us get sshfs source and install it.</p>
<p><code>wget http://voxel.dl.sourceforge.net/sourceforge/fuse/sshfs-fuse-2.1.tar.gz<br />
tar zxpfv sshfs*<br />
cd sshfs-fuse-*<br />
./configure</code></p>
<p>If you get the following error:</p>
<p><code>checking for SSHFS... configure: error: The pkg-config script could not be found or is too old.  Make sure it<br />
is in your PATH or set the PKG_CONFIG environment variable to the full<br />
path to pkg-config.</code></p>
<p>OR</p>
<p><code>checking for SSHFS... configure: error: Package requirements (fuse &gt;= 2.2 glib-2.0 gthread-2.0) were not met:</code></p>
<p>No package &#8216;glib-2.0&#8242; found<br />
No package &#8216;gthread-2.0&#8242; found</p>
<p>You need to install glib2.  Do the following:</p>
<p><code>yum install glib2-devel</code></p>
<p>Once installation is done, continue with configure.</p>
<p><code>./configure<br />
make &amp;&amp; make install</code></p>
<p>After installation is done, we can move on with testing the installation:</p>
<p><code>cd /mnt<br />
mkdir test<br />
sshfs 10.0.0.2:/ test</code></p>
<p>If you get the following error,<br />
<code>sshfs: error while loading shared libraries: libfuse.so.2: cannot open shared object file: No such file or directory</code><br />
execute this:  NOTE:  this is for x64 system.  If you have 32 bit system, you have to symlink to /lib instead.<br />
<code>ln -s /usr/local/lib/libfuse.so.2 /lib64/</code><br />
Let us try mounting again:<br />
<code>sshfs 10.0.0.2:/ test</code><br />
At this point it would be like if you were making a ssh connection to 10.0.0.2  You will have to type in a password to get the mount to happen.  You may get the following error:  <code>fuse: device not found, try 'modprobe fuse' first</code></p>
<p>If you do &#8216;modprobe fuse&#8217;, as they tell you to, and you get:<br />
<code>modprobe fuse<br />
FATAL: Module fuse not found.</code></p>
<p>That means your running kernel is not the same version as the one you compiled with.  You have two options here:<br />
1) you can upgrade your kernel by typing:  yum update kernel<br />
2) find the source files for the kernel you have running and recompile fuse.</p>
<p>I went with option 1.  Once you do the update, reboot and try doing <em>modprobe fuse</em> again.</p>
<p>At this point we can try doing the mount again.<br />
<code>cd /mnt<br />
sshfs 10.0.0.2:/ test</code></p>
<p>If you do not get any errors, do df -h to see the mount:<br />
<code>...<br />
sshfs#10.0.0.2:/  1000G     0 1000G   0% /mnt/test<br />
...</code></p>
<p>At this point you can browse 10.0.0.2 server filesystem as it was local on your server.</p>
<p>————————————-</p>
<p><small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/10/07/sshfs-how-do-you-install-sshfs-and-fuse-centoslinuxredhat/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Linux: How do you find out what your server&#8217;s outgoing ip is?</title>
		<link>http://crazytoon.com/2008/09/04/linux-how-do-you-find-out-what-your-servers-outgoing-ip-is/</link>
		<comments>http://crazytoon.com/2008/09/04/linux-how-do-you-find-out-what-your-servers-outgoing-ip-is/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 14:27:05 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Notes for self]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=110</guid>
		<description><![CDATA[There are many times when I needed to find out my outgoing (or external) IP for the servers which are behind load balancers or firewalls.  I used to just login to another external server from the server in question and find out by looking at &#8220;who&#8221; what my external ip is.  Even though it works [...]]]></description>
			<content:encoded><![CDATA[<p>There are many times when I needed to find out my outgoing (or external) IP for the servers which are behind load balancers or firewalls.  I used to just login to another external server from the server in question and find out by looking at &#8220;<a title="man who - manpage for who" href="http://www.lamp-tips.com/man-pages/who/" target="_blank">who</a>&#8221; what my external ip is.  Even though it works and I am so used to it, today I decided to figure out a more graceful way of finding my outgoing ip.  As most of us already know, whatismyip.com is the quickest way to find out your outgoing ip from the browser.  So I decided to use the same way on the servers.  So I issued a wget:</p>
<p><code>wget http://www.whatismyip.org</code></p>
<p>Well that does the trick.  But being lazy as I am, I did not want to have to cat the output file to find out the ip (plus there is no point of creating extra files and doing extra work to remove them).  So if you are ssh&#8217;ed in, you can issue following command (I am sure there is another way of doing it, but this is the quickest way I could think of):</p>
<p><code><a title="man wget - manpage for wget" href="http://www.lamp-tips.com/man-pages/wget/" target="_blank">wget</a> -q -O - http://www.whatismyip.org</code></p>
<p>-O tells wget to redirect output to the following file (- being the standard out ).  So it basically echo&#8217;s output to our console.</p>
<p>-q makes wget run in  quiet mode so you do not see all of the connection/download/etc output.</p>
<p>That is it!  I am curious to know what other ways people use to get the same information.  Please share your way if possible.</p>
<p>————————————-</p>
<p><small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/09/04/linux-how-do-you-find-out-what-your-servers-outgoing-ip-is/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Quick tip:  how do you rename all files so spaces are converted to underscores?</title>
		<link>http://crazytoon.com/2008/08/25/quick-tip-how-do-you-rename-all-files-so-spaces-are-converted-to-underscores/</link>
		<comments>http://crazytoon.com/2008/08/25/quick-tip-how-do-you-rename-all-files-so-spaces-are-converted-to-underscores/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 23:36:13 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[man tr]]></category>
		<category><![CDATA[rename files]]></category>
		<category><![CDATA[spaces to underscores]]></category>
		<category><![CDATA[uppercase to lowercase]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=97</guid>
		<description><![CDATA[My friend today asked me how to convert all spaces in filenames under a specified directory to underscores.  Also, at the same time lowercase all of the filenames.  Here is a quick script to do what is needed.  Let us start with creating some test data in a temp directory:
mkdir temp
cd temp
touch [...]]]></description>
			<content:encoded><![CDATA[<p>My friend today asked me how to convert all spaces in filenames under a specified directory to underscores.  Also, at the same time lowercase all of the filenames.  Here is a quick script to do what is needed.  Let us start with creating some test data in a temp directory:</p>
<p><code>mkdir temp<br />
cd temp<br />
touch Foo FooO "Foo Bar" "FOO BAaR"<br />
\ls | while read -r FILENAME<br />
do<br />
mv -v "$FILENAME" `echo $FILENAME| tr ' ' '_'| tr '[A-Z]' '[a-z]'`<br />
done</code></p>
<p>Note:  I intentionally have slash in front of ls (\ls).  \ls means that we want to make sure there is no ls alias overwriting our command.  This is needed if your system has alias setup to display ls in a different way instead of default listing.  mv -v shows us the filenames being renamed as your script goes through the whole dir.  Your output should be like:</p>
<p><code>`Foo' -&gt; `foo'<br />
`FOO BAaR' -&gt; `foo_baar'<br />
`Foo Bar' -&gt; `foo_bar'<br />
`FooO' -&gt; `fooo'</code></p>
<p>One of the very powerful commands in this post is the &#8220;tr&#8221; command.  This command is not as popular as sed or awk but it is very useful and simple to use (<a title="man tr - man page for tr" href="http://www.lamp-tips.com/man-pages/tr/" target="_blank">read more about tr</a>).</p>
<p>If you only needed to convert spaces to underscores and you are using CentOS/Fedora/Redhat, you can use this simpler method.  <strong>NOTE</strong>:  this command is not available on all distributions:  <code>rename " " "_" *</code></p>
<p>Learn more about <a title="man rename - man page for rename" href="http://www.lamp-tips.com/man-pages/rename/" target="_blank">rename </a>command<br />
————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/08/25/quick-tip-how-do-you-rename-all-files-so-spaces-are-converted-to-underscores/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Linux:  How do you rename a user account in linux?</title>
		<link>http://crazytoon.com/2008/05/09/linux-how-do-you-rename-a-user-account-in-linux/</link>
		<comments>http://crazytoon.com/2008/05/09/linux-how-do-you-rename-a-user-account-in-linux/#comments</comments>
		<pubDate>Fri, 09 May 2008 11:13:19 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=69</guid>
		<description><![CDATA[In Linux, there is no command which will rename a user account. If you make a mistake creating a user account, user changes their name or if user does not like his user name, there is no real easy way of going and making the change.  Only thing I know you can do is [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: line-through;">In Linux, there is no command which will rename a user account.</span> If you make a mistake creating a user account, user changes their name or if user does not like his user name, there is no real easy way of going and making the change.  Only thing I know you can do is to go through some files and rename user manually.  Let us say that we have a user who is named joe and we want to rename him to john.</p>
<p>Note:  you must be logged in as root to do following.</p>
<p>vi /etc/passwd<br />
find joe and change it to john, save/exit</p>
<p>vi /etc/group<br />
find joe and change it to john, save/exit</p>
<p>vi /etc/shadow<br />
find joe and change it to john.  This file is read only and you have to force overwrite it.  In vi it is :w!  once saved, quit.</p>
<p>cd /home<br />
mv joe john</p>
<p>And that should do the trick.</p>
<p>[Edited] Right after I posted this post, I was contacted and was told to look at utility called usermod.  Read more about it <a title="Man usermod:  man page for usermod" href="http://www.lamp-tips.com/man-pages/usermod/" target="_blank">man usermod</a>.  Got to love the quick responses.  </p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/05/09/linux-how-do-you-rename-a-user-account-in-linux/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Linux: How do you display specific information at login prompt in Linux on the console?</title>
		<link>http://crazytoon.com/2008/04/22/linux-how-to-change-login-prompt-in-linux/</link>
		<comments>http://crazytoon.com/2008/04/22/linux-how-to-change-login-prompt-in-linux/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 02:00:50 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[login prompt]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=63</guid>
		<description><![CDATA[Buddy of mine asked me a question over chat today: &#8220;how do I show my machines&#8217; IP at login prompt with out logging in?&#8221;  He is referring to his Virtual Machine in this case.  He does not want to have to log in to the server to see what ip it has (since [...]]]></description>
			<content:encoded><![CDATA[<p>Buddy of mine asked me a question over chat today: &#8220;how do I show my machines&#8217; IP at login prompt with out logging in?&#8221;  He is referring to his Virtual Machine in this case.  He does not want to have to log in to the server to see what ip it has (since its on dhcp) for him to ssh in or hit it from the browser.  I could have answered him with a simple how to but what is the fun in that?  So I decided to give some background on how login prompts are done and show what can be done.</p>
<p>When Linux server boots up, it calls a program called mingetty.  This program creates that infamous login prompt as show in a screenshot:</p>
<p><img style="vertical-align: middle;" src="http://crazytoon.com/wp-content/uploads/2008/04/centos_default_login_prompt-300x74.png" alt="Screenshot of default CentOS login prompt on x86_64 server" /></p>
<p>You can see how server calls the mingetty program by looking at <em>/etc/inittab</em>.  You will see a block like below:</p>
<p><code># Run gettys in standard runlevels<br />
1:2345:respawn:/sbin/mingetty tty1<br />
2:2345:respawn:/sbin/mingetty tty2<br />
3:2345:respawn:/sbin/mingetty tty3<br />
4:2345:respawn:/sbin/mingetty tty4<br />
5:2345:respawn:/sbin/mingetty tty5<br />
6:2345:respawn:/sbin/mingetty tty6</code></p>
<p>When <em>mingetty</em> is called, it reads a file called /etc/issue.  There are a lot of existing variables you use.  For example the prompt shown above in example is:</p>
<p><code>CentOS release 5 (Final)<br />
Kernel \r on an \m</code></p>
<p>All of the available variables are list here on this page:  <a title="man mingetty - Man page for mingetty" href="http://www.lamp-tips.com/man-pages/mingetty/" target="_blank">http://www.lamp-tips.com/man-pages/mingetty/</a></p>
<p>If you were paying attention in the beginning of the post and looked at all of the available variables you can use, you would notice there is nothing in there which talks about IP.  Since there is no variables available, you would have to sort of hack it.  Put following in your /etc/rc.local file:</p>
<p><code>echo "CentOS release 5 (Final)" &gt; /etc/issue<br />
echo "Kernel \r on an \m" &gt;&gt; /etc/issue<br />
echo `ifconfig eth0 | grep inet | cut -d : -f 2 | cut -d \  -f 1` &gt;&gt; /etc/issue</code></p>
<p>Getting an ip part can be modified to check another adapter such as eth1, eth2, etc.  Or you can get it another way if you want.  That all there is too.  <span style="text-decoration: line-through;">Reboot, and you should see your changes.</span></p>
<p>[correction 4.24.08] you do not have to reboot to see your changes.  Just press enter at the login prompt in console and it will re-read the issue file.</p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/04/22/linux-how-to-change-login-prompt-in-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL: How do you set up master-master replication in MySQL? (CentOS, RHEL, Fedora)</title>
		<link>http://crazytoon.com/2008/02/29/mysql-how-do-you-set-up-mastermaster-replication-in-mysql-centos-rhel-fedora/</link>
		<comments>http://crazytoon.com/2008/02/29/mysql-how-do-you-set-up-mastermaster-replication-in-mysql-centos-rhel-fedora/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 21:40:02 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL cluster]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2008/02/29/mysql-how-do-you-set-up-mastermaster-replication-in-mysql-centos-rhel-fedora/</guid>
		<description><![CDATA[Setting up master-master replication in MySQL is very similar to how we set up master/slave replication.  You can read up about how to setup master/slave replication in my previous post: How to set up master/slave replication in MySQL.  There is obviously pros and cons about using master/master replication.  But this is not [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up master-master replication in MySQL is very similar to how we <a href="http://crazytoon.com/2008/01/29/mysql-how-do-you-set-up-masterslave-replication-in-mysql-centos-rhel-fedora/">set up master/slave replication</a>.  You can read up about how to setup master/slave replication in my previous post: <a href="http://crazytoon.com/2008/01/29/mysql-how-do-you-set-up-masterslave-replication-in-mysql-centos-rhel-fedora/" title="How to set up master/slave replication in MySQL" target="_blank">How to set up master/slave replication in MySQL</a>.  There is obviously pros and cons about using master/master replication.  But this is not a post which discuses advantages and disadvantages for using master/master replication. One of the differences between master/master set up and master/slave is that in master/master set up, you have true redundancy.  If one server dies, second server can take all the inserts/selects.  In master/slave setup, if master dies, you will have to go through steps to make slave become the master.  Master/master set up we are going to set up is essentially master/slave and slave/master.  Meaning, if you had two servers, db0 and db1, your setup will be db0(master)/db1(slave) and also db0(slave)/db1(master).  Here are some assumptions:</p>
<p><code>Master1 server ip:  10.0.0.1<br />
Master2 server ip:  10.0.0.2<br />
Slave username:  slaveuser<br />
Slave pw:  slavepw<br />
Your data directory is:  /usr/local/mysql/var/</code></p>
<p>Let us go through the steps you must take on Master1 to enable it to act as master and slave by using following configuration which goes  under [mysqld] section:</p>
<p><code># let's make it so auto increment columns behave by having different increments on both servers<br />
auto_increment_increment=2<br />
auto_increment_offset=1<br />
# Replication Master Server<br />
# binary logging is required for replication<br />
log-bin=master1-bin<br />
binlog-ignore-db=mysql<br />
binlog-ignore-db=test<br />
# required unique id between 1 and 2^32 - 1<br />
server-id       = 1<br />
#following is the slave settings so this server can connect to master2<br />
master-host = 10.0.0.2<br />
master-user = slaveuser<br />
master-password = slavepw<br />
master-port = 3306</code></p>
<p>Following is the configuration which goes on master2 under [mysqld] section:</p>
<p><code># let's make it so auto increment columns behave by having different increments on both servers<br />
auto_increment_increment=2<br />
auto_increment_offset=2<br />
# Replication Master Server<br />
# binary logging is required for replication<br />
log-bin=master2-bin<br />
binlog-ignore-db=mysql<br />
binlog-ignore-db=test<br />
# required unique id between 1 and 2^32 - 1<br />
server-id       = 2<br />
#following is the slave settings so this server can connect to master2<br />
master-host = 10.0.0.1<br />
master-user = slaveuser<br />
master-password = slavepw<br />
master-port = 3306</code></p>
<p>On master1 server, go to mysql&gt; prompt and add the appropriate user:</p>
<p><code>mysql&gt; grant replication slave on *.* to slaveuser@'10.0.0.2' identified by 'slavepw';</code></p>
<p>On master2 server do the same but allow right ip:</p>
<p><code>mysql&gt; grant replication slave on *.* to slaveuser@'10.0.0.1' identified by 'slavepw';</code></p>
<p>Restart both of the master servers and check slave status:</p>
<p><code>mysql&gt; show slave status\G</code></p>
<p>That is all you have to do to set up the replication.  Of course there are a lot more configuration options but this should get your replication going and you can tweak from here on.</p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/02/29/mysql-how-do-you-set-up-mastermaster-replication-in-mysql-centos-rhel-fedora/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>MySQL:  How do I import individual table dump files in to MySQL using shell script?</title>
		<link>http://crazytoon.com/2007/11/28/mysql-how-do-i-import-individual-table-dump-files-in-to-mysql-using-shell-script/</link>
		<comments>http://crazytoon.com/2007/11/28/mysql-how-do-i-import-individual-table-dump-files-in-to-mysql-using-shell-script/#comments</comments>
		<pubDate>Thu, 29 Nov 2007 03:35:49 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL backup]]></category>
		<category><![CDATA[Notes for self]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/11/28/mysql-how-do-i-import-individual-table-dump-files-in-to-mysql-using-shell-script/</guid>
		<description><![CDATA[After I wrote the post: How do I dump all tables in a database into separate files? I got emails from couple people asking how to import the individual table files back in to MySQL.  First way to import each sql file created by  the post is to import each file individually by [...]]]></description>
			<content:encoded><![CDATA[<p>After I wrote the post: <a href="http://crazytoon.com/2007/11/26/mysql-how-do-i-dump-all-tables-in-a-database-into-separate-files/" rel="bookmark" title="MySQL:  How do I dump all tables in a database into separate files?">How do I dump all tables in a database into separate files?</a> I got emails from couple people asking how to import the individual table files back in to MySQL.  First way to import each sql file created by  <a href="http://crazytoon.com/2007/11/26/mysql-how-do-i-dump-all-tables-in-a-database-into-separate-files/" rel="bookmark" title="MySQL:  How do I dump all tables in a database into separate files?">the post</a> is to import each file individually by typing:<code>mysql db_name &lt; table1.sql</code>  This will work as long as you are only importing few files.  But if you need to import all of the files in the directory, which could be in 100&#8217;s, this method does not scale well.  To achieve this I wrote a shell script which does the work for me.  Of course, there are other ways to do this and I am only showing you one way of doing it.  This works for me so here it is:</p>
<p><code>#!/bin/bash<br />
db=$1<br />
if [ "$db" = "" ]; then<br />
echo "Usage: $0 db_name"<br />
exit 1<br />
fi<br />
mkdir done<br />
clear<br />
for sql_file in *.sql; do<br />
echo "Importing $sql_file";<br />
mysql $db&lt; $sql_file;<br />
mv $sql_file done;<br />
done</code></p>
<p>Related posts:</p>
<ul>
<li><a href="http://crazytoon.com/2007/11/26/mysql-how-do-i-dump-all-tables-in-a-database-into-separate-files/" title="How do I dump all tables in a database into separate files?" target="_blank">How do I dump all tables in a database into separate files?</a></li>
<li><a href="http://crazytoon.com/2007/01/23/mysql-backups-using-mysqldump/" title="MySQL backups using mysqldump" target="_blank">MySQL backups using mysqldump</a></li>
</ul>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/11/28/mysql-how-do-i-import-individual-table-dump-files-in-to-mysql-using-shell-script/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Linux:  How do I mass find and replace text in files under linux using perl?</title>
		<link>http://crazytoon.com/2007/10/29/linux-how-do-i-mass-find-and-replace-text-in-files-under-linux-using-perl/</link>
		<comments>http://crazytoon.com/2007/10/29/linux-how-do-i-mass-find-and-replace-text-in-files-under-linux-using-perl/#comments</comments>
		<pubDate>Mon, 29 Oct 2007 07:00:08 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/10/29/linux-how-do-i-mass-find-and-replace-text-in-files-under-linux-using-perl/</guid>
		<description><![CDATA[Few friends have asked me how to do mass find and replace text in files under linux.  There are quite a bit of options in linux to achieve mass replacing of text in files.  If you are doing it file by file, you can achieve that in vi by opening, running replace and [...]]]></description>
			<content:encoded><![CDATA[<p>Few friends have asked me how to do mass find and replace text in files under linux.  There are quite a bit of options in linux to achieve mass replacing of text in files.  If you are doing it file by file, you can achieve that in vi by opening, running replace and closing and going to next file.  But sometimes that can be very tedious and you would rather do mass replacement on all files containing certain extension.  We can do this by using sed or perl.  Since most people are familiar with perl (at least most system admins and programmers), I will show you a perl way of doing it which you can use with sed as well if you wish.  First step is to get perl to do what we want on one file</p>
<p><code>perl -w -i -p -e "s/search_text/replace_text/g" filename</code></p>
<p>-w turns warnings on<br />
-i  makes Perl operate on files in-place (if you would like to make backups, use -i.bak, this will save filename.bak files)<br />
-p loops over the whole input<br />
-e specifies Perl expression<br />
filename  works on one file at a time</p>
<p>Once we get the results we want, we can now pass it multiple files by doing something like:</p>
<p><code>perl -w -i -p -e "s/search_text/replace_text/g" *.php</code></p>
<p>This will search and replace within all php files in the directory you are in.</p>
<p>Now, let us say you want to go through your whole web directory and replace every place where you have &#8220;Perl is good&#8221; to &#8220;Perl is great&#8221;, you would use following command:</p>
<p><code>find /www_root -name "*.php"|xargs  perl -w -i -p -e "s/Perl is good/perl is great/g"</code></p>
<p>find will start at /www_root, look for filenames which have .php extension, xargs takes that filename and passes it to perl as an arguement.</p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/10/29/linux-how-do-i-mass-find-and-replace-text-in-files-under-linux-using-perl/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Linux virus scan:  How do I check my linux installation for viruses using ClamAV? (CentOS, Linux, Redhat)</title>
		<link>http://crazytoon.com/2007/10/19/linux-virus-scan-how-do-i-check-my-linux-installation-for-viruses-using-clamav-centos-linux-redhat/</link>
		<comments>http://crazytoon.com/2007/10/19/linux-virus-scan-how-do-i-check-my-linux-installation-for-viruses-using-clamav-centos-linux-redhat/#comments</comments>
		<pubDate>Sat, 20 Oct 2007 03:50:32 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/10/19/linux-virus-scan-how-do-i-check-my-linux-installation-for-viruses-using-clamav-centos-linux-redhat/</guid>
		<description><![CDATA[There are quite a bit of antivirus software exist for Linux nowadays.  One of the popular antivirus software is ClamAV.  We will install Clam AntiVirus software from source and install it to a custom directory.  We will also install gmp-devel package which installs GMP library.  GMP library is used to verify [...]]]></description>
			<content:encoded><![CDATA[<p>There are quite a bit of antivirus software exist for Linux nowadays.  One of the popular antivirus software is <a href="http://www.clamav.org/" title="ClamAV website" target="_blank">ClamAV</a>.  We will install Clam AntiVirus software from source and install it to a custom directory.  We will also install gmp-devel package which installs GMP library.  GMP library is used to verify the digital signature of the virus database.</p>
<p><code>yum -y install gmp-devel<br />
wget http://freshmeat.net/redir/clamav/29355/url_tgz/clamav-0.91.2.tar.gz<br />
adduser -M -s /bin/false clamav<br />
tar zxf clamav-0.91.2.tar.gz<br />
cd clamav-0.91.2<br />
./configure --prefix=/usr/local/clamav<br />
make install<br />
for binaries in `find /usr/local/clamav/bin/*` ; do ln -s ${binaries} /usr/bin/; done</code></p>
<p>At this point Clam AntiVirus is installed and ready for use.   Edit the configuration file and remove the line which says: Example  It is there to ensure.  If you want, you can look at other options but we don&#8217;t need to change anything else here to make ClamAV work for us.</p>
<p><code>vi /usr/local/clamav/etc/freshclam.conf #remove Example</code></p>
<p>Now let us run the <em>freshclam </em>which will download virus database and bring our virus database up to date.   We should do this manually and make sure it didn&#8217;t give any errors.  If this works, you will a lot of &#8220;downloading&#8221; messages.</p>
<p><code>/usr/bin/freshclam</code></p>
<p>If everything checks out, let us add this to our crontab to ensure our virus database is updated hourly.  I chose to be updated every 9 minutes in to every hour.  You can change to fit your needs or leave it as it is.<br />
<code><br />
crontab -e</code></p>
<p>9 * * * *       /usr/bin/freshclam &#8211;quiet</p>
<p>At this point our ClamAV virus database is up to date and now we can scan whichever directory we want.  Go to the directory you want to scan and type:</p>
<p><code>clamscan -r -i</code></p>
<p>Once it is done scanning, it will display something similar to below.<br />
-r parameter tells clamscan to recurse into directories<br />
-i will print out infected filenames</p>
<p><code>----------- SCAN SUMMARY -----------<br />
Known viruses: 159855<br />
Engine version: 0.91.2<br />
Scanned directories: 1437<br />
Scanned files: 8836<br />
Infected files: 0<br />
Data scanned: 464.83 MB<br />
Time: 103.678 sec (1 m 43 s)</code></p>
<p>Happy scanning!<br />
————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/10/19/linux-virus-scan-how-do-i-check-my-linux-installation-for-viruses-using-clamav-centos-linux-redhat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subversion (SVN):  How do you set up backup for your Subversion repositories?</title>
		<link>http://crazytoon.com/2007/08/16/subversion-svn-how-do-you-set-up-backup-for-your-subversion-repositories/</link>
		<comments>http://crazytoon.com/2007/08/16/subversion-svn-how-do-you-set-up-backup-for-your-subversion-repositories/#comments</comments>
		<pubDate>Fri, 17 Aug 2007 01:00:51 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/08/16/subversion-svn-how-do-you-set-up-backup-for-your-subversion-reposiotries/</guid>
		<description><![CDATA[Subversion is becoming more and more popular every day.  To get quick installation guide, see my post on installing Subversion.  Once you have Subversion set up, make sure you have backups of repository setup!  This is one of those things most people forget to do.  If you followed the installation guide [...]]]></description>
			<content:encoded><![CDATA[<p>Subversion is becoming more and more popular every day.  To get quick installation guide, see my post on <a href="http://crazytoon.com/2007/06/01/subversion-how-do-you-install-and-set-up-subversion-for-revision-control/" title="How do you install Subversion?">installing Subversion</a>.  Once you have Subversion set up, make sure you have backups of repository setup!  This is one of those things most people forget to do.  If you followed the installation guide and did source install, you already have a tool available to you.  You can find <span><strong class="command">hot-backup.py </strong></span>tool in the         <tt class="filename">tools/backup/</tt> directory of the Subversion         source distribution.   One thing about this script is that it doesn&#8217;t backup all your repositories.  Which might be an issue if you create more repositories but forget to create a script to backup that particular repository.  Here is a very simple shell script to help you backup all of your subversion repositories.  You can edit it to point to different /svn location if you didn&#8217;t install to default location.  Make sure you copy hot-backup.py to a location which is included in your path so your scripts will work.</p>
<p><code>mkdir /backups/repos -p<br />
for repostobackup in `ls /svn/` ; do<br />
filename=`basename ${repostobackup}`<br />
if [ ! $filename = "" ]; then<br />
hot-backup.py --archive-type=bz2 /svn/${filename} /backups/repos<br />
fi<br />
done</code></p>
<p>This will create your backup files and compress them using bzip2.  You can also use zip or gz if you prefer.  Another thing you should do is to edit the hot-backup.py script and change num_backups to be whatever you think is a good number.  I personally use:  num_backups = 10</p>
<p>That&#8217;s all there is to it.  Just add this script to your crons and your backups will be automated.  You may want to consider moving your backups to another server by adding ftp, scp or rsync at the end of the script.</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/08/16/subversion-svn-how-do-you-set-up-backup-for-your-subversion-repositories/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Cron:  crond will not read/honor new entries in crontab file. (CentOS, Redhat, Fedora)</title>
		<link>http://crazytoon.com/2007/08/16/cron-crond-will-not-readhonor-new-entries-in-crontab-file-centos-redhat-fedora/</link>
		<comments>http://crazytoon.com/2007/08/16/cron-crond-will-not-readhonor-new-entries-in-crontab-file-centos-redhat-fedora/#comments</comments>
		<pubDate>Thu, 16 Aug 2007 21:15:59 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/08/16/cron-crond-will-not-readhonor-new-entries-in-crontab-file-centos-redhat-fedora/</guid>
		<description><![CDATA[I ran in to something really odd.  I have been using crontab for LONG time and never seen this issue before.  Basically I added new entry into my crontab by type crontab -e and as always saved/exited.  For some reason that command never ran at the time I specified.  I tested [...]]]></description>
			<content:encoded><![CDATA[<p>I ran in to something really odd.  I have been using crontab for LONG time and never seen this issue before.  Basically I added new entry into my crontab by type <code>crontab -e</code> and as always saved/exited.  For some reason that command never ran at the time I specified.  I tested few more times and no luck.  So I started looking on google to find out why crond will not ready my new entries from crontab.  And then while I was looking, I decided to restart crond by issuing:  service crond restart  and to my surprise, my new schedule started working.</p>
<p>While I was looking around for solution for this problem on Google, I came upon few pages where they talked about if you have empty line before command, that command will not work.  For example:</p>
<p><code>#this is a cron file</code></p>
<p><code>* * * * * /do/something</code></p>
<p>In this example, /do/something will not run since there is a blank line before it.  You can fix this by moving that command up or put another comment above it.  This is a very odd thing and I have never experienced it myself but I figured if you stumble upon this post looking for help, blank line before command in crontab might be your issue.  Please comment if you had to delete a blank line to fix your crontab file.  Also mention which OS you are using.  To learn more about crond, see <a href="http://www.lamp-tips.com/man-pages/crond/" title="man crond - man page for crond" target="_blank">man crond</a> and <a href="http://www.lamp-tips.com/man-pages/crontab/" title="man crontab - man page for crontab" target="_blank">man crontab</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/08/16/cron-crond-will-not-readhonor-new-entries-in-crontab-file-centos-redhat-fedora/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SSH:  Getting error ssh_exchange_identification: Connection closed by remote host</title>
		<link>http://crazytoon.com/2007/08/05/ssh-getting-error-ssh_exchange_identification-connection-closed-by-remote-host/</link>
		<comments>http://crazytoon.com/2007/08/05/ssh-getting-error-ssh_exchange_identification-connection-closed-by-remote-host/#comments</comments>
		<pubDate>Sun, 05 Aug 2007 09:37:37 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/08/05/ssh-getting-error-ssh_exchange_identification-connection-closed-by-remote-host/</guid>
		<description><![CDATA[Today I was working on setting up public key authentication over SSH on few servers I inherited recently.  I have done this many times and never ran in to following error:
ssh_exchange_identification: Connection closed by remote host
After doing further research on the server I was trying to connect to (looking at logs) I noticed the server [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was working on setting up <a href="http://crazytoon.com/2007/08/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/" title="Public key authentication over SSH">public key authentication over SSH</a> on few servers I inherited recently.  I have done this many times and never ran in to following error:</p>
<p>ssh_exchange_identification: Connection closed by remote host</p>
<p>After doing further research on the server I was trying to connect to (looking at logs) I noticed the server was denying connection based on ip.  I put my servers ip in /etc/hosts.allow and tried again.  This time I was connected without any problems.  Note that you do not have to restart SSH for hosts.allow change to take affect.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/08/05/ssh-getting-error-ssh_exchange_identification-connection-closed-by-remote-host/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SSH:  Setting up public key authentication over SSH (CentOS, Redhat, Linux, Fedora)</title>
		<link>http://crazytoon.com/2007/08/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/</link>
		<comments>http://crazytoon.com/2007/08/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/#comments</comments>
		<pubDate>Sun, 05 Aug 2007 09:10:47 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/08/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/</guid>
		<description><![CDATA[Before we go in to details on how to set up public key authentication, I would like to talk about pros and cons about doing this.  After you know the pros and cons, you can make an educated decision.  First, let us talk about biggest benefit about setting up public key authentication over [...]]]></description>
			<content:encoded><![CDATA[<p>Before we go in to details on how to set up public key authentication, I would like to talk about pros and cons about doing this.  After you know the pros and cons, you can make an educated decision.  First, let us talk about biggest benefit about setting up public key authentication over ssh.  Once you set up the keys correctly, you will not need to enter password to access the other server.  For example, you can just type <code>ssh example.com</code> and you will be logged in.  This is the method you must use if you want to set up scripts which are run from crontab.  For example, you may have rsync script running which does backups from one server to another every night.  With every good thing, comes a bad thing.  So let us say &#8220;somebody&#8221; has access to server1 as root.  This somebody could be designated user or it could be a hacker who has gain root access to server1.  Now since we have public key authentication over ssh setup between server1 and server2, this &#8220;somebody&#8221; now can access server2.  As you can see, this can be a problematic.   Now you know number one pro and con about setting up public key authentication over ssh.  Let us now go on and actually go through process to setup keys.</p>
<p>On server1, you type:   <code>ssh-keygen -t rsa</code> (just press enter to keep accepting defaults).  You should see something like this:</p>
<p><code>ssh-keygen -t rsa<br />
Generating public/private rsa key pair.<br />
Enter file in which to save the key (/root/.ssh/id_rsa):<br />
Created directory '/root/.ssh'.<br />
Enter passphrase (empty for no passphrase):<br />
Enter same passphrase again:<br />
Your identification has been saved in /root/.ssh/id_rsa.<br />
Your public key has been saved in /root/.ssh/id_rsa.pub.<br />
The key fingerprint is:<br />
a2:b2:aw:w2:63:25:2a:62:fs:d5:ff:fd:11:f1:aa:60 root@server1</code></p>
<p>Fingerprint for your server will be different.  Now <code>cat /root/.ssh/id_rsa.pub</code> Copy the contents it displays.  You will need this for server2.  Paste it into notepad or any other text editor and make sure it pastes as one line.  This is very crucial you check this.</p>
<p>Now login to server2.  Create the public key by typing:  <code>ssh-keygen -t rsa</code> (this is same thing we did on server1).  Once you are done, type <code>vi /root/.ssh/authorized_keys2</code></p>
<p>Paste the content you copied earlier on server1.  Make sure it is all on one line.  Save/exit.   At this point, we should change the permissions on the file to make sure sshd likes it:  <code>chmod 600 /root/.ssh/authorized_keys2 </code></p>
<p>Go back to server1 and type ssh server2  You should be logged in with out having to put in a password.  If you are prompted for password still, check server2 /root/.ssh/authorized_keys2 file and make sure everything you pasted is one line.</p>
<p>That is all you have to do set up public key authentication over ssh!</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/08/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Bind:  Quick install guide to install and setup Bind (DNS server) in secure (chroot) environment in Linux (CentOS, Redhat Enterprise (RHEL), Fedora).</title>
		<link>http://crazytoon.com/2007/06/21/bind-quick-install-guide-to-install-and-setup-bind-dns-server-in-secure-chroot-environment-in-linux-centos-redhat-enterprise-rhel-fedora/</link>
		<comments>http://crazytoon.com/2007/06/21/bind-quick-install-guide-to-install-and-setup-bind-dns-server-in-secure-chroot-environment-in-linux-centos-redhat-enterprise-rhel-fedora/#comments</comments>
		<pubDate>Fri, 22 Jun 2007 06:55:02 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/06/21/bind-quick-install-guide-to-install-and-setup-bind-dns-server-in-secure-chroot-environment-in-linux-centos-redhat-enterprise-rhel-fedora/</guid>
		<description><![CDATA[There are a lot of great articles on setting up Bind and some of them even go in great details on setting up secure DNS server using Bind.  I have used one them time after time called:  Linux Howto:  Chroot Bind How To.  One of the things I do not like [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of great articles on setting up Bind and some of them even go in great details on setting up secure DNS server using Bind.  I have used one them time after time called:  Linux Howto:  <a href="http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html" title="Chroot Bind How To" target="_blank">Chroot Bind How To</a>.  One of the things I do not like about it is that I had to read over things which I really do not need to know or already know.  So I have put together this quick wow To based on this great how to.  Setting up secure DNS server using bind is not very complicated.</p>
<p>Let us dive into this.  First we create user and set up directory structure.</p>
<p><code>echo "named:x:200:200:Nameserver:/chroot/named:/bin/false" &gt;&gt; /etc/passwd<br />
echo "named:x:200:" &gt;&gt; /etc/group<br />
mkdir -p /chroot/named<br />
cd /chroot/named<br />
mkdir -p dev etc/namedb/slave var/run<br />
chown -R named:named /chroot/named/etc/namedb/slave<br />
chown named:named /chroot/named/var/run<br />
mknod /chroot/named/dev/null c 1 3<br />
mknod /chroot/named/dev/random c 1 8<br />
chmod 666 /chroot/named/dev/{null,random}<br />
cp /etc/localtime /chroot/named/etc/</code></p>
<p><code>vi /etc/sysconfig/syslog</code><br />
edit the line which starts with SYSLOGD_OPTIONS and edit it to look like: SYSLOGD_OPTIONS=&#8221;-m 0 -a /chroot/named/dev/log&#8221;<br />
Let us restart syslog to use new settings and let us secure the physical files on the server.</p>
<p><code>/etc/rc.d/init.d/syslog stop<br />
/etc/rc.d/init.d/syslog start<br />
chown root /chroot<br />
chmod 700 /chroot<br />
chown named:named /chroot/named<br />
chmod 700 /chroot/named<br />
cd /chroot/named<br />
chattr +i etc/localtime var</code></p>
<p>Let us clean up previous bind install since most linux installations have named (bind)  pre-installed.<br />
<code><br />
rpm -qa |grep bind<br />
rpm -e --nodeps &lt;copy-paste-all-the-packages-separated-by-space&gt;</code></p>
<p>Let us get the source files for bind and install it.  At time of writing, bind 9.4.1 is the latest.</p>
<p><code>wget http://ftp.isc.org/isc/bind9/9.4.1/bind-9.4.1.tar.gz<br />
tar zxpfv bind-*.gz<br />
cd bind*<br />
./configure<br />
make &amp;&amp; make install</code></p>
<p>copy following content to <code>/etc/init.d/named</code></p>
<p><code>#!/bin/sh<br />
#<br />
# named           This shell script takes care of starting and stopping<br />
#                 named (BIND DNS server).<br />
#<br />
# chkconfig: 345 55 45<br />
# description: named (BIND) is a Domain Name Server (DNS) \<br />
# that is used to resolve host names to IP addresses.<br />
# probe: true<br />
#<br />
# Source function library.<br />
. /etc/rc.d/init.d/functions<br />
#<br />
# Source networking configuration.<br />
. /etc/sysconfig/network<br />
#<br />
# Check that networking is up.<br />
[ ${NETWORKING} = "no" ] &amp;&amp; exit 0<br />
#<br />
[ -f /usr/local/sbin/named ] || exit 0<br />
[ -f /chroot/named/etc/named.conf ] || exit 0<br />
#<br />
# See how we were called.<br />
case "$1" in<br />
start)<br />
# Start daemons.<br />
echo -n "Starting named: "<br />
daemon /usr/local/sbin/named -u named -t /chroot/named -c /etc/named.conf<br />
echo<br />
touch /var/lock/subsys/named<br />
;;<br />
stop)<br />
# Stop daemons.<br />
echo -n "Shutting down named: "<br />
kill `pidof named`<br />
echo<br />
rm -f /var/lock/subsys/named<br />
;;<br />
status)<br />
status named<br />
exit $?<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
exit $?<br />
;;<br />
reload)<br />
/usr/local/sbin/rndc reload<br />
exit $?<br />
;;<br />
probe)<br />
# named knows how to reload intelligently; we don't want linuxconf<br />
# to offer to restart every time<br />
/usr/local/sbin/rndc reload &gt;/dev/null 2&gt;&amp;1 || echo start<br />
exit 0<br />
;;<br />
#<br />
*)<br />
echo "Usage: named {start|stop|status|restart|reload}"<br />
exit 1<br />
esac<br />
#<br />
exit 0</code></p>
<p>Make it executable:  <code>chmod +x /etc/init.d/named</code><br />
Let us set it so &#8220;named&#8221; will automatically start at boot up:  <code>chkconfig --add named</code></p>
<p>Save follow code into <code>/chroot/named/etc/named.conf</code><br />
<code>options {<br />
recursion no; // this will disable lookups against our server recursion no;<br />
directory "/etc/namedb"; // Working directory<br />
pid-file "/var/run/named.pid"; // Put pid file in working dir<br />
forwarders {<br />
10.10.10.10; //ip of dns server to forward requests to<br />
};<br />
statistics-file "/var/run/named.stats";<br />
query-source address * port 53;<br />
version "Bind 10";<br />
};<br />
controls {<br />
inet 127.0.0.1 port 953<br />
allow { 127.0.0.1; } keys { "rndc-key"; };<br />
};<br />
// Root server hints<br />
zone "." {<br />
type hint;<br />
file "root.hint";<br />
};<br />
// Provide a reverse mapping for the loopback address 127.0.0.1<br />
zone "0.0.127.in-addr.arpa" {<br />
type master;<br />
file "db.127.0.0";<br />
notify no;<br />
};</code></p>
<p>Save following in /chroot/named/etc/namedb/root.hint</p>
<p><code>;       This file holds the information on root name servers needed to<br />
;       initialize cache of Internet domain name servers<br />
;       (e.g. reference this file in the "cache  .  &lt;file&gt;"<br />
;       configuration file of BIND domain name servers).<br />
;<br />
;       This file is made available by InterNIC<br />
;       under anonymous FTP as<br />
;           file                /domain/named.root<br />
;           on server           FTP.INTERNIC.NET<br />
;<br />
;       last update:    Nov 5, 2002<br />
;       related version of root zone:   2002110501<br />
;<br />
;<br />
; formerly NS.INTERNIC.NET<br />
;<br />
.                        3600000  IN  NS    A.ROOT-SERVERS.NET.<br />
A.ROOT-SERVERS.NET.      3600000      A     198.41.0.4<br />
;<br />
; formerly NS1.ISI.EDU<br />
;<br />
.                        3600000      NS    B.ROOT-SERVERS.NET.<br />
B.ROOT-SERVERS.NET.      3600000      A     128.9.0.107<br />
;<br />
; formerly C.PSI.NET<br />
;<br />
.                        3600000      NS    C.ROOT-SERVERS.NET.<br />
C.ROOT-SERVERS.NET.      3600000      A     192.33.4.12<br />
;<br />
; formerly TERP.UMD.EDU<br />
;<br />
.                        3600000      NS    D.ROOT-SERVERS.NET.<br />
D.ROOT-SERVERS.NET.      3600000      A     128.8.10.90<br />
;<br />
; formerly NS.NASA.GOV<br />
;<br />
.                        3600000      NS    E.ROOT-SERVERS.NET.<br />
E.ROOT-SERVERS.NET.      3600000      A     192.203.230.10<br />
;<br />
; formerly NS.ISC.ORG<br />
;<br />
.                        3600000      NS    F.ROOT-SERVERS.NET.<br />
F.ROOT-SERVERS.NET.      3600000      A     192.5.5.241<br />
;<br />
; formerly NS.NIC.DDN.MIL<br />
;<br />
.                        3600000      NS    G.ROOT-SERVERS.NET.<br />
G.ROOT-SERVERS.NET.      3600000      A     192.112.36.4<br />
;<br />
; formerly AOS.ARL.ARMY.MIL<br />
;<br />
.                        3600000      NS    H.ROOT-SERVERS.NET.<br />
H.ROOT-SERVERS.NET.      3600000      A     128.63.2.53<br />
;<br />
; formerly NIC.NORDU.NET<br />
;<br />
.                        3600000      NS    I.ROOT-SERVERS.NET.<br />
I.ROOT-SERVERS.NET.      3600000      A     192.36.148.17<br />
;<br />
; operated by VeriSign, Inc.<br />
;<br />
.                        3600000      NS    J.ROOT-SERVERS.NET.<br />
J.ROOT-SERVERS.NET.      3600000      A     192.58.128.30<br />
;<br />
; housed in LINX, operated by RIPE NCC<br />
;<br />
.                        3600000      NS    K.ROOT-SERVERS.NET.<br />
K.ROOT-SERVERS.NET.      3600000      A     193.0.14.129<br />
;<br />
; operated by IANA<br />
;<br />
.                        3600000      NS    L.ROOT-SERVERS.NET.<br />
L.ROOT-SERVERS.NET.      3600000      A     198.32.64.12<br />
;<br />
; housed in Japan, operated by WIDE<br />
;<br />
.                        3600000      NS    M.ROOT-SERVERS.NET.<br />
M.ROOT-SERVERS.NET.      3600000      A     202.12.27.33<br />
; End of File</code></p>
<p>This should get you started.  Now just create appropriate zone files and you are good to go.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/06/21/bind-quick-install-guide-to-install-and-setup-bind-dns-server-in-secure-chroot-environment-in-linux-centos-redhat-enterprise-rhel-fedora/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Ramdisk:  How do you install and set up Ramdisk under Linux (CentOS, RHEL, Fedora)?</title>
		<link>http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/</link>
		<comments>http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 23:36:21 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[Server load]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/</guid>
		<description><![CDATA[Ramdisk is very good to have if you want something to stay in memory.   Files in memory makes it so you can access them with out having to access hard drive all the time.  Perfect candidates would be things which do not change eg. web images or downloadable files, etc.  If you have Linux Kernel [...]]]></description>
			<content:encoded><![CDATA[<p>Ramdisk is very good to have if you want something to stay in memory.   Files in memory makes it so you can access them with out having to access hard drive all the time.  Perfect candidates would be things which do not change eg. web images or downloadable files, etc.  If you have Linux Kernel 2.4 or later, you already have support of ramdisk built in.  You can check if ramdisk is setup by doing: </p>
<p><code># dmesg | grep RAMDISK<br />
RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize</code></p>
<p>You should get above output on CentOS and RHEL.  Other linux flavors will have similar output as well.  If you would like to see how they are named and what you would need to refer to, do the following:</p>
<p><code># ls -l /dev/ram*<br />
lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ram -&gt; ram1<br />
brw-rw---- 1 root disk 1, 0 Apr 24 12:05 /dev/ram0<br />
brw-rw---- 1 root disk 1, 1 Apr 24 12:05 /dev/ram1<br />
brw-rw---- 1 root disk 1, 10 Apr 24 12:05 /dev/ram10<br />
brw-rw---- 1 root disk 1, 11 Apr 24 12:05 /dev/ram11<br />
brw-rw---- 1 root disk 1, 12 Apr 24 12:05 /dev/ram12<br />
brw-rw---- 1 root disk 1, 13 Apr 24 12:05 /dev/ram13<br />
brw-rw---- 1 root disk 1, 14 Apr 24 12:05 /dev/ram14<br />
brw-rw---- 1 root disk 1, 15 Apr 24 12:05 /dev/ram15<br />
brw-rw---- 1 root disk 1, 2 Apr 24 12:05 /dev/ram2<br />
brw-rw---- 1 root disk 1, 3 Apr 24 12:05 /dev/ram3<br />
brw-rw---- 1 root disk 1, 4 Apr 24 12:05 /dev/ram4<br />
brw-rw---- 1 root disk 1, 5 Apr 24 12:05 /dev/ram5<br />
brw-rw---- 1 root disk 1, 6 Apr 24 12:05 /dev/ram6<br />
brw-rw---- 1 root disk 1, 7 Apr 24 12:05 /dev/ram7<br />
brw-rw---- 1 root disk 1, 8 Apr 24 12:05 /dev/ram8<br />
brw-rw---- 1 root disk 1, 9 Apr 24 12:05 /dev/ram9<br />
lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ramdisk -&gt; ram0</code></p>
<p>All those ramdisks listed have same size.  In above example, they are all 16MB.  Let us change that so we have more space allowed.  Note that I say allowed and not allocated.  We allocate space in one of the later steps by formatting one of the drives above.   Let us set it up so we have 128 MB.  Since this has to be in multiples of 1024, we will setup Ramdisk to have 131072K. </p>
<p><code>vi /etc/grub.conf</code></p>
<p>Find first line which looks similar to following:</p>
<p><code>kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00</code></p>
<p>add ramdisk_size=131072 to the end of the line.  Now your line should look like:</p>
<p><code>kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00 <strong>ramdisk_size=131072</strong></code><strong> </strong>Save and exit grub.conf.  At this point you have it configured to have ramdisk with new size but it does not take effect until you reboot your system.  Once you have rebooted your system, we can start doing rest of configurations.</p>
<p><code>mke2fs -m 0 /dev/ram0</code></p>
<p>This will format the ram0 ramdrive for us to use. At this point, kernel will allocate space for you.  Let us setup Ramdisk mount point so we can use it.  We will also have it be owned by user &#8220;sunny&#8221; so that user can read/write to that mount.</p>
<p><code>mkdir /home/ramdisk<br />
mount /dev/ram0 /home/ramdisk<br />
chown sunny.sunny /home/ramdisk</code></p>
<p>At this point you should be able to type:  <strong>mount </strong>and see your new Ramdisk drive mounted on /home/ramdisk</p>
<p>Remember that everything you put on this drive will be gone if you reboot your server.  If you unmounted the Ramdisk drive and remounted it, your files will still be there.  It is because your system has that much ram set aside for your Ramdisk and will not use it for anything else.   If you would like to setup Ramdisk the same next time you boot up, add these lines to your /etc/rc.local files.</p>
<p><code>mke2fs -m 0 /dev/ram0<br />
mount /dev/ram0 /home/ramdisk<br />
chown sunny.sunny /home/ramdisk</code></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subversion:  How do you install and set up Subversion for revision control?</title>
		<link>http://crazytoon.com/2007/06/01/subversion-how-do-you-install-and-set-up-subversion-for-revision-control/</link>
		<comments>http://crazytoon.com/2007/06/01/subversion-how-do-you-install-and-set-up-subversion-for-revision-control/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 20:32:24 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/06/01/subversion-how-do-you-install-and-set-up-subversion-for-revision-control/</guid>
		<description><![CDATA[Code revision control is very crucial part of development.  It ensures you know who has changed which files and you are able to rollback to older versions in case new changes are breaking your website page or entire project.  There are few options for you if you are looking into setting up code revision control.  My preferred [...]]]></description>
			<content:encoded><![CDATA[<p>Code revision control is very crucial part of development.  It ensures you know who has changed which files and you are able to rollback to older versions in case new changes are breaking your website page or entire project.  There are few options for you if you are looking into setting up code revision control.  My preferred option is Subversion.  <a target="_blank" href="http://subversion.tigris.org/" title="Subversion: An open-source revision control system.">Subversion</a> is an open-source revision control system which is becoming more and more popular every day.  It is very easy to install and setup your project under Subversion.  If you want detailed instructions, please see the <a target="_blank" href="http://svnbook.org/" title="Subversion Book">Subversion Book</a>.  They do a great job explaining what revision control is, what are the different types of revision control are out there, detailed instructions on installing subversion, doing administrator tasks, etc.  Here are instructions on how to set up Subversion under CentOS.  Same instructions apply to most linux distributions. </p>
<p><strong>YUM Install</strong> </p>
<p>Easiest way to install subversion is via &#8220;yum&#8221; by typing:</p>
<p><code>yum install subversion</code></p>
<p>Once install is done, confirm it by typing &#8220;svn&#8221; at the prompt and you should get:</p>
<p><code>Type 'svn help' for usage.</code></p>
<p>At this point you can skip to &#8220;Setting up Subversion repository&#8221; part.</p>
<p><strong>SOURCE Install</strong></p>
<p>Obtain source from:  <a target="_blank" href="http://subversion.tigris.org/" title="Subversion: An open-source revision control system.">Subversion</a>.  At the time of writing, latest (1.4.3) version can be obtain from this link:  <a href="http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gz">http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gz</a></p>
<p><code>tar zxf subversion*<br />
cd subversion*<br />
./configure<br />
make &amp;&amp; make install</code></p>
<p>after everything goes well, type svn at the prompt and you should get:</p>
<p><code>Type 'svn help' for usage.</code></p>
<p><strong>Setting up Subversion repository</strong></p>
<p><code>adduser svnusers<br />
mkdir repos/branches -p<br />
mkdir repos/trunk -p<br />
mkdir repos/tags -p<br />
mkdir /svn<br />
svnadmin create /svn/demorepo<br />
svn import --message "Initial set up" repos <a href="file:///svn/demorepo">file:///svn/demorepo</a><br />
cd /svn/demorepo<br />
chown .svnusers . -R<br />
chmod 775 * -R<br />
chmod +s db</code></p>
<p>Thats all there is to it to setup Subversion repository.  At this point, you should <em>add any users</em> you want to have access to the repository by adding them to &#8220;svnusers&#8221; group.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/06/01/subversion-how-do-you-install-and-set-up-subversion-for-revision-control/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apache:  How do you set up log rotation and archiving for Apache logs?</title>
		<link>http://crazytoon.com/2007/05/31/apache-how-do-you-set-up-log-rotation-and-archiving-for-apache-logs/</link>
		<comments>http://crazytoon.com/2007/05/31/apache-how-do-you-set-up-log-rotation-and-archiving-for-apache-logs/#comments</comments>
		<pubDate>Thu, 31 May 2007 23:53:39 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Data Backup]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/05/31/apache-how-do-you-set-up-log-rotation-and-archiving-for-apache-logs/</guid>
		<description><![CDATA[If you have a website and never have archived your apache logs, you may be surprised one day by running out of space due to logs using up all the free space on specific partition. Most people don&#8217;t think about archiving until it is too late. Here we set up a simple log rotation script [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a website and never have archived your apache logs, you may be surprised one day by running out of space due to logs using up all the free space on specific partition. Most people don&#8217;t think about archiving until it is too late. Here we set up a simple log rotation script which will work for apache 1.x and also for apache 2.x version as well. I have included comments in the script itself to help you understand what is going on throughout.</p>
<p><code>#!/bin/sh<br />
#<br />
# Created by:  Sunny Walia<br />
# Date created:  5/24/03<br />
# Date Modified:  5/29/07<br />
# Purpose:  do any type of preprocessing before log.php can do its work.<br />
#           Also does log rotation and backup.<br />
#<br />
# Modification history:<br />
#   5/25/03:    added comments.<br />
#               Gzip and move to backup logs folder<br />
#               added config info on top<br />
#<br />
#<br />
# configuration info<br />
SERVERNAME="svr1"<br />
WORKINGDIR="/admin/backups/$SERVERNAME/logs/"<br />
BACKUPLOGSDIR="/admin/backups/$SERVERNAME/logs/archived/"<br />
BACKUP_DIR="/admin/backups/$SERVERNAME/"<br />
LOGDIR="/usr/local/apache2/logs/"<br />
DATE=`date +%m%d%y%H`<br />
APACHCTL_LOC="/usr/local/apache2/bin/"<br />
#<br />
mkdir $WORKINGDIR -p<br />
mkdir $BACKUPLOGSDIR -p<br />
mkdir $BACKUP_DIR -p<br />
#<br />
# move the logs into their temp name so apache can continue to write to it<br />
mv ${LOGDIR}access_log ${LOGDIR}${SERVERNAME}_access_log.old<br />
mv ${LOGDIR}error_log ${LOGDIR}${SERVERNAME}_error_log.old<br />
#<br />
# restart apache gracefully so it will finish what its doing and start a new log file<br />
# when done serving current requests<br />
${APACHCTL_LOC}apachectl graceful<br />
#<br />
# give some time to apache to finish serving pending requests (in secs)<br />
sleep 15<br />
#<br />
# copy the files to our directory for processing<br />
cp ${LOGDIR}${SERVERNAME}_access_log.old ${WORKINGDIR}${SERVERNAME}_access_log<br />
cp ${LOGDIR}${SERVERNAME}_error_log.old ${WORKINGDIR}${SERVERNAME}_error_log<br />
#<br />
mv ${LOGDIR}${SERVERNAME}_access_log.old ${LOGDIR}${SERVERNAME}_access_log.$DATE<br />
mv ${LOGDIR}${SERVERNAME}_error_log.old ${LOGDIR}${SERVERNAME}_error_log.$DATE<br />
gzip ${LOGDIR}${SERVERNAME}_access_log.$DATE<br />
gzip ${LOGDIR}${SERVERNAME}_error_log.$DATE<br />
#<br />
# we move instead of copy than delete since if mv fails, we still have originals<br />
# mv can fail if target location is full<br />
mv ${LOGDIR}${SERVERNAME}_access_log.$DATE.gz $BACKUPLOGSDIR<br />
mv ${LOGDIR}${SERVERNAME}_error_log.$DATE.gz $BACKUPLOGSDIR<br />
</code></p>
<p>Let us make the script executable:<br />
<code>chmod +x  script_name.sh</code></p>
<p>You can automate this to happen every day by putting it in your crontab:<br />
<code>crontab -e</code></p>
<p><code>1 0 * * * /path/to/this/script</code></p>
<p>This will rotate your logs at 12:01 AM every day.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/05/31/apache-how-do-you-set-up-log-rotation-and-archiving-for-apache-logs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rsync:  Using rsync to backup data from one server to another over SSH.  Quick rsync tutorial.</title>
		<link>http://crazytoon.com/2007/05/24/rsync-using-rsync-to-backup-data-from-one-server-to-another-over-ssh-quick-rsync-tutorial/</link>
		<comments>http://crazytoon.com/2007/05/24/rsync-using-rsync-to-backup-data-from-one-server-to-another-over-ssh-quick-rsync-tutorial/#comments</comments>
		<pubDate>Thu, 24 May 2007 22:30:05 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Data Backup]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[Windows System]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/05/24/rsync-using-rsync-to-backup-data-from-one-server-to-another-over-ssh-quick-rsync-tutorial/</guid>
		<description><![CDATA[Rsync is a great tool which can be used to do many tasks which involved copying/moving data.  If privacy/security is of concern, which it always should be, you can use rsync to do all the copying/moving of data over SSH.  Read through &#8220;man rsync&#8221; to get deeper understanding of rsync.  Here is [...]]]></description>
			<content:encoded><![CDATA[<p>Rsync is a great tool which can be used to do many tasks which involved copying/moving data.  If privacy/security is of concern, which it always should be, you can use rsync to do all the copying/moving of data over SSH.  Read through &#8220;man rsync&#8221; to get deeper understanding of rsync.  Here is my attempt to a short <strong>tutorial on rsync</strong>.   Let us start with most simple example of using rsync over ssh.</p>
<p><code> rsync -ae ssh server1:/home /home/backups/server1_home_backup/</code></p>
<p>This command will download all the files/directories from /home on server1 and copies them to /home/backups/server1_home_backup/<br />
-a = archive mode.  This will preserve permissions, timestamps, etc.<br />
-e = specify which remote shell to use.  In our case, we want to use ssh which follow right after  &#8220;e&#8221;</p>
<p>Let us improve on this and add couple more parameters:</p>
<p><code>rsync -zave ssh --progress server1:/home /home/backups/server1_home_backup/</code><br />
-z = adds zip compression.<br />
-v = verbose<br />
&#8211;progress = my favorite parameter when I am doing rsync manually, not so good when you have it in cron.  This show progress (how_many_files_left/how_many_files_total) and speed along with some other useful data.</p>
<p>Great.. we are moving along pretty good.  Let us add some security to make sure things work the way we want to.</p>
<p><code>rsync --delete-after -zave ssh --progress server1:/home /home/backups/server1_home_backup/</code></p>
<p>&#8211;delete-after = this will delete files on backup server which are missing from source <em>after</em> ALL syncing is done.  If you don&#8217;t care of having extra files on your backup server and have plenty of disk space to spare, do not use this parameter.</p>
<p>Lastly, one of the VERY handy parameters,</p>
<p><code>rsync --delete-after -zave ssh --progress server1:/home /home/backups/server1_home_backup/ -n</code></p>
<p>The -n (or &#8211;dry-run) parameter is great to use for testing.  It will not transfer or delete any files, rather will report to you what it would have done if it was ran with out -n parameter.  This way you can test it with out destroying or transfering data just to find out that is not what you wanted.</p>
<p>For further reading:  <a href="http://www.lamp-tips.com/man-pages/rsync/" title="man rsync - man page for rsync" target="_blank">man rsync</a></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/05/24/rsync-using-rsync-to-backup-data-from-one-server-to-another-over-ssh-quick-rsync-tutorial/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Samba: How do you install and set up Samba in linux? [Redhat Enterprise(RHEL), CentOS, Fedora]</title>
		<link>http://crazytoon.com/2007/05/22/samba-how-do-you-install-and-set-up-samba-in-linux-redhat-enterpriserhel-centos-fedora/</link>
		<comments>http://crazytoon.com/2007/05/22/samba-how-do-you-install-and-set-up-samba-in-linux-redhat-enterpriserhel-centos-fedora/#comments</comments>
		<pubDate>Tue, 22 May 2007 19:38:59 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[Samba]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/05/22/samba-how-do-you-install-and-set-up-samba-in-linux-redhat-enterpriserhel-centos-fedora/</guid>
		<description><![CDATA[Setting up Samba &#8220;can&#8221; be complicated at times.  Especially if you are looking for instructions online where there are WAY too many tutorials which go in to details about what configuration does what, etc.  Well, this post is nothing like that.  Here I just show you quick and easy way to install [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up Samba &#8220;can&#8221; be complicated at times.  Especially if you are looking for instructions online where there are WAY too many tutorials which go in to details about what configuration does what, etc.  Well, this post is nothing like that.  Here I just show you quick and easy way to install Samba, configure it, and set up the drive letter on your XP/Vista.  NOTE:  for using Samba with Vista, please see my previous post in which I talk about changing settings in Vista so you can connect to your Samba share:  <a href="http://crazytoon.com/2007/02/05/windows-vista-installation-update-2/" title="Fix Samba drive mapping issue">Windows Vista Installation</a></p>
<p>NOTE:  This set up is very &#8220;open&#8221;  and should not be used on servers which are facing the world.  This is for private network where you trust all the computers and its users.</p>
<p>Installing Samba (using yum on CentOS and Fedora):  yum install samba<br />
Installing Samba (using rpm):</p>
<ol>
<li>Obtain Samba rpm from rhn.redhat.com</li>
<li>rpm -ivh samba*.rpm</li>
</ol>
<p>Configuring Samba:<br />
<code>cd /etc/samba<br />
mv smb.conf smb.conf.backup<br />
vi smb.conf</code></p>
<p>Paste content below in to your vi:</p>
<p><code>[global]<br />
workgroup = wrkgrp<br />
netbios name = smbserver<br />
security = SHARE<br />
load printers = No<br />
default service = global<br />
path = /home<br />
available = No<br />
encrypt passwords = yes<br />
[share]<br />
writeable = yes<br />
admin users = smbuser<br />
path = /home/share<br />
force user = root<br />
valid users = smbuser<br />
public = yes<br />
available = yes</code></p>
<p>save and exit</p>
<p><code>adduser smbuser       #add unix account<br />
passwd smbuser          #set unix account password<br />
smbpasswd -a smbuser #lets create same user account on samba<br />
&lt;put same password as your unix account password&gt;<br />
/etc/init.d/smb restart</code></p>
<p>Now let us setup drive letter on our Windows so we can easily access these files.</p>
<p>Start -&gt; run -&gt; cmd &lt;enter&gt;</p>
<p>At the prompt type:  net use z: \\ip_of_your_samba_server\share /user: smbuser password_you_assigned</p>
<p>That is it!  At this point you have successfully set up Samba under Linux and are now successfully connected to your share from your Windows machine.</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/05/22/samba-how-do-you-install-and-set-up-samba-in-linux-redhat-enterpriserhel-centos-fedora/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Perl:  How do I install Perl modules? eg. Installing LWP module for Perl.</title>
		<link>http://crazytoon.com/2007/05/21/perl-how-do-i-install-perl-modules-eg-installing-lwp-module-for-perl/</link>
		<comments>http://crazytoon.com/2007/05/21/perl-how-do-i-install-perl-modules-eg-installing-lwp-module-for-perl/#comments</comments>
		<pubDate>Mon, 21 May 2007 22:28:55 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/05/21/perl-how-do-i-install-perl-modules-eg-installing-lwp-module-for-perl/</guid>
		<description><![CDATA[The easiest way to install Perl modules is by installing them through &#8220;shell&#8221;.  Let us say that you are trying to install very common module called:  LWP
You can test to see if you have LWP installed by typing:
perl -MLWP -le "print(LWP-&#62;VERSION)"
If you get something like:  Can&#8217;t locate LWP.pm in @INC  means [...]]]></description>
			<content:encoded><![CDATA[<p>The easiest way to install Perl modules is by installing them through &#8220;shell&#8221;.  Let us say that you are trying to install very common module called:  LWP</p>
<p>You can test to see if you have LWP installed by typing:<br />
<code>perl -MLWP -le "print(LWP-&gt;VERSION)"</code><br />
If you get something like:  <strong>Can&#8217;t locate LWP.pm in @INC </strong> means that you don&#8217;t have it installed.  To install LWP, type:<br />
<code>perl -MCPAN -eshell</code><br />
NOTE:  most times it is okey for you to accept default answers to questions <em>cpan</em> asks.<br />
You can read through cpan help by typing &#8220;h&#8221; without the quotes at cpan&gt; prompt.<br />
To continue installing LWP, type:<br />
<code>install Bundle::LWP</code><br />
After few questions, and some text scrolling, you will have LWP installed.  If for some reason you don&#8217;t want to do it this way, you can always obtain source for the module you are trying to install and build it from source files.  You can obtain these files from <a href="http://mirror.cpan.org/">CPAN site</a></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/05/21/perl-how-do-i-install-perl-modules-eg-installing-lwp-module-for-perl/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>CentOS and Redhat problem: NFS mount at boot up fails with error: &#8220;System Error: No route to host&#8221;</title>
		<link>http://crazytoon.com/2007/05/11/centos-and-redhat-problem-nfs-mount-at-boot-up-fails-with-error-system-error-no-route-to-host/</link>
		<comments>http://crazytoon.com/2007/05/11/centos-and-redhat-problem-nfs-mount-at-boot-up-fails-with-error-system-error-no-route-to-host/#comments</comments>
		<pubDate>Fri, 11 May 2007 21:47:08 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/05/11/centos-and-redhat-problem-nfs-mount-at-boot-up-fails-with-error-system-error-no-route-to-host/</guid>
		<description><![CDATA[On our CentOS 4.4 box, I set up the nfs mount by putting the setting in fstab.
10.0.0.2:/export/files    /files    intr
After that I tested the setting by typing:  mount /files Everything worked as expected and files was mounted successfully.  At this point I wanted to make sure server will [...]]]></description>
			<content:encoded><![CDATA[<p>On our CentOS 4.4 box, I set up the <strong>nfs mount</strong> by putting the setting in fstab.</p>
<p><code>10.0.0.2:/export/files    /files    intr</code></p>
<p>After that I tested the setting by typing:  <code>mount /files</code> Everything worked as expected and files was mounted successfully.  At this point I wanted to make sure server will do nfs mounts automatically at boot up.  To my surprise once I rebooted the server, nfs mount did not happen.  I checked the logs and found this:</p>
<p><code>May 11 11:00:24 www3 mount: mount: mount to NFS server '10.0.0.2' failed:<br />
May 11 11:00:24 www3 mount: System Error: No route to host.</code></p>
<p>But once server booted up, I typed <code>mount /files </code>and again, mount worked great. After poking around for a while I found out that when netfs script runs, netfs can not find network routes (due to network is still initializing).  I tried few ways to get around this issue and settled on following solution:</p>
<p><em>vi /etc/init.d/netfs</em><br />
insert:  <em>action $&#8221;Sleeping for 30 secs: &#8221; sleep 30</em><br />
right after:  <em>[ ! -f /var/lock/subsys/portmap ] &amp;&amp; service portmap start</em><br />
and right before: <em>action $&#8221;Mounting NFS filesystems: &#8221; mount -a -t nfs,nfs4</em></p>
<p>Basically we are going to give enough time for network to start and set up routes etc.  You can play with that number after sleep command (we are basically pausing netfs script execution for 30 secs)  and see what works for you.  Once you are done, save/exit and reboot the server to see if number you used is sufficient sleep time.  You can type <em>df -h</em> to see if it was mounted.  If it wasn&#8217;t mounted, you can check /var/log/messages to see if nic was starting after nfs mount.  If it is after, you will have to increase that number after sleep.  Remember that you are only pausing the netfs script execution.  Rest of the system continues to boot up.  After I made changes, I checked my <em>df </em>output after reboot and my mount was there.  I also checked <em>/var/log/messages</em> to see if everything looks ok there:</p>
<p><code>May 11 11:22:14 www3 kernel: bnx2: eth0 NIC Link is Up, 1000 Mbps full duplex<br />
May 11 11:22:16 www3 netfs: Sleeping for 30 secs:  succeeded<br />
May 11 11:22:17 www3 netfs: Mounting NFS filesystems:  succeeded</code></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/05/11/centos-and-redhat-problem-nfs-mount-at-boot-up-fails-with-error-system-error-no-route-to-host/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>TIP:  How do I rename multiple files to another extension?</title>
		<link>http://crazytoon.com/2007/05/02/tip-how-do-i-rename-multiple-files-to-another-extension/</link>
		<comments>http://crazytoon.com/2007/05/02/tip-how-do-i-rename-multiple-files-to-another-extension/#comments</comments>
		<pubDate>Wed, 02 May 2007 21:50:25 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Notes for self]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/05/02/tip-how-do-i-rename-multiple-files-to-another-extension/</guid>
		<description><![CDATA[Let us say that you want to rename all of your &#8220;.php3&#8243; files to &#8220;.php&#8221; files.  How you do this with minimal effort?   Answer lies in for loop.
for old in *.php3; do cp $old `basename $old .php3`.php; done
Thats all there is to it.  Let us say you need to rename index.php3 [...]]]></description>
			<content:encoded><![CDATA[<p>Let us say that you want to rename all of your &#8220;.php3&#8243; files to &#8220;.php&#8221; files.  How you do this with minimal effort?   Answer lies in for loop.</p>
<p><code>for old in *.php3; do cp $old `basename $old .php3`.php; done</code></p>
<p>Thats all there is to it.  Let us say you need to rename index.php3 to index.php.  The way above snippet works is that it loops through current directory and finds all the files with extension &#8220;.php3&#8243; and processes &#8216;em one by one.  In our index.php3 file example, it finds index.php3 file, does a cp index.php3 `basename index.php3 .php3`.php &lt;- basename returns &#8220;index&#8221; so you add .php to it and now you are left with index.php.  Of course you can do mv command if you want to just move the file to new name.  I would suggest doing cp first to make sure things work the way you want &#8216;em to.</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/05/02/tip-how-do-i-rename-multiple-files-to-another-extension/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
