<?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>Personal blog of Chris Ergatides &#187; Linux</title>
	<atom:link href="http://blog.ergatides.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ergatides.com</link>
	<description>jQuery, Linux, Technology, Web Design and random stuff.</description>
	<lastBuildDate>Mon, 06 Feb 2012 05:01:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>What nobody does is nobody&#8217;s business.</title>
		<link>http://blog.ergatides.com/2012/01/24/what-nobody-does-is-nobodys-business/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=what-nobody-does-is-nobodys-business</link>
		<comments>http://blog.ergatides.com/2012/01/24/what-nobody-does-is-nobodys-business/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 14:34:54 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nobody]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[users]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=1761</guid>


		<description><![CDATA[<p>Came across <a href="http://www.serverschool.com/dedicated-servers/who-is-nobody/" target="_blank">this article</a> about the &#8216;nobody&#8217; user on *nix systems and loved the closing sentence&#8230;</p>
<blockquote><p>If you stare at the list of running processes on your server for long enough, you are bound to come across the user called “nobody”. Before you call a security expert and prepare to fight off a hacker, relax. While the username “nobody” may seem suspicious, it is actually supposed to be there.<br />
.<br />
.<br />
Therefore, do not fear “nobody” and do not take any steps to hinder the user’s ability to run some of your critical applications, like the web server. What nobody does is nobody’s business.</p></blockquote>
<p>There, you&#8217;ve been told!</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2011/09/05/ssh-configuration-single-host-multiple-users/' rel='bookmark' title='SSH configuration: single host, multiple users.'>SSH configuration: single host, multiple users.</a></li>
<li><a href='http://blog.ergatides.com/2011/07/29/12th-annual-system-administrator-appreciation-day/' rel='bookmark' title='12th Annual System Administrator Appreciation Day'>12th Annual System Administrator Appreciation Day</a></li>
<li><a href='http://blog.ergatides.com/2011/02/21/whats-my-ip-check-your-ip-address-from-the-command-line/' rel='bookmark' title='What&#8217;s my IP? Check your IP address from the command line.'>What&#8217;s my IP? Check your IP address from the command line.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Came across <a href="http://www.serverschool.com/dedicated-servers/who-is-nobody/" target="_blank">this article</a> about the &#8216;nobody&#8217; user on *nix systems and loved the closing sentence&#8230;</p>
<blockquote><p>If you stare at the list of running processes on your server for long enough, you are bound to come across the user called “nobody”. Before you call a security expert and prepare to fight off a hacker, relax. While the username “nobody” may seem suspicious, it is actually supposed to be there.<br />
.<br />
.<br />
Therefore, do not fear “nobody” and do not take any steps to hinder the user’s ability to run some of your critical applications, like the web server. What nobody does is nobody’s business.</p></blockquote>
<p>There, you&#8217;ve been told!</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2011/09/05/ssh-configuration-single-host-multiple-users/' rel='bookmark' title='SSH configuration: single host, multiple users.'>SSH configuration: single host, multiple users.</a></li>
<li><a href='http://blog.ergatides.com/2011/07/29/12th-annual-system-administrator-appreciation-day/' rel='bookmark' title='12th Annual System Administrator Appreciation Day'>12th Annual System Administrator Appreciation Day</a></li>
<li><a href='http://blog.ergatides.com/2011/02/21/whats-my-ip-check-your-ip-address-from-the-command-line/' rel='bookmark' title='What&#8217;s my IP? Check your IP address from the command line.'>What&#8217;s my IP? Check your IP address from the command line.</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2012/01/24/what-nobody-does-is-nobodys-business/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using sed to search and replace contents of next line in a file.</title>
		<link>http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-sed-to-search-and-replace-contents-of-next-line-in-a-file</link>
		<comments>http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 13:50:19 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[dyndns]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[no-ip]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=1740</guid>


		<description><![CDATA[<p>This example will show you how easy it is using sed to find a particular line in a file and replace all or part of the next line. In this example, using htaccess we want to deny access to all clients except a particular dynamic IP (for your home connection for instance).</p>
<p>Your .htaccess file might look like this:</p>
<pre class="brush: plain; title: ; notranslate">
order deny,allow
deny from all

# allow from example.dyndns.org
allow from 8.8.4.4
</pre>
<p>And your sed code to update the allowed IP address might look like this:</p>
<pre class="brush: plain; title: ; notranslate">
sed -i -r &quot;/# allow from example.dyndns.org/I{\
n; s/([0-9]{1,3}.){3}[0-9]{1,3}/8.8.8.8/\
}&quot; .htaccess
</pre>
<p>Let&#8217;s look at it piece by piece.</p>
<ul>
<li><strong>/# allow from example.dyndns.org/I</strong> will search the file for this string. The I flag at the end makes the search case insensitive.</li>
<li><strong>n;</strong> will tell sed to continue processing on the next line.</li>
<li><strong>s/([0-9]{1,3}\.){3}[0-9]{1,3}/8.8.8.8/</strong> will regex search for an IP and replace the match with your updated IP (in this case 8.8.8.8).</li>
<li><strong>.htaccess</strong> is of course the input file to process.</li>
</ul>
<p>Note that in .htaccess files, comments must be on a line of their own. End of line or inline comments are not permitted. In cases where you do not need to replace a part of the next line but rather all of it, our replacement becomes <strong>s/.*/8.8.8.8/</strong></p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/' rel='bookmark' title='Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)'>Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)</a></li>
<li><a href='http://blog.ergatides.com/2011/02/21/whats-my-ip-check-your-ip-address-from-the-command-line/' rel='bookmark' title='What&#8217;s my IP? Check your IP address from the command line.'>What&#8217;s my IP? Check your IP address from the command line.</a></li>
<li><a href='http://blog.ergatides.com/2010/02/24/handy-command-line-currency-converter/' rel='bookmark' title='Handy command line currency converter.'>Handy command line currency converter.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This example will show you how easy it is using sed to find a particular line in a file and replace all or part of the next line. In this example, using htaccess we want to deny access to all clients except a particular dynamic IP (for your home connection for instance).</p>
<p>Your .htaccess file might look like this:</p>
<pre class="brush: plain; title: ; notranslate">
order deny,allow
deny from all

# allow from example.dyndns.org
allow from 8.8.4.4
</pre>
<p>And your sed code to update the allowed IP address might look like this:</p>
<pre class="brush: plain; title: ; notranslate">
sed -i -r &quot;/# allow from example.dyndns.org/I{\
n; s/([0-9]{1,3}.){3}[0-9]{1,3}/8.8.8.8/\
}&quot; .htaccess
</pre>
<p>Let&#8217;s look at it piece by piece.</p>
<ul>
<li><strong>/# allow from example.dyndns.org/I</strong> will search the file for this string. The I flag at the end makes the search case insensitive.</li>
<li><strong>n;</strong> will tell sed to continue processing on the next line.</li>
<li><strong>s/([0-9]{1,3}\.){3}[0-9]{1,3}/8.8.8.8/</strong> will regex search for an IP and replace the match with your updated IP (in this case 8.8.8.8).</li>
<li><strong>.htaccess</strong> is of course the input file to process.</li>
</ul>
<p>Note that in .htaccess files, comments must be on a line of their own. End of line or inline comments are not permitted. In cases where you do not need to replace a part of the next line but rather all of it, our replacement becomes <strong>s/.*/8.8.8.8/</strong></p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/' rel='bookmark' title='Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)'>Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)</a></li>
<li><a href='http://blog.ergatides.com/2011/02/21/whats-my-ip-check-your-ip-address-from-the-command-line/' rel='bookmark' title='What&#8217;s my IP? Check your IP address from the command line.'>What&#8217;s my IP? Check your IP address from the command line.</a></li>
<li><a href='http://blog.ergatides.com/2010/02/24/handy-command-line-currency-converter/' rel='bookmark' title='Handy command line currency converter.'>Handy command line currency converter.</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Epson Stylus Photo PX830FWD</title>
		<link>http://blog.ergatides.com/2012/01/24/epson-stylus-photo-px830fwd/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=epson-stylus-photo-px830fwd</link>
		<comments>http://blog.ergatides.com/2012/01/24/epson-stylus-photo-px830fwd/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 12:34:20 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[epson]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[px830fwd]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[scan]]></category>
		<category><![CDATA[stylus]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=1706</guid>


		<description><![CDATA[<p><a href="http://www.amazon.co.uk/gp/product/B005VYKZ3W/ref=as_li_ss_il?ie=UTF8&#038;tag=peblofcher-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=B005VYKZ3W" target="_blank" rel="nofollow"><img border="0" src="http://ws.assoc-amazon.co.uk/widgets/q?_encoding=UTF8&#038;Format=_SL160_&#038;ASIN=B005VYKZ3W&#038;MarketPlace=GB&#038;ID=AsinImage&#038;WS=1&#038;tag=peblofcher-21&#038;ServiceVersion=20070822" ></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=peblofcher-21&#038;l=as2&#038;o=2&#038;a=B005VYKZ3W" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>
<p>I&#8217;ve recently purchased an <a href="http://www.amazon.co.uk/gp/product/B005VYKZ3W/ref=as_li_ss_tl?ie=UTF8&#038;tag=peblofcher-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=B005VYKZ3W" target="_blank" rel="nofollow">Epson Stylus Photo PX830FWD</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=peblofcher-21&#038;l=as2&#038;o=2&#038;a=B005VYKZ3W" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> which doesn&#8217;t seem to want to stop impressing me. Following the death of my last desktop PC, I needed a way to be able to scan again since there&#8217;s no way I&#8217;d ever be able to use my SCSI scanner. Wireless was the way to go as our lives are surrounded by laptops, tablets and smartphones not to mention the whole internet. Yes, this is a <a href="http://www.google.com/cloudprint/learn/" title="Google Cloud Print" target="_blank">Google Cloud Print</a> enabled printer which means I can print to it from my Android devices, or from Chrome, etc&#8230; wherever I am in the world. Epson have their own cloud print service if you prefer, but I haven&#8217;t tested it yet.</p>
<p>I was very happy to learn that I can use this device wirelessly from my Fedora machines as well since booting Windows just to scan wirelessly was not something that I was looking forward to have to do. If you do use Windows, the Scan-to-PC feature is pretty cool. It means that you can scan a bunch of documents at the scanner without touching a PC. I stuck Windows inside a <a href="http://www.virtualbox.org/" target="_blank" title="VirtualBox">VirtualBox</a> guest, mounted a folder on my <a target="_blank" href="http://www.amazon.co.uk/mn/search/?_encoding=UTF8&#038;x=0&#038;tag=peblofcher-21&#038;linkCode=ur2&#038;y=0&#038;camp=1634&#038;creative=19450&#038;field-keywords=synology&#038;url=search-alias%3Daps" rel="nofollow">Synology NAS</a><img src="https://www.assoc-amazon.co.uk/e/ir?t=peblofcher-21&#038;l=ur2&#038;o=2" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> and scan to that directly. This way my scans are immediately accessible on my local network, remotely via scp/sshfs and even via the NAS&#8217; web interface.</p>
<p>I haven&#8217;t tested the fax capabilities yet, but over and above manual mode there is a Print-to-Fax driver under Windows with it&#8217;s own address book. And if you ever run out of ruled or graph paper, stick a blank A4 sheet in it, press a button and hey presto. Stick in an SD card with pictures and it will even use a photo as a background. The <a href="http://www.amazon.co.uk/gp/product/B003VNKNF0/ref=as_li_ss_tl?ie=UTF8&#038;tag=peblofcher-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=B003VNKNF0" rel="nofollow">32GB Transcend Class 10 SDHC</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=peblofcher-21&#038;l=as2&#038;o=2&#038;a=B003VNKNF0" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> which I bought for my <a href="http://www.amazon.co.uk/gp/product/B0037KM0F8/ref=as_li_ss_tl?ie=UTF8&#038;tag=peblofcher-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=B0037KM0F8" target="_blank" rel="nofollow">Canon EOS 550D Rebel T2i</a> worked no problem with the printer.</p>
<p>I no longer have a need to print on CDs or DVDs myself, but it has it&#8217;s own built-in tray which sounds like a Transformer transforming as it moves around the internal parts of the printer during eject/insert. All in all, an excellent piece of kit which I would recommend any day. Now I need a good shredder (minimum DIN/Level 3). Any recommendations?</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2010/08/27/quick-keyboard-shortcut-tip-for-the-euro-e-symbol/' rel='bookmark' title='Quick keyboard shortcut tip for the EURO € symbol.'>Quick keyboard shortcut tip for the EURO € symbol.</a></li>
<li><a href='http://blog.ergatides.com/2012/01/27/photo-of-snow-covered-troodos-mountain-range-in-the-sun/' rel='bookmark' title='Photo of snow covered Troodos mountain range in the sun.'>Photo of snow covered Troodos mountain range in the sun.</a></li>
<li><a href='http://blog.ergatides.com/2011/06/26/fedora-gnome-3-show-desktop-keyboard-shortcut/' rel='bookmark' title='Fedora GNOME 3 show desktop keyboard shortcut.'>Fedora GNOME 3 show desktop keyboard shortcut.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.co.uk/gp/product/B005VYKZ3W/ref=as_li_ss_il?ie=UTF8&#038;tag=peblofcher-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=B005VYKZ3W" target="_blank" rel="nofollow"><img border="0" src="http://ws.assoc-amazon.co.uk/widgets/q?_encoding=UTF8&#038;Format=_SL160_&#038;ASIN=B005VYKZ3W&#038;MarketPlace=GB&#038;ID=AsinImage&#038;WS=1&#038;tag=peblofcher-21&#038;ServiceVersion=20070822" ></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=peblofcher-21&#038;l=as2&#038;o=2&#038;a=B005VYKZ3W" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>
<p>I&#8217;ve recently purchased an <a href="http://www.amazon.co.uk/gp/product/B005VYKZ3W/ref=as_li_ss_tl?ie=UTF8&#038;tag=peblofcher-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=B005VYKZ3W" target="_blank" rel="nofollow">Epson Stylus Photo PX830FWD</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=peblofcher-21&#038;l=as2&#038;o=2&#038;a=B005VYKZ3W" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> which doesn&#8217;t seem to want to stop impressing me. Following the death of my last desktop PC, I needed a way to be able to scan again since there&#8217;s no way I&#8217;d ever be able to use my SCSI scanner. Wireless was the way to go as our lives are surrounded by laptops, tablets and smartphones not to mention the whole internet. Yes, this is a <a href="http://www.google.com/cloudprint/learn/" title="Google Cloud Print" target="_blank">Google Cloud Print</a> enabled printer which means I can print to it from my Android devices, or from Chrome, etc&#8230; wherever I am in the world. Epson have their own cloud print service if you prefer, but I haven&#8217;t tested it yet.</p>
<p>I was very happy to learn that I can use this device wirelessly from my Fedora machines as well since booting Windows just to scan wirelessly was not something that I was looking forward to have to do. If you do use Windows, the Scan-to-PC feature is pretty cool. It means that you can scan a bunch of documents at the scanner without touching a PC. I stuck Windows inside a <a href="http://www.virtualbox.org/" target="_blank" title="VirtualBox">VirtualBox</a> guest, mounted a folder on my <a target="_blank" href="http://www.amazon.co.uk/mn/search/?_encoding=UTF8&#038;x=0&#038;tag=peblofcher-21&#038;linkCode=ur2&#038;y=0&#038;camp=1634&#038;creative=19450&#038;field-keywords=synology&#038;url=search-alias%3Daps" rel="nofollow">Synology NAS</a><img src="https://www.assoc-amazon.co.uk/e/ir?t=peblofcher-21&#038;l=ur2&#038;o=2" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> and scan to that directly. This way my scans are immediately accessible on my local network, remotely via scp/sshfs and even via the NAS&#8217; web interface.</p>
<p>I haven&#8217;t tested the fax capabilities yet, but over and above manual mode there is a Print-to-Fax driver under Windows with it&#8217;s own address book. And if you ever run out of ruled or graph paper, stick a blank A4 sheet in it, press a button and hey presto. Stick in an SD card with pictures and it will even use a photo as a background. The <a href="http://www.amazon.co.uk/gp/product/B003VNKNF0/ref=as_li_ss_tl?ie=UTF8&#038;tag=peblofcher-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=B003VNKNF0" rel="nofollow">32GB Transcend Class 10 SDHC</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=peblofcher-21&#038;l=as2&#038;o=2&#038;a=B003VNKNF0" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> which I bought for my <a href="http://www.amazon.co.uk/gp/product/B0037KM0F8/ref=as_li_ss_tl?ie=UTF8&#038;tag=peblofcher-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=B0037KM0F8" target="_blank" rel="nofollow">Canon EOS 550D Rebel T2i</a> worked no problem with the printer.</p>
<p>I no longer have a need to print on CDs or DVDs myself, but it has it&#8217;s own built-in tray which sounds like a Transformer transforming as it moves around the internal parts of the printer during eject/insert. All in all, an excellent piece of kit which I would recommend any day. Now I need a good shredder (minimum DIN/Level 3). Any recommendations?</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2010/08/27/quick-keyboard-shortcut-tip-for-the-euro-e-symbol/' rel='bookmark' title='Quick keyboard shortcut tip for the EURO € symbol.'>Quick keyboard shortcut tip for the EURO € symbol.</a></li>
<li><a href='http://blog.ergatides.com/2012/01/27/photo-of-snow-covered-troodos-mountain-range-in-the-sun/' rel='bookmark' title='Photo of snow covered Troodos mountain range in the sun.'>Photo of snow covered Troodos mountain range in the sun.</a></li>
<li><a href='http://blog.ergatides.com/2011/06/26/fedora-gnome-3-show-desktop-keyboard-shortcut/' rel='bookmark' title='Fedora GNOME 3 show desktop keyboard shortcut.'>Fedora GNOME 3 show desktop keyboard shortcut.</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2012/01/24/epson-stylus-photo-px830fwd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ternary operator for bash scripting.</title>
		<link>http://blog.ergatides.com/2012/01/13/ternary-operator-for-bash-scripting/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ternary-operator-for-bash-scripting</link>
		<comments>http://blog.ergatides.com/2012/01/13/ternary-operator-for-bash-scripting/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 13:03:55 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mounted]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[ternary]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=1633</guid>


		<description><![CDATA[<p>I was curious whether or not <a href="http://en.wikipedia.org/wiki/Ternary_operation" target="_blank">ternary operations</a> are possible in bash or not. It turns out <a href="http://developmentality.wordpress.com/2010/10/20/ternary-operator-in-bash/" target="_blank">they are</a> but only for numeric comparisons. So what if you wanted to compare whether a string is empty if you cannot use a string comparison (-Z or -n for example)? Use the <a href="http://unstableme.blogspot.com/2008/03/find-string-length-bash.html" target="_blank">string&#8217;s length</a>.</p>
<p>As always with Linux, there&#8217;s a plethora of ways to do what I am doing below, so this is just an example for your reference:</p>
<pre class="brush: bash; title: ; notranslate">
function check_mounted () {
    local result=`df | grep $1`
    echo $((${#result} &gt; 0 ? 1 : 0))
}
</pre>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/13/relative-path-to-absolute-path-in-a-bash-shell/' rel='bookmark' title='Relative path to absolute path in a bash shell.'>Relative path to absolute path in a bash shell.</a></li>
<li><a href='http://blog.ergatides.com/2010/02/24/handy-command-line-currency-converter/' rel='bookmark' title='Handy command line currency converter.'>Handy command line currency converter.</a></li>
<li><a href='http://blog.ergatides.com/2011/05/17/masking-fixed-length-strings-in-php/' rel='bookmark' title='Masking fixed length strings in PHP.'>Masking fixed length strings in PHP.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I was curious whether or not <a href="http://en.wikipedia.org/wiki/Ternary_operation" target="_blank">ternary operations</a> are possible in bash or not. It turns out <a href="http://developmentality.wordpress.com/2010/10/20/ternary-operator-in-bash/" target="_blank">they are</a> but only for numeric comparisons. So what if you wanted to compare whether a string is empty if you cannot use a string comparison (-Z or -n for example)? Use the <a href="http://unstableme.blogspot.com/2008/03/find-string-length-bash.html" target="_blank">string&#8217;s length</a>.</p>
<p>As always with Linux, there&#8217;s a plethora of ways to do what I am doing below, so this is just an example for your reference:</p>
<pre class="brush: bash; title: ; notranslate">
function check_mounted () {
    local result=`df | grep $1`
    echo $((${#result} &gt; 0 ? 1 : 0))
}
</pre>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/13/relative-path-to-absolute-path-in-a-bash-shell/' rel='bookmark' title='Relative path to absolute path in a bash shell.'>Relative path to absolute path in a bash shell.</a></li>
<li><a href='http://blog.ergatides.com/2010/02/24/handy-command-line-currency-converter/' rel='bookmark' title='Handy command line currency converter.'>Handy command line currency converter.</a></li>
<li><a href='http://blog.ergatides.com/2011/05/17/masking-fixed-length-strings-in-php/' rel='bookmark' title='Masking fixed length strings in PHP.'>Masking fixed length strings in PHP.</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2012/01/13/ternary-operator-for-bash-scripting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Relative path to absolute path in a bash shell.</title>
		<link>http://blog.ergatides.com/2012/01/13/relative-path-to-absolute-path-in-a-bash-shell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=relative-path-to-absolute-path-in-a-bash-shell</link>
		<comments>http://blog.ergatides.com/2012/01/13/relative-path-to-absolute-path-in-a-bash-shell/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 07:45:13 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[dbpath]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[readlink]]></category>
		<category><![CDATA[realpath]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[skype]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=1619</guid>


		<description><![CDATA[<p>There are many ways to convert a relative path to an absolute path which can be accessed regardless of the current working directory, particularly useful for scripting. Later, I may make a post to demonstrate the various ways, but the easiest way to do this is to use the <em>readlink</em> utility which comes bundled with just about every Linux distribution with the exception of Debian based systems which use <em>realpath</em> instead.</p>
<pre class="brush: bash; title: ; notranslate">
$ pwd
/media/usbdisk/bin

$ readlink -f ./../mnt/.Skype
/media/usbdisk/mnt/.Skype
</pre>
<p>When you use readlink in a script and assign a resulting path to a variable, you should add the n flag (-fn) to suppress the trailing newline.</p>
<p>As you might have noticed, I needed to use this in a script to launch Skype but specify that I want to use the data files on my usb key as opposed to the default ~/.Skype location. This however was not working with relative paths and Skype would crash with something like:</p>
<blockquote><p>$ FatalAssert(*out_ptr != &#8216;.&#8217; &#038;&#038; !strstr(out_ptr, &#8220;../&#8221;) &#038;&#038; !strstr(out_ptr, &#8220;..\\&#8221;))<br />
FatalAssert(*out_ptr != &#8216;.&#8217; &#038;&#038; !strstr(out_ptr, &#8220;../&#8221;) &#038;&#038; !strstr(out_ptr, &#8220;..\\&#8221;))</p></blockquote>
<p>The moment I pass a real path to Skype&#8217;s &#8211;dbpath parameter, everything works as expected.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/13/ternary-operator-for-bash-scripting/' rel='bookmark' title='Ternary operator for bash scripting.'>Ternary operator for bash scripting.</a></li>
<li><a href='http://blog.ergatides.com/2011/06/14/automatically-download-and-merge-multiple-pdf-files-with-a-unix-shell/' rel='bookmark' title='Automatically download and merge multiple PDF files with a Unix shell.'>Automatically download and merge multiple PDF files with a Unix shell.</a></li>
<li><a href='http://blog.ergatides.com/2011/11/18/how-to-install-kde-on-fedora-core-13-and-onwards/' rel='bookmark' title='How to install KDE on Fedora Core 13 and onwards.'>How to install KDE on Fedora Core 13 and onwards.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>There are many ways to convert a relative path to an absolute path which can be accessed regardless of the current working directory, particularly useful for scripting. Later, I may make a post to demonstrate the various ways, but the easiest way to do this is to use the <em>readlink</em> utility which comes bundled with just about every Linux distribution with the exception of Debian based systems which use <em>realpath</em> instead.</p>
<pre class="brush: bash; title: ; notranslate">
$ pwd
/media/usbdisk/bin

$ readlink -f ./../mnt/.Skype
/media/usbdisk/mnt/.Skype
</pre>
<p>When you use readlink in a script and assign a resulting path to a variable, you should add the n flag (-fn) to suppress the trailing newline.</p>
<p>As you might have noticed, I needed to use this in a script to launch Skype but specify that I want to use the data files on my usb key as opposed to the default ~/.Skype location. This however was not working with relative paths and Skype would crash with something like:</p>
<blockquote><p>$ FatalAssert(*out_ptr != &#8216;.&#8217; &#038;&#038; !strstr(out_ptr, &#8220;../&#8221;) &#038;&#038; !strstr(out_ptr, &#8220;..\\&#8221;))<br />
FatalAssert(*out_ptr != &#8216;.&#8217; &#038;&#038; !strstr(out_ptr, &#8220;../&#8221;) &#038;&#038; !strstr(out_ptr, &#8220;..\\&#8221;))</p></blockquote>
<p>The moment I pass a real path to Skype&#8217;s &#8211;dbpath parameter, everything works as expected.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/13/ternary-operator-for-bash-scripting/' rel='bookmark' title='Ternary operator for bash scripting.'>Ternary operator for bash scripting.</a></li>
<li><a href='http://blog.ergatides.com/2011/06/14/automatically-download-and-merge-multiple-pdf-files-with-a-unix-shell/' rel='bookmark' title='Automatically download and merge multiple PDF files with a Unix shell.'>Automatically download and merge multiple PDF files with a Unix shell.</a></li>
<li><a href='http://blog.ergatides.com/2011/11/18/how-to-install-kde-on-fedora-core-13-and-onwards/' rel='bookmark' title='How to install KDE on Fedora Core 13 and onwards.'>How to install KDE on Fedora Core 13 and onwards.</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2012/01/13/relative-path-to-absolute-path-in-a-bash-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Be careful when using find with the delete flag to clean old files.</title>
		<link>http://blog.ergatides.com/2012/01/09/be-careful-when-using-find-with-the-delete-flag-to-clean-old-files/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=be-careful-when-using-find-with-the-delete-flag-to-clean-old-files</link>
		<comments>http://blog.ergatides.com/2012/01/09/be-careful-when-using-find-with-the-delete-flag-to-clean-old-files/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 15:28:18 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[actions]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[exec]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[order]]></category>
		<category><![CDATA[priority]]></category>
		<category><![CDATA[rm]]></category>
		<category><![CDATA[xargs]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=1597</guid>


		<description><![CDATA[<p>The linux <em>find</em> command is very powerful. I use it all the time, either manually or in cron scripts to delete useless Thumbs.db files for example. A word of caution however, if you intend on using the <em>-delete</em> flag with find (instead of -exec rm&#8230; or xargs etc.).</p>
<p>This is <strong><em>very bad</em></strong>:</p>
<pre class="brush: bash; title: ; notranslate">find / -delete -type f -name 'Thumbs.db' -mtime +7</pre>
<p>This is <strong>good</strong>:</p>
<pre class="brush: bash; title: ; notranslate">find / -type f -name 'Thumbs.db' -mtime +7 -delete</pre>
<p>The order of the -delete flag is very important. In the first case find will delete <strong>everything</strong> it finds (totally ignoring the subsequent criteria), whereas the second case will delete what is matched.</p>
<p>In other words, the order of the find flags/parameters/actions are very important. If you are in doubt, or even if you are not, you should always have a backup in case something goes wrong.<br />
<span id="more-1597"></span><br />
CentOS help for -delete flag:</p>
<blockquote><p>Delete files; true if removal succeeded.  If  the  removal  failed,  an  error  message  is issued.  Use of this action automatically turns on the ’-depth’ option.</p></blockquote>
<p>Fedora help for -delete flag:</p>
<blockquote><p>Delete  files;  true  if  removal succeeded.  If the removal failed, an error message is issued.  If -delete fails, find&#8217;s exit status will be nonzero (when it eventually exits).  Use of -delete  automatically turns on the `-depth&#8217; option.</p>
<p>Warnings:  Don&#8217;t forget that the find command line is evaluated as an expression, so putting -delete first will make find try to delete everything below the starting points you specified.  When testing a  find command line that you later intend to use with -delete, you should explicitly specify -depth in order to avoid later surprises.  Because -delete implies -depth, you cannot usefully  use  -prune and -delete together.</p></blockquote>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/' rel='bookmark' title='Using sed to search and replace contents of next line in a file.'>Using sed to search and replace contents of next line in a file.</a></li>
<li><a href='http://blog.ergatides.com/2011/06/14/automatically-download-and-merge-multiple-pdf-files-with-a-unix-shell/' rel='bookmark' title='Automatically download and merge multiple PDF files with a Unix shell.'>Automatically download and merge multiple PDF files with a Unix shell.</a></li>
<li><a href='http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/' rel='bookmark' title='Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)'>Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The linux <em>find</em> command is very powerful. I use it all the time, either manually or in cron scripts to delete useless Thumbs.db files for example. A word of caution however, if you intend on using the <em>-delete</em> flag with find (instead of -exec rm&#8230; or xargs etc.).</p>
<p>This is <strong><em>very bad</em></strong>:</p>
<pre class="brush: bash; title: ; notranslate">find / -delete -type f -name 'Thumbs.db' -mtime +7</pre>
<p>This is <strong>good</strong>:</p>
<pre class="brush: bash; title: ; notranslate">find / -type f -name 'Thumbs.db' -mtime +7 -delete</pre>
<p>The order of the -delete flag is very important. In the first case find will delete <strong>everything</strong> it finds (totally ignoring the subsequent criteria), whereas the second case will delete what is matched.</p>
<p>In other words, the order of the find flags/parameters/actions are very important. If you are in doubt, or even if you are not, you should always have a backup in case something goes wrong.<br />
<span id="more-1597"></span><br />
CentOS help for -delete flag:</p>
<blockquote><p>Delete files; true if removal succeeded.  If  the  removal  failed,  an  error  message  is issued.  Use of this action automatically turns on the ’-depth’ option.</p></blockquote>
<p>Fedora help for -delete flag:</p>
<blockquote><p>Delete  files;  true  if  removal succeeded.  If the removal failed, an error message is issued.  If -delete fails, find&#8217;s exit status will be nonzero (when it eventually exits).  Use of -delete  automatically turns on the `-depth&#8217; option.</p>
<p>Warnings:  Don&#8217;t forget that the find command line is evaluated as an expression, so putting -delete first will make find try to delete everything below the starting points you specified.  When testing a  find command line that you later intend to use with -delete, you should explicitly specify -depth in order to avoid later surprises.  Because -delete implies -depth, you cannot usefully  use  -prune and -delete together.</p></blockquote>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/' rel='bookmark' title='Using sed to search and replace contents of next line in a file.'>Using sed to search and replace contents of next line in a file.</a></li>
<li><a href='http://blog.ergatides.com/2011/06/14/automatically-download-and-merge-multiple-pdf-files-with-a-unix-shell/' rel='bookmark' title='Automatically download and merge multiple PDF files with a Unix shell.'>Automatically download and merge multiple PDF files with a Unix shell.</a></li>
<li><a href='http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/' rel='bookmark' title='Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)'>Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2012/01/09/be-careful-when-using-find-with-the-delete-flag-to-clean-old-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to install KDE on Fedora Core 13 and onwards.</title>
		<link>http://blog.ergatides.com/2011/11/18/how-to-install-kde-on-fedora-core-13-and-onwards/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-install-kde-on-fedora-core-13-and-onwards</link>
		<comments>http://blog.ergatides.com/2011/11/18/how-to-install-kde-on-fedora-core-13-and-onwards/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 09:46:27 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[fc16]]></category>
		<category><![CDATA[fedora core]]></category>
		<category><![CDATA[fedora core 16]]></category>
		<category><![CDATA[gnome 3]]></category>
		<category><![CDATA[groupinstall]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[skype]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=1264</guid>


		<description><![CDATA[<p>I haven&#8217;t used KDE for a very long time, obviously since before Fedora Core 13. Back then, the yum group for KDE was named <strong><em>kde-desktop</em></strong>, so a simple <strong><em>sudo yum groupinstall kde-dekstop</em></strong> would set you on your way.</p>
<p>Since FC13, the group name has changed to the not-so-obvious <strong><em>KDE Software Compilation</em></strong>.</p>
<p><strong>sudo yum groupinstall &#8220;KDE Software Compilation&#8221;</strong> (with the quotes) and you&#8217;re off!</p>
<p>I&#8217;m installing KDE in a fresh install of FC16 as I&#8217;m writing this, because like <a href="http://mamchenkov.net/wordpress/2011/11/09/fedora-16-going-back-to-kde-4/" target="_blank">Leonid</a>, <em>one</em> of the things which annoy me about GNOME 3 is the inability to see a Skype icon with notifications of incoming chats without having to move your mouse to bottom right corner all the time. We are using Skype as an example here, there are of course other icons which one might miss, such as the Dropbox icon for example to know if any synchronisation is in progress.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2010/03/29/wireless-lan-for-runlevel-3-in-fedora-core-12/' rel='bookmark' title='Wireless LAN for Runlevel 3 in Fedora Core 12'>Wireless LAN for Runlevel 3 in Fedora Core 12</a></li>
<li><a href='http://blog.ergatides.com/2012/01/13/relative-path-to-absolute-path-in-a-bash-shell/' rel='bookmark' title='Relative path to absolute path in a bash shell.'>Relative path to absolute path in a bash shell.</a></li>
<li><a href='http://blog.ergatides.com/2009/11/30/installing-fedora-core-12-fc12-constantine-on-old-hardware/' rel='bookmark' title='Installing Fedora Core 12 (FC12 &#8220;Constantine&#8221;) on old hardware.'>Installing Fedora Core 12 (FC12 &#8220;Constantine&#8221;) on old hardware.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t used KDE for a very long time, obviously since before Fedora Core 13. Back then, the yum group for KDE was named <strong><em>kde-desktop</em></strong>, so a simple <strong><em>sudo yum groupinstall kde-dekstop</em></strong> would set you on your way.</p>
<p>Since FC13, the group name has changed to the not-so-obvious <strong><em>KDE Software Compilation</em></strong>.</p>
<p><strong>sudo yum groupinstall &#8220;KDE Software Compilation&#8221;</strong> (with the quotes) and you&#8217;re off!</p>
<p>I&#8217;m installing KDE in a fresh install of FC16 as I&#8217;m writing this, because like <a href="http://mamchenkov.net/wordpress/2011/11/09/fedora-16-going-back-to-kde-4/" target="_blank">Leonid</a>, <em>one</em> of the things which annoy me about GNOME 3 is the inability to see a Skype icon with notifications of incoming chats without having to move your mouse to bottom right corner all the time. We are using Skype as an example here, there are of course other icons which one might miss, such as the Dropbox icon for example to know if any synchronisation is in progress.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2010/03/29/wireless-lan-for-runlevel-3-in-fedora-core-12/' rel='bookmark' title='Wireless LAN for Runlevel 3 in Fedora Core 12'>Wireless LAN for Runlevel 3 in Fedora Core 12</a></li>
<li><a href='http://blog.ergatides.com/2012/01/13/relative-path-to-absolute-path-in-a-bash-shell/' rel='bookmark' title='Relative path to absolute path in a bash shell.'>Relative path to absolute path in a bash shell.</a></li>
<li><a href='http://blog.ergatides.com/2009/11/30/installing-fedora-core-12-fc12-constantine-on-old-hardware/' rel='bookmark' title='Installing Fedora Core 12 (FC12 &#8220;Constantine&#8221;) on old hardware.'>Installing Fedora Core 12 (FC12 &#8220;Constantine&#8221;) on old hardware.</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2011/11/18/how-to-install-kde-on-fedora-core-13-and-onwards/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Securing WordPress Dashboard using .htaccess behind CloudFlare (or any other CDN)</title>
		<link>http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn</link>
		<comments>http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 12:28:17 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cloudflare]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=1086</guid>


		<description><![CDATA[<p>You may wish to increase the security of your WordPress blog by doing this, or you may not. It&#8217;s a matter of preference. Before today I never bothered, but since I wanted to figure out how it can be done, now it makes no sense to remove the extra security.</p>
<p>In all cases, there are 2 areas that can be locked down from 2 separate .htaccess files. These are:</p>
<ul>
<li><strong>/wordpress/.htaccess</strong> to secure the wp-login.php file (used to log in).</li>
<li><strong>/wordpress/wp-admin/.htaccess</strong> to secure everything under the wp-admin directory.</li>
</ul>
<p>I want to allow only a few IP addresses to be able to access these areas. This is how it&#8217;s done without a cloud:</p>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/.htaccess
&lt;Files wp-login.php&gt;
    order deny,allow
    deny from all
    allow from 93.75.252.219
    allow from 110.170.50.32
&lt;/Files&gt;
</pre>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/wp-admin/.htaccess
order deny,allow
deny from all
allow from 93.75.252.219
allow from 110.170.50.32
</pre>
<p>Access to the login and admin areas of your website are now restricted to only the IPs you allow. If however, you are using a service like <a href="http://www.cloudflare.com/" target="_blank" title="CloudFlare">CloudFlare</a>, the above will not work because apache can&#8217;t see your (the visitor&#8217;s) IP address. Let&#8217;s fix this:</p>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/.htaccess
&lt;Files wp-login.php&gt;
    SetEnvIf X-FORWARDED-FOR 93.75.252.219 allowedip
    SetEnvIf X-FORWARDED-FOR 110.170.50.32 allowedip
    order deny,allow
    deny from all
    allow from allowedip
&lt;/Files&gt;
</pre>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/wp-admin/.htaccess
SetEnvIf X-FORWARDED-FOR 93.75.252.219 allowedip
SetEnvIf X-FORWARDED-FOR 110.170.50.32 allowedip
order deny,allow
deny from all
allow from allowedip
</pre>
<p>Apache is now reading your IP address and setting the <em>allowedip</em> environment variable which is then whitelisted on the last line.</p>
<p>Note that you should *not* rely on this security measure alone since an IP address you have whitelisted can and may be spoofed. Always monitor your access logs and combine this with other security methods (such as basic authentication for example) to further increase security.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/' rel='bookmark' title='Using sed to search and replace contents of next line in a file.'>Using sed to search and replace contents of next line in a file.</a></li>
<li><a href='http://blog.ergatides.com/2010/06/18/inove-theme-by-neoease-for-wordpress-3-0/' rel='bookmark' title='iNove theme by NeoEase for WordPress 3.0'>iNove theme by NeoEase for WordPress 3.0</a></li>
<li><a href='http://blog.ergatides.com/2011/06/08/cloudflare-threat-control-require-captcha-by-country/' rel='bookmark' title='CloudFlare threat control. Require captcha by country.'>CloudFlare threat control. Require captcha by country.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>You may wish to increase the security of your WordPress blog by doing this, or you may not. It&#8217;s a matter of preference. Before today I never bothered, but since I wanted to figure out how it can be done, now it makes no sense to remove the extra security.</p>
<p>In all cases, there are 2 areas that can be locked down from 2 separate .htaccess files. These are:</p>
<ul>
<li><strong>/wordpress/.htaccess</strong> to secure the wp-login.php file (used to log in).</li>
<li><strong>/wordpress/wp-admin/.htaccess</strong> to secure everything under the wp-admin directory.</li>
</ul>
<p>I want to allow only a few IP addresses to be able to access these areas. This is how it&#8217;s done without a cloud:</p>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/.htaccess
&lt;Files wp-login.php&gt;
    order deny,allow
    deny from all
    allow from 93.75.252.219
    allow from 110.170.50.32
&lt;/Files&gt;
</pre>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/wp-admin/.htaccess
order deny,allow
deny from all
allow from 93.75.252.219
allow from 110.170.50.32
</pre>
<p>Access to the login and admin areas of your website are now restricted to only the IPs you allow. If however, you are using a service like <a href="http://www.cloudflare.com/" target="_blank" title="CloudFlare">CloudFlare</a>, the above will not work because apache can&#8217;t see your (the visitor&#8217;s) IP address. Let&#8217;s fix this:</p>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/.htaccess
&lt;Files wp-login.php&gt;
    SetEnvIf X-FORWARDED-FOR 93.75.252.219 allowedip
    SetEnvIf X-FORWARDED-FOR 110.170.50.32 allowedip
    order deny,allow
    deny from all
    allow from allowedip
&lt;/Files&gt;
</pre>
<pre class="brush: plain; title: ; notranslate">
# add the following lines to /wordpress/wp-admin/.htaccess
SetEnvIf X-FORWARDED-FOR 93.75.252.219 allowedip
SetEnvIf X-FORWARDED-FOR 110.170.50.32 allowedip
order deny,allow
deny from all
allow from allowedip
</pre>
<p>Apache is now reading your IP address and setting the <em>allowedip</em> environment variable which is then whitelisted on the last line.</p>
<p>Note that you should *not* rely on this security measure alone since an IP address you have whitelisted can and may be spoofed. Always monitor your access logs and combine this with other security methods (such as basic authentication for example) to further increase security.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/24/using-sed-to-search-and-replace-contents-of-next-line-in-a-file/' rel='bookmark' title='Using sed to search and replace contents of next line in a file.'>Using sed to search and replace contents of next line in a file.</a></li>
<li><a href='http://blog.ergatides.com/2010/06/18/inove-theme-by-neoease-for-wordpress-3-0/' rel='bookmark' title='iNove theme by NeoEase for WordPress 3.0'>iNove theme by NeoEase for WordPress 3.0</a></li>
<li><a href='http://blog.ergatides.com/2011/06/08/cloudflare-threat-control-require-captcha-by-country/' rel='bookmark' title='CloudFlare threat control. Require captcha by country.'>CloudFlare threat control. Require captcha by country.</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2011/09/07/securing-wordpress-dashboard-using-htaccess-behind-cloudflare-or-any-other-cdn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH configuration: single host, multiple users.</title>
		<link>http://blog.ergatides.com/2011/09/05/ssh-configuration-single-host-multiple-users/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ssh-configuration-single-host-multiple-users</link>
		<comments>http://blog.ergatides.com/2011/09/05/ssh-configuration-single-host-multiple-users/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 13:44:25 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[multiple]]></category>
		<category><![CDATA[per-user]]></category>
		<category><![CDATA[profiles]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh_config]]></category>
		<category><![CDATA[usernames]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=1069</guid>


		<description><![CDATA[<p>A colleague of mine recently reminded me of the per-user ssh config file the other day, which typically lives at <em>~/.ssh/config</em> or <em>/home/user/.ssh/config</em></p>
<p>In this file you can define multiple ssh connections that you frequent and this becomes even more useful if you have many hosts/accounts to connect to.</p>
<p>Consider the following:</p>
<blockquote><p>ssh user1@example.com -p2222</p></blockquote>
<p>Sure, it&#8217;s easy to remember, but what if you have many hosts, each with different ports?</p>
<p>Whilst reminding me about the config file however, he complained that you can&#8217;t define 2 different users for the same system. This isn&#8217;t true, and this is how it&#8217;s done:</p>
<blockquote><p>Host user1<br />
HostName ssh.example.com<br />
User user1<br />
Port 2222</p>
<p>Host user2<br />
HostName ssh.example.com<br />
User user2<br />
Port 2222</p></blockquote>
<p>That&#8217;s all! Now, when using ssh, you can just type &#8220;ssh &#8221; and the first few characters of a Host and then hit tab to get a list of all available accounts. The autocompletion comes from the &#8220;Host&#8221; definition. Inside any Host profile, you can basically use any other parameter documented in `man ssh_config`. Definition for <em>Host</em> as follows:</p>
<blockquote><p><strong>Host</strong> Restricts the following declarations (up to the next Host keyword) to be only for those hosts that match one of the patterns given after the keyword.  If more than one pattern is provided, they should be separated by whitespace.  A single ‘*’ as a pattern can be used to provide global defaults for all hosts.  The host is the hostname argument given on the command line (i.e. the name is not converted to a canonicalized host name before matching).</p></blockquote>
<p><span style="color: #800000;"><strong>Edit</strong></span>: As pointed out by <a title="Leonid" href="http://mamchenkov.net/wordpress/" target="_blank">Leonid</a>, you will need `yum install bash-completion` or its equivalent for host autocompletion to work.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/24/what-nobody-does-is-nobodys-business/' rel='bookmark' title='What nobody does is nobody&#8217;s business.'>What nobody does is nobody&#8217;s business.</a></li>
<li><a href='http://blog.ergatides.com/2009/12/02/apache-virtual-hosts-_default_-and-servername/' rel='bookmark' title='Apache virtual hosts, _default_ and ServerName'>Apache virtual hosts, _default_ and ServerName</a></li>
<li><a href='http://blog.ergatides.com/2011/06/14/automatically-download-and-merge-multiple-pdf-files-with-a-unix-shell/' rel='bookmark' title='Automatically download and merge multiple PDF files with a Unix shell.'>Automatically download and merge multiple PDF files with a Unix shell.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>A colleague of mine recently reminded me of the per-user ssh config file the other day, which typically lives at <em>~/.ssh/config</em> or <em>/home/user/.ssh/config</em></p>
<p>In this file you can define multiple ssh connections that you frequent and this becomes even more useful if you have many hosts/accounts to connect to.</p>
<p>Consider the following:</p>
<blockquote><p>ssh user1@example.com -p2222</p></blockquote>
<p>Sure, it&#8217;s easy to remember, but what if you have many hosts, each with different ports?</p>
<p>Whilst reminding me about the config file however, he complained that you can&#8217;t define 2 different users for the same system. This isn&#8217;t true, and this is how it&#8217;s done:</p>
<blockquote><p>Host user1<br />
HostName ssh.example.com<br />
User user1<br />
Port 2222</p>
<p>Host user2<br />
HostName ssh.example.com<br />
User user2<br />
Port 2222</p></blockquote>
<p>That&#8217;s all! Now, when using ssh, you can just type &#8220;ssh &#8221; and the first few characters of a Host and then hit tab to get a list of all available accounts. The autocompletion comes from the &#8220;Host&#8221; definition. Inside any Host profile, you can basically use any other parameter documented in `man ssh_config`. Definition for <em>Host</em> as follows:</p>
<blockquote><p><strong>Host</strong> Restricts the following declarations (up to the next Host keyword) to be only for those hosts that match one of the patterns given after the keyword.  If more than one pattern is provided, they should be separated by whitespace.  A single ‘*’ as a pattern can be used to provide global defaults for all hosts.  The host is the hostname argument given on the command line (i.e. the name is not converted to a canonicalized host name before matching).</p></blockquote>
<p><span style="color: #800000;"><strong>Edit</strong></span>: As pointed out by <a title="Leonid" href="http://mamchenkov.net/wordpress/" target="_blank">Leonid</a>, you will need `yum install bash-completion` or its equivalent for host autocompletion to work.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2012/01/24/what-nobody-does-is-nobodys-business/' rel='bookmark' title='What nobody does is nobody&#8217;s business.'>What nobody does is nobody&#8217;s business.</a></li>
<li><a href='http://blog.ergatides.com/2009/12/02/apache-virtual-hosts-_default_-and-servername/' rel='bookmark' title='Apache virtual hosts, _default_ and ServerName'>Apache virtual hosts, _default_ and ServerName</a></li>
<li><a href='http://blog.ergatides.com/2011/06/14/automatically-download-and-merge-multiple-pdf-files-with-a-unix-shell/' rel='bookmark' title='Automatically download and merge multiple PDF files with a Unix shell.'>Automatically download and merge multiple PDF files with a Unix shell.</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2011/09/05/ssh-configuration-single-host-multiple-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fedora 15 NVIDIA external Samsung SyncMaster&#8230; finally!</title>
		<link>http://blog.ergatides.com/2011/08/21/fedora-15-nvidia-external-samsung-syncmaster-finally/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fedora-15-nvidia-external-samsung-syncmaster-finally</link>
		<comments>http://blog.ergatides.com/2011/08/21/fedora-15-nvidia-external-samsung-syncmaster-finally/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 18:48:41 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[1000m]]></category>
		<category><![CDATA[fc15]]></category>
		<category><![CDATA[fedora 15]]></category>
		<category><![CDATA[lenovo]]></category>
		<category><![CDATA[nvidia]]></category>
		<category><![CDATA[samsung]]></category>
		<category><![CDATA[syncmaster quadro]]></category>
		<category><![CDATA[w520]]></category>

		<guid isPermaLink="false">http://blog.ergatides.com/?p=941</guid>


		<description><![CDATA[<p>Ever since Fedora 15 came out, I couldn&#8217;t get my external monitor to work with my Lenovo <a href="http://www.amazon.co.uk/gp/product/B004WNAXFS/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&#038;tag=peblofcher-21&#038;linkCode=as2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=B004WNAXFS" target="_blank" title="Lenovo W520" rel="nofollow">W520</a> laptop which has an NVIDIA Quadro 1000M graphics adapter. I am using the proprietary driver and no matter what settings I would choose, I&#8217;d always get a nasty &#8220;Oops, something went wrong!&#8221; error message when logging in. I knew that there shouldn&#8217;t be a problem as I dual boot into Win7 and the external monitor was working fine.</p>
<p>Today I tried a few more combinations and finally got it working, most probably because I have chosen &#8220;TwinView&#8221; in the configuration, rather than &#8220;Separate X screen&#8221;. I also specified each screen&#8217;s resolution and refresh rates instead of leaving everything on &#8220;Auto&#8221;. Further settings include:</p>
<ul>
<li>Screen 0: Absolute Position +0+0</li>
<li>Screen 0: Make this the primary display for the X screen</li>
<li>Screen 1: Position +1920+0 (where 1920 is the width of the laptop display)</li>
</ul>
<p>My setup is perfect again.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2011/06/26/fedora-gnome-3-show-desktop-keyboard-shortcut/' rel='bookmark' title='Fedora GNOME 3 show desktop keyboard shortcut.'>Fedora GNOME 3 show desktop keyboard shortcut.</a></li>
<li><a href='http://blog.ergatides.com/2009/11/30/installing-fedora-core-12-fc12-constantine-on-old-hardware/' rel='bookmark' title='Installing Fedora Core 12 (FC12 &#8220;Constantine&#8221;) on old hardware.'>Installing Fedora Core 12 (FC12 &#8220;Constantine&#8221;) on old hardware.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Ever since Fedora 15 came out, I couldn&#8217;t get my external monitor to work with my Lenovo <a href="http://www.amazon.co.uk/gp/product/B004WNAXFS/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&#038;tag=peblofcher-21&#038;linkCode=as2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=B004WNAXFS" target="_blank" title="Lenovo W520" rel="nofollow">W520</a> laptop which has an NVIDIA Quadro 1000M graphics adapter. I am using the proprietary driver and no matter what settings I would choose, I&#8217;d always get a nasty &#8220;Oops, something went wrong!&#8221; error message when logging in. I knew that there shouldn&#8217;t be a problem as I dual boot into Win7 and the external monitor was working fine.</p>
<p>Today I tried a few more combinations and finally got it working, most probably because I have chosen &#8220;TwinView&#8221; in the configuration, rather than &#8220;Separate X screen&#8221;. I also specified each screen&#8217;s resolution and refresh rates instead of leaving everything on &#8220;Auto&#8221;. Further settings include:</p>
<ul>
<li>Screen 0: Absolute Position +0+0</li>
<li>Screen 0: Make this the primary display for the X screen</li>
<li>Screen 1: Position +1920+0 (where 1920 is the width of the laptop display)</li>
</ul>
<p>My setup is perfect again.</p>
<p>Related posts:</p><ol>
<li><a href='http://blog.ergatides.com/2011/06/26/fedora-gnome-3-show-desktop-keyboard-shortcut/' rel='bookmark' title='Fedora GNOME 3 show desktop keyboard shortcut.'>Fedora GNOME 3 show desktop keyboard shortcut.</a></li>
<li><a href='http://blog.ergatides.com/2009/11/30/installing-fedora-core-12-fc12-constantine-on-old-hardware/' rel='bookmark' title='Installing Fedora Core 12 (FC12 &#8220;Constantine&#8221;) on old hardware.'>Installing Fedora Core 12 (FC12 &#8220;Constantine&#8221;) on old hardware.</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2011/08/21/fedora-15-nvidia-external-samsung-syncmaster-finally/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

