<?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>Tips and Tricks &#187; Linux</title>
	<atom:link href="http://www.legend.ws/blog/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.legend.ws/blog</link>
	<description>Random tech ramblings</description>
	<lastBuildDate>Wed, 11 Jan 2012 16:11:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Deleting a file, the name of which starts with a hyphen (Linux)</title>
		<link>http://www.legend.ws/blog/tips-tricks/deleting-a-file-starting-with-a-hyphen-on-linux/</link>
		<comments>http://www.legend.ws/blog/tips-tricks/deleting-a-file-starting-with-a-hyphen-on-linux/#comments</comments>
		<pubDate>Mon, 02 May 2011 10:08:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[hyphen]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.legend.ws/blog/?p=147</guid>
		<description><![CDATA[<p><a href="http://www.legend.ws/blog/wp-content/uploads/2011/05/shell.png"></a><a href="http://www.legend.ws/blog/wp-content/uploads/2011/05/rm.png"></a>You might have come across a difficulty in deleting a file in Linux whose name starts with a dash/hyphen.</p>
<p>Adding an escape character (e.g. rm -rf \-filename) or quoting the file name (e.g. rm -rf &#8220;-filename&#8221;) will not do the job.</p>
<p>The solution is simple: explicitly provide the full or relative path to the file. e.g.:</p>
<p>rm -rf /path/to/-file</p>
<p>or the following &#8211; if for instance your current working directory is the one containing the file in question</p>
<p>rm -rf ./-file&#8230;</p>]]></description>
		<wfw:commentRss>http://www.legend.ws/blog/tips-tricks/deleting-a-file-starting-with-a-hyphen-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux: finding files modified or accessed at a certain time</title>
		<link>http://www.legend.ws/blog/tips-tricks/linux-finding-files-modified-or-accessed-at-a-certain-time/</link>
		<comments>http://www.legend.ws/blog/tips-tricks/linux-finding-files-modified-or-accessed-at-a-certain-time/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 19:10:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[range]]></category>

		<guid isPermaLink="false">http://www.legend.ws/blog/?p=136</guid>
		<description><![CDATA[<p>The &#8216;find&#8217; utility is quite handy when used with the proper parameters. Below is a few ways to find files/folders based on the time they were accessed or modified.</p>
<p><strong>Example 1</strong>:</p>
<p>find /path/to/folder -type f -name &#8220;*.txt&#8221; -mtime -5</p>
<p>This will find &#8216;files&#8217; (-type f) within the folder /path/to/folder (or one of its sub directories), whose name ends with &#8216;.txt&#8217;, and which were <span style="text-decoration: underline;">modified</span> (<span style="text-decoration: underline;">m</span>time) <strong>less than 5 days ago</strong></p>
<p><strong>Example 2:</strong></p>
<p>find /path/to/folder -type d -name &#8220;stat*&#8221; -mtime +10</p>
<p>This would find &#8216;directories&#8217; (-type d) within the folder /path/to/folder (or one of its subdirectories), whose name &#8230;</p>]]></description>
		<wfw:commentRss>http://www.legend.ws/blog/tips-tricks/linux-finding-files-modified-or-accessed-at-a-certain-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Traffic forwarding on linux using IPTABLES</title>
		<link>http://www.legend.ws/blog/tips-tricks/traffic-forwarding-on-linux-using-iptables/</link>
		<comments>http://www.legend.ws/blog/tips-tricks/traffic-forwarding-on-linux-using-iptables/#comments</comments>
		<pubDate>Mon, 18 May 2009 08:24:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[forwarding]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[NAT]]></category>
		<category><![CDATA[packets]]></category>
		<category><![CDATA[rules]]></category>
		<category><![CDATA[TCP]]></category>
		<category><![CDATA[traffic]]></category>
		<category><![CDATA[UDP]]></category>

		<guid isPermaLink="false">http://www.legend.ws/blog/?p=100</guid>
		<description><![CDATA[<p>IPTables allows you to easily setup rules for packet filtering/forwarding.</p>
<p>So, to keep it short and simple: assume you&#8217;d like to forward any traffic coming to your machine (192.168.0.1) on port 80 to machine2 (192.168.0.2) on port 8080 then:</p>
<p>- Enable port forwarding:</p>
<p>echo 1 &#62; /proc/sys/net/ipv4/ip_forward</p>
<p>- Now add the rules:</p>
<p>iptables -t nat -A PREROUTING -p tcp -d 192.168.0.1 &#8211;dport 80 -j DNAT &#8211;to 192.168.0.2:8080</p>
<p>iptables -t nat -A POSTROUTING -d 192.168.0.2 -j MASQUERADE</p>
<p>The -p tcp flag specifies that the protocol is TCP (as opposed to UDP, ICMP for example).</p>
<p>The -d 192.168.0.1 flag specifies that the &#8230;</p>]]></description>
		<wfw:commentRss>http://www.legend.ws/blog/tips-tricks/traffic-forwarding-on-linux-using-iptables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL password hashing</title>
		<link>http://www.legend.ws/blog/tips-tricks/mysql-password-hashing/</link>
		<comments>http://www.legend.ws/blog/tips-tricks/mysql-password-hashing/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 18:55:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[hashing]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[mysql 4]]></category>
		<category><![CDATA[mysql 5]]></category>
		<category><![CDATA[password]]></category>

		<guid isPermaLink="false">http://www.legend.ws/blog/?p=35</guid>
		<description><![CDATA[<p>Whenever you upgrade your MySQL installation, make sure to upgrade any client that uses it.</p>
<p>In some cases, clients that use a version prior to 4.1 will have a problem authenticating against the MySQL database if the latter has a post 4.1 version.</p>
<p>The trick is that after 4.1 (i.e. 4.11 and up), MySQL changed the way it stores the passwords in the <strong>user</strong> table inside the <strong>mysql</strong> system database.<br />
Password hashes are now 41 bytes long instead of the old 16 bytes.</p>
<p>So for example, if your MySQL server is 5.0, while your <strong>php-mysql</strong> library is 4.1, your web &#8230;</p>]]></description>
		<wfw:commentRss>http://www.legend.ws/blog/tips-tricks/mysql-password-hashing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting rid of the ^M characters in vi</title>
		<link>http://www.legend.ws/blog/linux/removing-the-m-character-in-vim/</link>
		<comments>http://www.legend.ws/blog/linux/removing-the-m-character-in-vim/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 18:53:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.legend.ws/blog/?p=29</guid>
		<description><![CDATA[<p>If you&#8217;re a regular <a href="http://www.vim.org/">vi</a> user, you may have noticed that some files, when being edited in vi, contain <strong>^M</strong> characters at line ends.</p>
<p>This usually happens when you edit a file using certain windows-editors, then transfer it to your *nix machine.<br />
Luckily, it is easily to get rid of this control character. While in vi, execute the following command:</p>
<p>:1,$s/<strong>^M</strong>//g</p>
<p>Important note: do not manually type a caret then the capital M character. Actually, in order to type <strong>^M</strong>, press CTRL+V followed by CTRL+M.</p>
<p>A quick note:  the above command will look for the <strong>^M</strong> character &#8230;</p>]]></description>
		<wfw:commentRss>http://www.legend.ws/blog/linux/removing-the-m-character-in-vim/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using vi to replace a string in multiple files</title>
		<link>http://www.legend.ws/blog/tips-tricks/replace-text-in-multiple-files/</link>
		<comments>http://www.legend.ws/blog/tips-tricks/replace-text-in-multiple-files/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 19:58:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.legend.ws/blog/tips-tricks/replace-text-in-multiple-files/</guid>
		<description><![CDATA[<p>Sometime you may want to replace occurences of a string across multiple files.</p>
<p>There is an easy way to do so with the help of the vi editor.</p>
<p>This example will illustrate the power of vi:</p>
<p>Suppose you have 100 .html files, and you want to replace the occurence of the string &#8217;2007&#8242; with &#8217;2008&#8242;.</p>
<p>As such, execute the following at your prompt:</p>
<p>vi *.html</p>
<p>This will open all the files ending with &#8216;.html&#8217; in your current working directory. Then issue the following command:</p>
<p>:argdo %s/2007/2008/g &#124; wq</p>
<p>That&#8217;s it! the above command will loop over each file, replacing (%) &#8230;</p>]]></description>
		<wfw:commentRss>http://www.legend.ws/blog/tips-tricks/replace-text-in-multiple-files/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Linux file permissions explained</title>
		<link>http://www.legend.ws/blog/tips-tricks/linux-file-permissions-explained/</link>
		<comments>http://www.legend.ws/blog/tips-tricks/linux-file-permissions-explained/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 00:11:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.legend.ws/blog/tips-tricks/linux-file-permissions-explained/</guid>
		<description><![CDATA[<p>Some people may not be very knowledgeable about *nix file permissions, and what they mean, so this is intended to be some sort of a guide.</p>
<p>Any file or folder has a permission associated to it. Look at it as: &#8216;who has the power over this file/folder, and what kind of power does he have&#8217;.</p>
<p>There are 3 types of permissions:</p>
<ul>
<li>read</li>
<li>write</li>
<li>execute</li>
</ul>
<p>These permissions apply to 3 groups of people:</p>
<ul>
<li>The file/folder owner</li>
<li>The group to which the owner of this file/folder belongs</li>
<li>The rest of the crowd, called world.</li>
</ul>
<p>So suppose you have a file &#8216;x&#8217;, then &#8230;</p>]]></description>
		<wfw:commentRss>http://www.legend.ws/blog/tips-tricks/linux-file-permissions-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using iptables in order to share an internet connection</title>
		<link>http://www.legend.ws/blog/tips-tricks/iptables-internet-connection-sharing/</link>
		<comments>http://www.legend.ws/blog/tips-tricks/iptables-internet-connection-sharing/#comments</comments>
		<pubDate>Thu, 09 Nov 2006 22:40:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://legend.ws/blog/iptables-internet-connection-sharing/</guid>
		<description><![CDATA[<p>Many users run small networks, be it at home or work. One of the widely used techniques for sharing the internet connection over a small local area network is Microsoft&#8217;s ICS (Internet Connection Sharing).</p>
<p>What if the main server is not running windows? Some prefer to opt for linux, and run several services that benefit client computers on this network (such as dns, dhcp, samba, NIS, etcâ€¦)</p>
<p>The good news for linux users is that they can benefit from the same functionality of ICS, but using linux iptables.</p>
<p>The following is a sample rule:</p>
<p>/sbin/iptables -t nat -A POSTROUTING -o &#8230;</p>]]></description>
		<wfw:commentRss>http://www.legend.ws/blog/tips-tricks/iptables-internet-connection-sharing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

