<?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>sp2hari@weblog... &#187; linux</title>
	<atom:link href="http://sp2hari.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://sp2hari.com</link>
	<description>I see, learn and rediscover... everyday!</description>
	<lastBuildDate>Wed, 28 Jul 2010 01:13:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Advanced Bash Scripting &#8211; Part 2</title>
		<link>http://sp2hari.com/2010/07/27/advanced-bash-scripting-part2/</link>
		<comments>http://sp2hari.com/2010/07/27/advanced-bash-scripting-part2/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 00:11:31 +0000</pubDate>
		<dc:creator>sp2hari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Shell-Scripting]]></category>

		<guid isPermaLink="false">http://sp2hari.com/?p=572</guid>
		<description><![CDATA[The problem statement is as follows : The Playfair Cipher encrypts text by substitution of digrams (2-letter groupings). It is traditional to use a 5 x 5 letter scrambled-alphabet key square for the encryption and decryption. Each letter of the alphabet appears once, except &#8220;I&#8221; also represents &#8220;J&#8221;. The arbitrarily chosen key word, &#8220;CODES&#8221; comes]]></description>
			<content:encoded><![CDATA[<p><a href="http://sp2hari.com/wp-content/uploads/2010/03/application-x-shellscript.png"><img src="http://sp2hari.com/wp-content/uploads/2010/03/application-x-shellscript.png" alt="Shell Script" title="application-x-shellscript" width="128" height="128" class="alignleft size-full wp-image-446" /></a><strong>The problem statement is as follows : </strong></p>
<p>The Playfair Cipher encrypts text by substitution of digrams (2-letter groupings). It is traditional to use a 5 x 5 letter scrambled-alphabet key square for the encryption and decryption.</p>
<p>Each letter of the alphabet appears once, except &#8220;I&#8221; also represents &#8220;J&#8221;. The arbitrarily chosen key word, &#8220;CODES&#8221; comes first, then all the rest of the alphabet, in order from left to right, skipping letters already used.</p>
<p>To encrypt, separate the plaintext message into digrams (2-letter groups). If a group has two identical letters, delete the second, and form a new group. If there is a single letter left over at the end, insert a &#8220;null&#8221; character, typically an &#8220;X.&#8221;</p>
<p>To read more about the question, check <a href="http://tldp.org/LDP/abs/html/writingscripts.html">http://tldp.org/LDP/abs/html/writingscripts.html</a></p>
<p>The solution for this question is pretty long (over 100 lines in shell script). You can check the final solution at <a href="http://sp2hari.com/bash/playfair-cipher.html">http://sp2hari.com/bash/playfair-cipher.html</a></p>
<p>Explanation of function/code used in the solution.</p>
<p><strong>locateInKeySquare</strong>: Searches for the character passed as the parameter in the keySquare and returns the position of the character.<br />
<strong>addToKeySquare</strong>: Adds a character c passed as the parameter to the keySquare. This checks if the character is already present, if it is J and changes it to uppercase (if needed)<br />
<strong>printKeySquare</strong>: Prints the keySquare from 1D to 2D format. </p>
<p>The rest of the code adds the keyWord to keySquare. The the remaining words are added to the keySquare. After that, we extract the dialects from the plaintext and based on the 3 rules, we encrypt the text. </p>
<p>Hope this is helpful.. </p>
]]></content:encoded>
			<wfw:commentRss>http://sp2hari.com/2010/07/27/advanced-bash-scripting-part2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security settings for a LAMP Server : Iptables</title>
		<link>http://sp2hari.com/2010/05/24/security-settings-for-a-lamp-server-iptables-ssh/</link>
		<comments>http://sp2hari.com/2010/05/24/security-settings-for-a-lamp-server-iptables-ssh/#comments</comments>
		<pubDate>Mon, 24 May 2010 23:12:06 +0000</pubDate>
		<dc:creator>sp2hari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[interviewstreet-dev]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://sp2hari.com/?p=509</guid>
		<description><![CDATA[Security is the major concern for anyone hosting a website on the internet. These are the preliminary security settings to be performed to protect your server. iptables Our server stack is LAMP. Hence iptables as the firewall is the most natural choice. The requirements are like 1. Block everything except Ping, SSH, Apache, and SSL.]]></description>
			<content:encoded><![CDATA[<p>Security is the major concern for anyone hosting a website on the internet. These are the preliminary security settings to be performed to protect your server. </p>
<p><strong>iptables</strong><br />
Our server stack is LAMP. Hence iptables as the firewall is the most natural choice. The requirements are like</p>
<p>1. Block everything except Ping, SSH, Apache, and SSL.<br />
2. Enabled SSH only from the selected IP addresses.</p>
<p>The following script takes care of all iptables settings. (Idea copied from <a href="http://serverfault.com/questions/84872/iptables-ok-now-am-i-doing-it-right">here</a>)</p>
<p>Note: Please enter the command one by one. Make sure you replace IP1.IP2.IP3.IP4 with your own IP address.</p>
<p><code># Establish a clean slate<br />
iptables -P INPUT ACCEPT<br />
iptables -P FORWARD ACCEPT<br />
iptables -P OUTPUT ACCEPT<br />
iptables -F # Flush all rules<br />
iptables -X # Delete all chains<br />
# Disable routing. Drop packets if they reach the end of the chain.<br />
iptables -P FORWARD DROP<br />
# Drop all packets with a bad state<br />
iptables -A INPUT -m state --state INVALID -j DROP<br />
# Accept any packets that have something to do with ones we've sent on outbound<br />
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT<br />
# Accept any packets coming or going on localhost (this can be very important)<br />
iptables -A INPUT -i lo -j ACCEPT<br />
# Accept ICMP<br />
iptables -A INPUT -p icmp -j ACCEPT<br />
# Allow ssh<br />
iptables -A INPUT -p tcp --dport 22 -j ACCEPT<br />
# Allow httpd<br />
iptables -A INPUT -p tcp --dport 80 -j ACCEPT<br />
# Allow mysql<br />
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT<br />
# Allow SSL<br />
iptables -A INPUT -p tcp --dport 443 -j ACCEPT<br />
# Block all other traffic<br />
iptables -A INPUT -j DROP<br />
</code></p>
<p>I guess the above script should take care of the basic security issues. Hope it helps. </p>
]]></content:encoded>
			<wfw:commentRss>http://sp2hari.com/2010/05/24/security-settings-for-a-lamp-server-iptables-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced Bash Scripting &#8211; Part 1</title>
		<link>http://sp2hari.com/2010/03/31/advanced-bash-scripting-part-1/</link>
		<comments>http://sp2hari.com/2010/03/31/advanced-bash-scripting-part-1/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 11:32:27 +0000</pubDate>
		<dc:creator>sp2hari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Shell-Scripting]]></category>

		<guid isPermaLink="false">http://sp2hari.com/?p=445</guid>
		<description><![CDATA[Hello everyone, I&#8217;m planning to solve the problems in the Advanced Bash-Scripting Guide, say like one problem per week. Why am I doing this? 1. The problems there are very interesting. 2. Working in windows all the time, I feel I&#8217;m losing my shell scripting abilities. This will keep me updated. The problem we are]]></description>
			<content:encoded><![CDATA[<p><a href="http://sp2hari.com/wp-content/uploads/2010/03/application-x-shellscript.png"><img src="http://sp2hari.com/wp-content/uploads/2010/03/application-x-shellscript.png" alt="Shell Script" title="application-x-shellscript" width="108" height="108" class="alignleft size-full wp-image-446" align="left"/></a> </p>
<p>Hello everyone, I&#8217;m planning to solve the problems in the <a href="http://tldp.org/LDP/abs/html/writingscripts.html">Advanced Bash-Scripting Guide</a>, say like one problem per week. Why am I doing this?</p>
<p>1. The problems there are very interesting.<br />
2. Working in windows all the time, I feel I&#8217;m losing my shell scripting abilities. This will keep me updated. </p>
<p>The problem we are going to solve this week is &#8220;Testing Passwords&#8221;. The problem statement is as follows.</p>
<p>Write a script to check and validate passwords. The object is to flag &#8220;weak&#8221; or easily guessed password candidates.<br />
A trial password will be input to the script as a command-line parameter. To be considered acceptable, a password must meet the following minimum qualifications:</p>
<p>1. Minimum length of 8 characters<br />
2. Must contain at least one numeric character<br />
3. Must contain at least one of the following non-alphabetic characters: @, #, $, %, &#038;, *, +, -, =</p>
<p>Optional:<br />
Do a dictionary check on every sequence of at least four consecutive alphabetic characters in the password under test. This will eliminate passwords containing embedded &#8220;words&#8221; found in a standard dictionary.<br />
Enable the script to check all the passwords on your system. These probably do not reside in /etc/passwd.</p>
<p>The command I&#8217;m planning to use for this is grep, with a few for loop constructs and string operations. </p>
<p>Let&#8217;s check the constraints one by one. </p>
<p><code>#Minimum length of 8 characters<br />
if [ ${#password} -lt 8 ]<br />
then<br />
&nbsp;&nbsp;echo "$password: $weakString"<br />
&nbsp;&nbsp;return<br />
fi</code></p>
<p><code>#Must contain at least one numeric character<br />
if [ `echo $password | grep -c -E "[0-9]+"` -eq 0 ]<br />
then<br />
&nbsp;&nbsp;echo "$password: $weakString"<br />
&nbsp;&nbsp;return<br />
fi</code></p>
<p><code>#Must contain at least one of the following non-alphabetic characters: @, #, $, %, &#038;, *, +, -, =<br />
if [ `echo $password | grep -c -E "[@#$%&#038;*=+-]+"` -eq 0 ]<br />
then<br />
&nbsp;&nbsp;echo "$password: $weakString"<br />
&nbsp;&nbsp;return<br />
fi</code></p>
<p><code>#Do a dictionary check on every sequence of at least four consecutive alphabetic characters in the password under test. This will eliminate passwords containing embedded "words" found in a standard dictionary.<br />
for((i=4;i<=${#password};i++))<br />
do<br />
&nbsp;&nbsp;for((j=0;j<=${#password}-$i;j++))<br />
&nbsp;&nbsp;do<br />
&nbsp;&nbsp;&nbsp;&nbsp;if [ `grep -c -E "^${password:$j:$i}$" dict.txt` -gt 0 ]<br />
&nbsp;&nbsp;&nbsp;&nbsp;then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "$password: $weakString"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return<br />
&nbsp;&nbsp;&nbsp;&nbsp;fi<br />
&nbsp;&nbsp;done<br />
done</code></p>
<p>That's about it, we have checked all the constraints. Now, we will combine all the checks in one function and then we will pass all the  command line parameters to this function one by one. </p>
<p>You can take a look at the <a href="http://sp2hari.com/bash/testing-passwords.html">final script here</a>. </p>
<p>Can you make it any better or reduce the code size? Feel free to add it in the comments section.</p>
]]></content:encoded>
			<wfw:commentRss>http://sp2hari.com/2010/03/31/advanced-bash-scripting-part-1/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Meet GNU/Linux 07</title>
		<link>http://sp2hari.com/2007/06/12/meet-gnulinux-07/</link>
		<comments>http://sp2hari.com/2007/06/12/meet-gnulinux-07/#comments</comments>
		<pubDate>Wed, 13 Jun 2007 01:32:00 +0000</pubDate>
		<dc:creator>sp2hari</dc:creator>
				<category><![CDATA[glugt]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mgl]]></category>

		<guid isPermaLink="false">http://sp2hari.com/?p=54</guid>
		<description><![CDATA[After 2 successful editions of Meet GNU/Linux, which is conducted byGLUG-T every year for beginners, the third edition of MGL is startingon 27th July, at NITT. A few updates about MGL&#8217;07 : 1. Guys are planning to release a beginner handbook, which would begiven out to them. The content is being edited in a wiki]]></description>
			<content:encoded><![CDATA[<p>After 2 successful editions of Meet GNU/Linux, which is conducted by<br />GLUG-T every year for beginners, the  third edition of MGL is starting<br />on 27th July, at NITT.</p>
<p>A few updates about MGL&#8217;07 :</p>
<p>1. Guys are planning to release a beginner handbook, which would be<br />given out to them. The content is being edited in a wiki :<br /><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://glugt-mgl.pbwiki.com/" target="_blank">http://glugt-mgl.pbwiki.com/</a>  Go ahead and edit when you are  free.</p>
<p>2. This is GNU/Linux for dummies. So, if you have any of your<br />friend/relative interested in learning about it(in trichy), you can<br />ask them to contact <a href="http://suren4oss.blogspot.com">suren</a> who is co-ordinating<br />the event.</p>
<p>3. The co-ords are planning to release podcasts of the events, which<br />will be helpful.</p>
<p>Ideas, suggestion about how to organise the classes are welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://sp2hari.com/2007/06/12/meet-gnulinux-07/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coding Style &#8230;</title>
		<link>http://sp2hari.com/2007/05/23/coding-style/</link>
		<comments>http://sp2hari.com/2007/05/23/coding-style/#comments</comments>
		<pubDate>Wed, 23 May 2007 11:01:00 +0000</pubDate>
		<dc:creator>sp2hari</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[LDTP]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://sp2hari.com/?p=43</guid>
		<description><![CDATA[I have never thought much about coding style before i did my NOSIP in Novell. But once i started coding for ldtprecord, according to the coding style suggested to me by nags, i was surprised to see how nice and neat the final code looks. Some tips/tricks for nice coding skills are, 1. Do spend]]></description>
			<content:encoded><![CDATA[<div style="text-align: justify;">I have never thought much about coding style before i did my <a href="http://www.gnomebangalore.org/?q=nosip">NOSIP</a> in <a href="http://www.novell.com/">Novell</a>. But once i started coding for <a href="http://ldtp.freedesktop.org/">ldtprecord</a>, according to the coding style suggested to me by <a href="http://nagappanal.blogspot.com/">nags</a>, i was surprised to see how nice and neat the final code looks.</div>
<p>Some tips/tricks for nice coding skills are,</p>
<div style="text-align: justify;">1. Do spend some time to think about the variable names and the function names. This sometimes might be bit boring, especially when you want to concentrate much on the program logic and performance. But this is <span style="font-style: italic;">Rule 0</span> for coding conventions. A variable name &#8220;k&#8221; can imply anything like &#8220;kappa, kozhukattai, katthu, kaadhal, kerala, kozhuppu&#8230;&#8221; to someone who might have to read your code later. This is again mentioned <a href="http://developer.gnome.org/doc/guides/programming-guidelines/code-style.html">here</a> clearly. Many thanks to emacs, you can always use the auto complete, if your variable name is too long. :-) .</div>
<p>
<div style="text-align: justify;">2. The actual coding convention depends much on the language and the standards your team is using already. The following style won&#8217;t work for someone, whose team is already using a totally different style.</div>
<p>A few examples for C is posted here .</p>
<p><span style="font-weight: bold;">Sample Code 1 :</p>
<p></span><span style="font-style: italic;">if (a == 5)  {</span><span style="font-style: italic;"><br /></span>
<div style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-style: italic;">b = 10;</span></div>
<p><span style="font-style: italic;">}</span><br /><span style="font-style: italic;">else {</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-style: italic;">b = 20;</span> <span style="font-style: italic;"><br />}</span></p>
<p>Things to be noticed in the above snippet are.</p>
<p>1. A space between if and &#8220;(&#8221; .<br />2. Space in both the sides of the comparison operator.<br />3. Space between &#8220;)&#8221; and &#8220;{&#8220;<br />4. Space between both the sides of assignment operator (line 2 &#038; 5) . This is true for almost all the operators.<br />5. Proper indentation of lines 2 &amp; 5. If you are using emacs or vi, check <a href="http://developer.gnome.org/doc/guides/programming-guidelines/code-style.html">here</a> for your .emacs or .vimrc file .</p>
<div style="text-align: justify;">Well, your code will compile and run even if you don&#8217;t give these spaces, but a program coded with a bad coding style is equivalent to an inefficient code.</div>
<p><span style="font-weight: bold;">Sample Code 2</p>
<p></span>Let us have a function which takes two integers and returns their sum .<br />The code should be like<br /><span style="font-style: italic;"><br />int add_numbers (int num1, int num2) {</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-style: italic;">return (num1 + num2);</span> <span style="font-style: italic;"><br />}</span></p>
<p>The function call will be something like,</p>
<p><span style="font-style: italic;">int sum;</span> <span style="font-style: italic;"><br />sum = add_numbers (10, 20);</p>
<p></span>Things to be noticed in the above snippet is</p>
<p>In the first line in the function declaration,</p>
<p>1. The function name should be as clear as possible.<br />2. A space between the end of function name and &#8220;(&#8221; .<br />3. Spaces are given after every &#8220;,&#8221; in the function argument list.<br />4. A space is given between &#8220;)&#8221; and &#8220;{&#8220;.</p>
<p>In the second line in the function declaration,</p>
<p>1. A space before &#8220;(&#8220;.  [ This rule is almost global. Apply it everywhere whenever you use "(" ] .
<div style="text-align: justify;">2. There is a space on both the sides of the addition operator. This is again almost global. A space between both the sides of operator makes the code look real neat.</div>
<p>3. The indentation about which was mentioned earlier.</p>
<p>But yes, if your girl friend is a geek or a nerd or a psycho or a fundoo, then you better go for this. ;-)</p>
<p><span style="font-style: italic;">#define MAGIC &#8220;eilouvy43605321&#8243;</span><br /><span style="font-style: italic;">#define _(p,o,q) (t o#p[0])?(q)</span><br /><span style="font-style: italic;">#define __(p,o,q) _(p,o,t-q)</span><br /><span style="font-style: italic;">int main(){int t, i; for(i=8;i>0;i&#8211;)printf(&#8220;%c&#8221;, MAGIC[(((t=(MAGIC+7)[i-1])==&#8217;_')?62:_(.,==,63):_(@,==,64):__(a,>=,&#8217;a'+36):__(A,>=,&#8217;A'+10):(t-&#8217;0&#8242;))]);}</p>
<p></span>Note :: I wont say the coding style i use is the perfect one. It always depends upon what your team was using till now and how easy it is to read, debug and maintain the code.<span style="font-style: italic;"></p>
<p></span><span>Useful Links :<br /></span>
<div style="text-align: justify;">The guide coding standards in <a href="http://developer.gnome.org/doc/guides/programming-guidelines/book1.html">GNOME</a> is really a nice one.<br />Even better was <a href="http://www.possibility.com/Cpp/CppCodingStandard.html">this one</a> i found recently. Though i didn&#8217;t read it completely, it was quite interesting.<br /><a href="http://www.arcticlabs.com/codingstandards/ArcticLabsCodingStandardsCpp.html">This</a> article was short and sweet. </div>
]]></content:encoded>
			<wfw:commentRss>http://sp2hari.com/2007/05/23/coding-style/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Seg Fault</title>
		<link>http://sp2hari.com/2007/05/03/seg-fault/</link>
		<comments>http://sp2hari.com/2007/05/03/seg-fault/#comments</comments>
		<pubDate>Thu, 03 May 2007 08:00:00 +0000</pubDate>
		<dc:creator>sp2hari</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[segfault]]></category>
		<category><![CDATA[technical]]></category>

		<guid isPermaLink="false">http://sp2hari.com/?p=36</guid>
		<description><![CDATA[Wikipedia says,A segmentation fault (often shortened to segfault) is a particular error condition that can occur during the operation of computer software. A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not]]></description>
			<content:encoded><![CDATA[<p>Wikipedia says,<br />A <a href="http://en.wikipedia.org/wiki/Segmentation_fault"><span style="font-weight: bold;">segmentation fault</span></a>  (often shortened to <b>segfault</b>) is a particular error condition that can occur during the operation of <a href="http://en.wikipedia.org/wiki/Computer_software" title="Computer software">computer software</a>. A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a read-only location, or to overwrite part of the operating system).&#8221;</p>
<p>I have seen hundreds and hundreds of seg faults ;-) while coding for record module of <a href="http://ldtp.freedesktop.org/">LDTP</a> and Spider SMS. But the one i saw yesterday was new, strange and fascinating. I am not sure whether i will be able to reproduce it again. The screenshot says why it is strange and fascinating :-) .</p>
<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_7owHVJdIzX8/RjmX9bSaGlI/AAAAAAAAArw/mJl5A_goeGE/s1600-h/Screenshot.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp2.blogger.com/_7owHVJdIzX8/RjmX9bSaGlI/AAAAAAAAArw/mJl5A_goeGE/s320/Screenshot.png" alt="" id="BLOGGER_PHOTO_ID_5060242737880242770" border="0" /></a></p>
<p>-bash-3.1$ man su<br /><span style="font-style: italic;">says </span></p>
<p>AUTHOR<br />       Written by David MacKenzie.</p>
<p>REPORTING BUGS<br />       Report bugs to &lt;bug-coreutils@gnu.org&gt;.</p>
<p>Maybe i should consider reporting this :P .</p>
]]></content:encoded>
			<wfw:commentRss>http://sp2hari.com/2007/05/03/seg-fault/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Forgot mysql root pass ?</title>
		<link>http://sp2hari.com/2007/01/30/forgot-mysql-root-pass/</link>
		<comments>http://sp2hari.com/2007/01/30/forgot-mysql-root-pass/#comments</comments>
		<pubDate>Tue, 30 Jan 2007 19:19:00 +0000</pubDate>
		<dc:creator>sp2hari</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[lostpass]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://sp2hari.com/?p=27</guid>
		<description><![CDATA[Recently forgot mysql root password for one of the servers i maintain . Little bit googling helped me to reset the password .Just copy pasted the tutorials i saw so that i need not google again . If you have set a root password, but forgot what it was, you can set a new password]]></description>
			<content:encoded><![CDATA[<p>Recently forgot mysql root password for one of the servers i maintain . Little bit googling helped me to reset the password .<br />Just copy pasted the tutorials i saw so that i need not google again .
<p>If you have set a <code>root</code> password, but forgot what it was, you can set a new       password with the following procedure:</p>
<ol>
<li>Take down the <code>mysqld</code> server by sending a <code>kill</code> (not <code>kill           -9</code>) to the <code>mysqld</code> server. The pid is stored in a <tt>`.pid'</tt> file,           which is normally in the MySQL database directory:
<pre>shell> kill `cat /mysql-data-directory/hostname.pid`</pre>
<p>           You must be either the Unix <code>root</code> user or the same user <code>mysqld</code>           runs as to do this.         </li>
<li>Restart <code>mysqld</code> with the <code>--skip-grant-tables</code> option.         </li>
<li>Set a new password with the <code>mysqladmin password</code> command:
<pre>shell> mysqladmin -u root password 'mynewpassword'</pre>
</li>
<li>Now you can either stop <code>mysqld</code> and restart it normally, or just load the           privilege tables with:
<pre>shell> mysqladmin -h hostname flush-privileges</pre>
</li>
<li>After this, you should be able to connect using the new password.</li>
</ol>
<p>Alternatively, you can set the new password using the <code>mysql</code> client:
<ol>
<li>Take down and restart <code>mysqld</code> with the <code>--skip-grant-tables</code>           option as described above.         </li>
<li>Connect to the <code>mysqld</code> server with:
<pre>shell> mysql -u root mysql</pre>
</li>
<li>Issue the following commands in the <code>mysql</code> client:
<pre>mysql> UPDATE user SET Password=PASSWORD('mynewpassword')   ->             WHERE User='root';mysql> FLUSH PRIVILEGES;</pre>
</li>
<li>After this, you should be able to connect using the new password.         </li>
<li>You can now stop <code>mysqld</code> and restart it normally.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://sp2hari.com/2007/01/30/forgot-mysql-root-pass/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
