<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.deadgod.net/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.deadgod.net/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
	<channel>
		<title>DranoK's Linux Wisdom</title>
		<link>http://linux.DeadGod.net</link>
		<description>Regularly published original articles and HOWTOs about Linux specifically and UNIX in general.</description>
		<dc:date>2008-07-24T17:07:55Z</dc:date>
		<copyright>DeadGod.Net</copyright>
		<generator>DeadGod CMS System</generator>
		<dc:language>en</dc:language>
		<dc:creator>Nick "LiQUiD_X" Johnson</dc:creator>
		<geo:lat>37.378341</geo:lat><geo:long>-122.023987</geo:long><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.deadgod.net/DranoksLinuxWisdom" type="application/rss+xml" /><feedburner:emailServiceId>923156</feedburner:emailServiceId><feedburner:feedburnerHostname>http://www.feedburner.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.deadgod.net%2FDranoksLinuxWisdom" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.deadgod.net%2FDranoksLinuxWisdom" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.deadgod.net%2FDranoksLinuxWisdom" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.rojo.com/add-subscription?resource=http%3A%2F%2Ffeeds.deadgod.net%2FDranoksLinuxWisdom" src="http://blog.rojo.com/RojoWideRed.gif">Subscribe with Rojo</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.deadgod.net/DranoksLinuxWisdom" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.deadgod.net%2FDranoksLinuxWisdom" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.deadgod.net%2FDranoksLinuxWisdom" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.deadgod.net%2FDranoksLinuxWisdom" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:browserFriendly>Regularly published original articles and HOWTOs about Linux specifically and UNIX in general.</feedburner:browserFriendly><item>
			<title>DIY Render Farm</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/277156279/DIY_Render_Farm</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[Nice.<br />
<br />
<a href="http://dranok.DeadGod.net/full/Pics/Random/19-helmer-klar.jpg" target="_blank"><img src="http://dranok.DeadGod.net/normalizedblog/Pics/Random/19-helmer-klar.jpg" border="0" alt="" /></a><br />
<br />
<a href="http://helmer.sfe.se/" target="_blank">This is the story of Helmer. A linux cluster in a IKEA Helmer cabinet.</a><br />
<br />
<div style="width: 100%; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="6" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2" style="border:1px inset">
			
				3D computer rendering are very CPU intensive and the best way so speed up slow render problems, are usually to distribute them on to more computers. Render farms are usually very large, expensive and run using ALLOT of energy. I wanted to build something that could be put in my home, not make too much noise and run using very little energy... and be dirt cheep, big problem? :) no computer stuff cost almost nothing these days, it just a matter of finding fun stuff to play with.
			
		</td>
	</tr>
	</table>
</div><div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=ILGzgBG"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=ILGzgBG" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=UxvtXxg"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=UxvtXxg" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=vPbfb5g"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=vPbfb5g" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=qX8YumG"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=qX8YumG" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=l1GNlQg"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=l1GNlQg" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=O82NxtG"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=O82NxtG" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=OEe7QQg"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=OEe7QQg" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=G3hGSFG"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=G3hGSFG" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/277156279" height="1" width="1"/>]]></content:encoded>
			<dc:date>2008-04-24T15:36:52-05:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2008/04/24/DIY_Render_Farm</guid>
			<category>Link</category>
		<feedburner:origLink>http://linux.DeadGod.net/2008/04/24/DIY_Render_Farm</feedburner:origLink></item>
		<item>
			<title>Singularity, Part IV:  Performance Testing</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/223101214/Singularity_Part_IV__Performance_Testing</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[<font size="5">Singularity, Part IV: Performance Testing</font><br />
<br />
<font size="4">Articles in this series</font><br />
<a href="http://blog.deadgod.net/2007/11/07/Singularity_Part_I_Confessions_of_a_Digital_Pack_Rat" target="_blank">Singularity, Part I: Confessions of a Digital Pack Rat</a><br />
<a href="http://blog.deadgod.net/2007/11/15/Singularity_Part_II_The_Network_Upgrade" target="_blank">Singularity, Part II: The Network Upgrade</a><br />
<a href="http://linux.deadgod.net/2007/12/06/Singularity_Part_III_Construction" target="_blank">Singularity, Part III: Construction</a><br />
<b>Singularity, Part IV: Performance Testing</b><br />
Singularity, Part V: Conclusion<br />
<br />
<font size="4">Intro</font><br />
<br />
With Sin successfully built the big question on our minds was how ZFS would compare to ext3 + md software raid on our hardware.  To discover this we spent the first weekend after the server was built running the benchmarks below.<br />
<br />
<font size="4">Setup</font><br />
<br />
Unfortunately Ubuntu out of the box had problems with the two array drives sitting on the motherboard rather than the PCI-X controller.  We found a bug report for it but didn't feel like updating the kernel just to fix it.  Instead we built an 8-disk array instead of a 10-disk for these tests.  We're now running a full 10-disk array which obviously performs slightly better than the 8-disk benchmarks below.<br />
<br />
What impressed me most about ZFS is that it doesn't need to construct the new disk array.  On Linux, md must construct the array, usually by flagging one of the disks as faulty and rebuilding.  For both the raid5 and raid6 setups below this took over nine hours under Ubuntu.  ZFS, by contrast, doesn't (at least as long as you give it entire disks to use).  The array was available for us immediately.<br />
<br />
Our tests involved unpacking (not uncompressing) the Linux 2.6.23 kernel tarball, writing a 1GB dd file filled with zeros, and using a benchmarking utility called <a href="http://www.coker.com.au/bonnie++/" target="_blank">Bonnie++</a>.<br />
<br />
<br />
<font size="4"><div align="center"><a href="http://linux.DeadGod.net/2008/01/25/Singularity_Part_IV__Performance_Testing" target="_blank">Click here for the rest of this article.</a></div></font><div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=bi7WwKD"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=bi7WwKD" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=gl3LZ5d"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=gl3LZ5d" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=x2u3hid"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=x2u3hid" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=E9KXaVD"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=E9KXaVD" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=a0FE3fd"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=a0FE3fd" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=AAvRefD"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=AAvRefD" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=2zYp9rd"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=2zYp9rd" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=M5ikTtD"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=M5ikTtD" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/223101214" height="1" width="1"/>]]></content:encoded>
			<dc:date>2008-01-25T13:19:21-06:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2008/01/25/Singularity_Part_IV__Performance_Testing</guid>
			<category>Story</category>
		<feedburner:origLink>http://linux.DeadGod.net/2008/01/25/Singularity_Part_IV__Performance_Testing</feedburner:origLink></item>
		<item>
			<title>Video Codec Trojans</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/207246235/Video_Codec_Trojans</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[Something to be aware of while downloading anime/movies/whatever:<br />
<br />
<a href="http://www.securityfocus.com/brief/650" target="_blank">http://www.securityfocus.com/brief/650</a><br />
<br />
<div style="width: 100%; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="6" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2" style="border:1px inset">
			
				Trojan horse programs dressed up like video decoders, or codecs, have become a popular way to attempt to infect the computers of unwary Web surfers.
			
		</td>
	</tr>
	</table>
</div>In other news, Singularity is built and running, I've just been bogged down with other things to finish writing it.  Hopefully part 4 will be up tomorrow.<div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=ZKE8n2C"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=ZKE8n2C" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=1eCZfPc"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=1eCZfPc" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=ArCafTc"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=ArCafTc" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=NvFvQKC"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=NvFvQKC" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=xgmH5Zc"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=xgmH5Zc" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=ECEHzhC"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=ECEHzhC" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=QErCZoc"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=QErCZoc" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=PBoHEAC"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=PBoHEAC" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/207246235" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-12-27T17:08:39-06:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/12/27/Video_Codec_Trojans</guid>
			<category>News</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/12/27/Video_Codec_Trojans</feedburner:origLink></item>
		<item>
			<title>Singularity, Part III: Construction</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/195976402/Singularity_Part_III_Construction</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[<font size="5">Singularity, Part III: Construction</font><br />
<br />
<font size="4">Articles in this series</font><br />
<a href="http://blog.deadgod.net/2007/11/07/Singularity_Part_I_Confessions_of_a_Digital_Pack_Rat" target="_blank">Singularity, Part I: Confessions of a Digital Pack Rat</a><br />
<a href="http://blog.deadgod.net/2007/11/15/Singularity_Part_II_The_Network_Upgrade" target="_blank">Singularity, Part II: The Network Upgrade</a><br />
<b>Singularity, Part III: Construction</b><br />
<a href="http://blog.deadgod.net/2008/01/25/Singularity_Part_IV__Performance_Testing" target="_blank">Singularity, Part IV: Performance Testing</a><br />
Singularity, Part V: Conclusion<br />
<br />
<font size="4">Intro</font><br />
<br />
This part has been delayed a bit.  First, at least one memory DIMM was bad.  Second, the motherboard had two fried SATA ports.  Thrid, it was Thanksgiving weekend, so getting RMAs placed was nearly impossible.<br />
<br />
Still, we got everything up and running.  I won't do much more talking here.  This part is mainly for the pics! ;)<br />
<br />
<br />
<font size="4"><div align="center"><a href="http://linux.DeadGod.net/2007/12/06/Singularity_Part_III_Construction" target="_blank">Click here for the rest of this article.</a></div></font><div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=6VL8JAC"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=6VL8JAC" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=qMU6HGc"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=qMU6HGc" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=TfLc5cc"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=TfLc5cc" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=GhDYlKC"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=GhDYlKC" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=Ql40C9c"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=Ql40C9c" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=oJ5sJBC"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=oJ5sJBC" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=6HoL25c"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=6HoL25c" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=FBnag7C"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=FBnag7C" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/195976402" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-12-06T02:25:00-06:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/12/06/Singularity_Part_III_Construction</guid>
			<category>Story</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/12/06/Singularity_Part_III_Construction</feedburner:origLink></item>
		<item>
			<title>Long live IPv4</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/191409074/Long_live_IPv4</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[This is why IPv4 will be around for a long tome to come.<br />
<br />
<a href="http://dranok.DeadGod.net/full/Pics/Random/map-of-the-ipv4-address-space.png" target="_blank"><img src="http://dranok.DeadGod.net/normalizedblog/Pics/Random/map-of-the-ipv4-address-space.png" border="0" alt="" /></a><div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=5yHudaB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=5yHudaB" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=Hy1iUgb"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=Hy1iUgb" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=RF6Us9b"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=RF6Us9b" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=teAlZCB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=teAlZCB" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=SxWfRfb"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=SxWfRfb" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=XJCwhcB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=XJCwhcB" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=UvciHIb"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=UvciHIb" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=LH09ZIB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=LH09ZIB" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/191409074" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-11-27T12:29:48-06:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/11/27/Long_live_IPv4</guid>
			<category>Image</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/11/27/Long_live_IPv4</feedburner:origLink></item>
		<item>
			<title>Singularity, Part II: The Network Upgrade</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/185467784/Singularity_Part_II_The_Network_Upgrade</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[<font size="5">Singularity, Part II: The Network Upgrade</font><br />
<br />
<font size="4">Articles in this series</font><br />
<a href="http://blog.deadgod.net/2007/11/07/Singularity_Part_I_Confessions_of_a_Digital_Pack_Rat" target="_blank">Singularity, Part I: Confessions of a Digital Pack Rat</a><br />
<b>Singularity, Part II: The Network Upgrade</b> [<a href="http://liquidx.DeadGod.net/Nicks_Photos/Singularity/PDRM0011.JPG" target="_blank">Image 1</a>] [<a href="http://liquidx.deadgod.net/Nicks_Photos/Singularity/PDRM0012.JPG" target="_blank">Image 2</a>]<br />
<a href="http://linux.deadgod.net/2007/12/06/Singularity_Part_III_Construction" target="_blank">Singularity, Part III: Construction</a><br />
<a href="http://blog.deadgod.net/2008/01/25/Singularity_Part_IV__Performance_Testing" target="_blank">Singularity, Part IV: Performance Testing</a><br />
Singularity, Part V: Conclusion<br />
<br />
<font size="4">Home Gigabit Network</font><br />
<br />
Gigabit networking has recently become an option for consumer budgets.  This advance has been fueled by the proliferation of cheap, unmanaged switches by Netgear and Cisco.<br />
<br />
Most of these were four-port or possibly eight-port creatures, however--most consumers didn't have a need for more than this.  Businesses still preferred more expensive managed switches for their production network, and their office network often didn't need it.  Especially if everyone is in love with wireless.<br />
<br />
This is changing, slowly, as people become disillusioned with cubical wireless and trend back toward wired access.  As storage continues to increase the uses for it explode.  More and more people start to demand gigabit speeds.<br />
<br />
Many corporations have already deployed gigabit managed switches for their office environments.  Many small businesses, however, have not.  Larger-capacity unmanaged gigabit switches cater to small businesses like these, as well as the enthusiast market.<br />
<br />
<font size="4">The Gigabit Myth</font><br />
<br />
People often run network tests and find they're not getting &quot;true&quot; gigabit speeds (128 MiB/s).  Typically they blame the switch.  To some extent they're correct--cheap, unmanaged switches rarely perform well in a single transfer vs. their pricier cousins.  There are other reasons, however.<br />
<br />
Even with a <a href="http://www.wdraptorx.com/en/specifications/" target="_blank">RaptorX SATAII drive</a>, the absolute best-case transfer rate you're going to get (buffer -&gt; disk) is 84 MB/s.  I'm not sure if this is MB or MiB--regardless it's a far cry from 128MiB/s.  And that's just your raw 10k disk speed.  If your network ports are built into your motherboard you're going to have a slowdown any time your CPU is busy (like when it's buffering and writing disk data).  PCI network cards are typically no better, unless it's a PCI-X or PCI-E with offloaded processing.<br />
<br />
Where gigabit networks shine, however, is in multiple transfers.  Sure, any single given device may not seem like it's taking advantage of gigabit--but when two or more devices are transferring data at the same time you will definitely notice a difference.<br />
<br />
<font size="4">The New Network</font><br />
<br />
We jumped to gigabit for the first time when we built Sol.  We quickly ran out of ports, however, and have been hobbling along with a 16-port 10/100 Linksys trunked switch ever since.<br />
<br />
With cheaper, higher-capacity gigabit switches now available we took this opportunity to scoop one up.<br />
<br />
<a href="http://dranok.DeadGod.net/full/Pics/Random/enus_left-lores_product_gs116.jpg" target="_blank"><img src="http://dranok.DeadGod.net/normalizedblog/Pics/Random/enus_left-lores_product_gs116.jpg" border="0" alt="" /></a><br />
<br />
We also had a cabling rat's nest problem, as most people probably do.  You never have the right length of ethernet cables so inevitably end up with 15ft monsters connecting devices which are two feet from each other.  We decided we wanted to buy our own cabling kit and crimp new cables ourselves so we could better control the length.  We found a good deal on a kit:<br />
<br />
<a href="http://dranok.DeadGod.net/full/Pics/Random/C184-28428-main.jpg" target="_blank"><img src="http://dranok.DeadGod.net/normalizedblog/Pics/Random/C184-28428-main.jpg" border="0" alt="" /></a><br />
<br />
We especially enjoyed the Engrish instructions :)<br />
<br />
<a href="http://liquidx.DeadGod.net/full/Nicks_Photos/Singularity/cabletester.gif" target="_blank"><img src="http://liquidx.DeadGod.net/normalizedblog/Nicks_Photos/Singularity/cabletester.gif" border="0" alt="" /></a><br />
<br />
<font size="4">Beyond Gigabit</font><br />
<br />
Now that we had an excess of ports it was time to push Sol beyond gigabit speeds.  Since we had two gigabit NICs available here we decided to aggregate them into a single, bonded device.<br />
<br />
Network bonding is a method of combining two independent NICs into a single virtual device to provide both redundancy and higher throughput.  Under Linux there are many different network bonding modes available, from simple round-robin load balancing to advanced load balancing.  For our purposes we chose mode 6, or &quot;Adaptive load balancing&quot;.  The actual details of network bonding is beyond the scope of this document; more information can be found in your kernel distribution (<a href="http://www.id.ethz.ch/about/sections/kom/dkid/themas/link-aggregation/bonding" target="_blank">/usr/src/linux/Documentation/networking/bonding.txt</a>)<br />
<br />
Now our current fileserver is running at two gigabit while all our other nodes are at regular gigabit.  We are now I/O bound on Sol, however this should speed up simultaneous access.  As an added bonus, we can run new ethernet cables and swap ports without causing a network interruption.<br />
<br />
<font size="4"><a href="http://linux.deadgod.net/2007/12/06/Singularity_Part_III_Construction" target="_blank">Next: Singularity, Part III: Construction</a></font><div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=RpFVLSB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=RpFVLSB" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=mbEdPib"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=mbEdPib" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=uCaDwFb"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=uCaDwFb" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=23Lz1JB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=23Lz1JB" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=lhqTGZb"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=lhqTGZb" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=s8yT6uB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=s8yT6uB" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=L0T2obb"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=L0T2obb" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=y0axhaB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=y0axhaB" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/185467784" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-11-15T16:53:17-06:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/11/15/Singularity_Part_II_The_Network_Upgrade</guid>
			<category>Story</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/11/15/Singularity_Part_II_The_Network_Upgrade</feedburner:origLink></item>
		<item>
			<title>Singularity, Part I: Confessions of a Digital Pack Rat</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/181303973/Singularity_Part_I_Confessions_of_a_Digital_Pack_Rat</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[<font size="5">Singularity, Part I: Confessions of a Digital Pack Rat</font><br />
<br />
<font size="4">Articles in this series</font><br />
<b>Singularity, Part I: Confessions of a Digital Pack Rat</b><br />
<a href="http://blog.deadgod.net/2007/11/15/Singularity_Part_II_The_Network_Upgrade" target="_blank">Singularity, Part II: The Network Upgrade</a> [<a href="http://liquidx.DeadGod.net/Nicks_Photos/Singularity/PDRM0011.JPG" target="_blank">Image 1</a>] [<a href="http://liquidx.deadgod.net/Nicks_Photos/Singularity/PDRM0012.JPG" target="_blank">Image 2</a>]<br />
<a href="http://linux.deadgod.net/2007/12/06/Singularity_Part_III_Construction" target="_blank">Singularity, Part III: Construction</a><br />
<a href="http://blog.deadgod.net/2008/01/25/Singularity_Part_IV__Performance_Testing" target="_blank">Singularity, Part IV: Performance Testing</a><br />
Singularity, Part V: Conclusion<br />
<br />
<br />
<font size="4">Prologue</font><br />
<br />
My desk is many men's worst nightmare.  Papers are strewn everywhere.  Pencils pour from every crevice.  Network charts which should be on the wall are buried under stacks of paper and cdroms.  That paperweight given to me as a gift is probably at the bottom of my trash bin--I trash anything that's not absolutely needed.  If I didn't I'd drown.<br />
<br />
It's not dirty, you understand.  It's <i>cluttered</i>.  Disorganized.<br />
<br />
It's a stark contrast to my digital world.  Here I'm a meticulously-organized pack rat.  I keep everything I download--I probably still have the NVidia drivers for my original GForce card somewhere under my vast hierarchical construct.<br />
<br />
Such an addiction comes at a cost.  My habit quickly outpaced available storage.  Luckily for me we live in the future, where gigantic fileservers can be assembled from consumer parts.  Where a digital pack rat can thrive.<br />
<br />
This is the story of the singularity--the fileserver that will succeed <a href="http://liquidx.deadgod.net/Nicks_Photos/Sol/all" target="_blank">sol</a> and retire jupiter.  The third incarnation of primal consumer storage.<br />
<br />
<font size="4"><div align="center"><a href="http://linux.DeadGod.net/2007/11/07/Singularity_Part_I_Confessions_of_a_Digital_Pack_Rat" target="_blank">Click here to view the full article.</a></div></font><div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=HJRjqHB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=HJRjqHB" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=wrm7UWb"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=wrm7UWb" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=D5AuUhb"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=D5AuUhb" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=M4ShYdB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=M4ShYdB" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=K3xdRdb"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=K3xdRdb" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=qOa7LbB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=qOa7LbB" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=bNZBO6b"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=bNZBO6b" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=SHII0dB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=SHII0dB" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/181303973" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-11-07T16:03:32-06:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/11/07/Singularity_Part_I_Confessions_of_a_Digital_Pack_Rat</guid>
			<category>Story</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/11/07/Singularity_Part_I_Confessions_of_a_Digital_Pack_Rat</feedburner:origLink></item>
		<item>
			<title>Scheduling jobs with at instead of cron</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/146194450/Scheduling_jobs_with_at_instead_of_cron</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[Most Linux admins are well-versed with <a href="http://www.linuxweblog.com/node/24" target="_blank">crontab</a>.  All too often, however, I see people using crontab to schedule a job that's only intended to run once.  This not only clutters your cron file but can potentially be dangerous if you forget to un-schedule your job before it runs again.<br />
<br />
Luckily there's an alternative:  <b>at</b><br />
<br />
<font size="1"><b>Prerequisites:</b></font><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">o Familiarity with the bash shell</pre></td></tr></tbody></table><br />
<br />
The <b>at</b> command simply runs a job once at some specified point in the future.  Unlike crontabs, which will only use your user environment if you explicitly tell it to, <b>at</b> will use your environment by default.<br />
<br />
The basic invocation patterns of <b>at</b> are:<br />
<br />
<font size="1"><b>Listing 1: Basic invocation:</b></font><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">1) at <i>time</i>
2) at <i>time</i> &lt; /file/with/commands
3) echo &quot;<i>some command</i>&quot; |at <i>time</i></pre></td></tr></tbody></table><br />
In the first example after pressing enter you will be dropped into the <i>at&gt;</i> shell.  Here type the commands, one per line, you would like to be executed.<br />
<br />
The second example is non-interactive.  Instead of typing your commands into the <i>at&gt;</i> shell, put them into the /file/with/commands file instead.  <b>Note that you <i>do not</i> put a shabang (#!/bin/sh) at the top of your script!</b>  If you have a script you want to run, do not specify &quot;at <i>time</i> &lt; /path/to/script&quot;--instead create a new text file with one line, &quot;/path/to/script&quot; in it, and use that file as your source to at (at <i>time</i> &lt; /path/to/newfile).<br />
<br />
The third example is useful if you want to run a single command at a specified time.  For example, &quot;echo /path/to/script |at <i>time</i>&quot;<br />
<br />
<font size="4"><div align="center"><a href="http://linux.DeadGod.net/2007/08/20/Scheduling_jobs_with_at_instead_of_cron" target="_blank">Click here to view the rest of the article</a></div></font><div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=MCUZBWwY"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=MCUZBWwY" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=Mu2Ig4tT"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=Mu2Ig4tT" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=2uDOHVwO"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=2uDOHVwO" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=s2GkmAL3"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=s2GkmAL3" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=DdIPdUXw"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=DdIPdUXw" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=5o4VauCg"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=5o4VauCg" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=iyUrOsLC"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=iyUrOsLC" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=lEhtRjGi"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=lEhtRjGi" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/146194450" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-08-20T12:45:40-05:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/08/20/Scheduling_jobs_with_at_instead_of_cron</guid>
			<category>Intermediate</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/08/20/Scheduling_jobs_with_at_instead_of_cron</feedburner:origLink></item>
		<item>
			<title>How to tunnel all traffic over DNS</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/137391463/How_to_tunnel_all_traffic_over_DNS</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[Wow, this tickles me in all the right ways.  Encapsulating base32-encoded data over TXT records.  Brilliant.<br />
<br />
<a href="http://dnstunnel.de/" target="_blank">http://dnstunnel.de/</a><br />
<br />
<div style="width: 100%; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="6" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2" style="border:1px inset">
			
				Well, since all subdomain resolve requests are delegatet (ie., relayed) to your host, you can include arbitrary data in the hostname which your server then can interpret and execute/relay.<br />
<br />
The bytes you want to send to the server (upstream) will be encoded using Base32 (if you know what Base64 is, Base32 is just the same except there is no case sensivitiy, for EXAMPLE.COM ist just the same as example.com). After the data, there is a unique ID (since some DNS requests may take longer than others and the UDP protocol has no methods to check this) and either one of the keywords up or down, indicating whether the traffic's up- or downstream. Here is what an example request could look like (transferring something to the server):<br />
<br />
ntez375sy2qk7jsg2og3eswo2jujscb3r43as6m6hl2ws<br />
xobm7h2olu4tmaq.lyazbf2e2rdynrd3fldvdy2w3tifi<br />
gy2csrx3cqczxyhnxygor72a7fx47uo.nwqy4oa3v5rx6<br />
6b4aek5krzkdm5btgz6jbiwd57ubnohnknpcuybg7py.6<br />
3026-0.id-32227.up.sshdns.feh.dnstunnel.de<br />
<br />
The server's response comes as a DNS TXT record. A TXT record can hold arbitrary ASCII data and can hold uppercase letters as well as lowercase letters and numbers (some other characters, as well). So the responses come Base64 encoded. Such a response might look like the following one:<br />
<br />
695-8859.id-39201.down.sshdns.feh.dnstunnel.de.   0       IN      TXT<br />
&quot;AAAAlAgfAAAAgQDKrd3sFmf8aLX6FdU8ThUy3SRWGhotR6EsA  avqHgBzH2khqsQHQjEf355jS7cT<br />
G+4a8kAmFVQ4mpEEJeBE6IyDWbAQ9a0rgOKcsaWwJ7GdngGm9j  pvReXX7S/2oqAIUFCn0M8=&quot;<br />
&quot;MHw9tR0kkDVZB7RCfCOpjfHrir7yuiCbt7FpyX8AAAABBQAAA  AAAAAAA&quot;
			
		</td>
	</tr>
	</table>
</div><div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=zFtjKZQf"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=zFtjKZQf" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=DrGZa3qV"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=DrGZa3qV" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=8WtMPdU0"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=8WtMPdU0" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=qXWxgOA4"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=qXWxgOA4" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=MKb86ii2"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=MKb86ii2" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=IU2ETrBe"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=IU2ETrBe" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=VJEjgwg0"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=VJEjgwg0" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=lIc4k7oQ"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=lIc4k7oQ" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/137391463" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-07-25T17:44:37-05:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/07/25/How_to_tunnel_all_traffic_over_DNS</guid>
			<category>Link</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/07/25/How_to_tunnel_all_traffic_over_DNS</feedburner:origLink></item>
		<item>
			<title>Make a script behave differently if run from cron</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/132711192/Make_a_script_behave_differently_if_run_from_cron</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[It can be useful at times to have a shell script behave differently if it's run interactively vs. run from cron or other non-interactive means.  For example, you may want the script to send email on certain conditions if it's run from cron, but simply print the message to standard out if it's being run interactively.<br />
<br />
<font size="1"><b>Prerequisites:</b></font><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">o Familiarity with the bash shell
o Shell scripting experience</pre></td></tr></tbody></table><br />
One solution is to wrap the interactive cron with a non-interactive script.  This generally isn't the best method as it requires duplicating code in two separate scripts and possibly creating hacked-together ways for the script to interact.<br />
<br />
A better solution is to test if the shell is a tty or not.<br />
<br />
<b><font size="1">Listing 1: Test if a shell is a TTY</font></b><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">#!/bin/bash

tty -s
TTYTEST=$?</pre></td></tr></tbody></table><br />
<b>$?</b> is a special bash variable which means the return code of the most recent command, in this case &quot;tty -s&quot;.  Unix commands generally return 0 on success, and some number greater than 0 on failure.  For &quot;tty -s&quot;, a 0 (success) return code means the shell is a TTY, while anything other than 0 means the shell is <i>not</i>.  We can now use $TTYTEST to alter the behavior of our script.<br />
<br />
<b><font size="1">Listing 2: Altering script flow based on TTY test</font></b><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">#!/bin/bash

tty -s
TTYTEST=$?

# Random script code here, until we want to do something different based on TTY

if [ $TTYTEST -gt 0 ]; then
  # Code to run if shell is NOT a TTY
else
  # Code to run if the shell IS a TTY
fi</pre></td></tr></tbody></table><br />
The &quot;-s&quot; option to the tty command tells it to run silently.  If you don't specify -s the tty command will print your TTY to standard out if you have one, or &quot;not a tty&quot; if you do not.  If you don't want to deal with return codes you can do the following, however personally I think assigning a variable to the return code of &quot;tty -s&quot; is a more elegant way of doing this.<br />
<br />
<b><font size="1">Listing 3: Alternate method to avoid using return codes</font></b><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">#!/bin/bash

TTYTEST=`tty`

# Random script code here, until we want to do something different based on TTY

if [ &quot;$TTYTEST&quot; = 'not a tty' ]; then
  # Code to run if shell is NOT a TTY
else
  # Code to run if the shell IS a TTY
fi</pre></td></tr></tbody></table><br />
Note that $TTYTEST must be put in quotes since it is a string.  The above method can be simplified into a one-line check if you only need to know if the shell is a TTY or not for one if statement.<br />
<br />
<b><font size="1">Listing 4: Quick one-liner to test if a shell is a TTY</font></b><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">#!/bin/bash

if [ &quot;`tty`&quot; = 'not a tty' ]; then
  # Code to run if shell is NOT a TTY
else
  # Code to run if the shell IS a TTY
fi</pre></td></tr></tbody></table><br />
Just as the $TTYEST variable had to be put in quotes since it was a string, so must `tty` when ran explicitly.  Since `tty` will return a string, this must be wrapped in quotes as &quot;`tty`&quot; for it to be used.<div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=g2xKxkJj"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=g2xKxkJj" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=dVovOUWm"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=dVovOUWm" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=czaXRzOK"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=czaXRzOK" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=PDHTt1Mz"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=PDHTt1Mz" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=vdVr71dd"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=vdVr71dd" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=t2XdQU0G"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=t2XdQU0G" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=dA6Q3PzZ"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=dA6Q3PzZ" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=n15KUNgH"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=n15KUNgH" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/132711192" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-07-11T12:48:41-05:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/07/11/Make_a_script_behave_differently_if_run_from_cron</guid>
			<category>Intermediate</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/07/11/Make_a_script_behave_differently_if_run_from_cron</feedburner:origLink></item>
		<item>
			<title>Excellent Linux Shell Tricks</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/132435995/Excellent_Linux_Shell_Tricks</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[Some of these are a bit advanced, but very well worth it.  I'm not the only one who uses IPTables as a workaround to common problems ;)<br />
<br />
<a href="http://www.venturecake.com/10-linux-shell-tricks-you-dont-already-know-for-once/" target="_blank">http://www.venturecake.com/10-linux-...know-for-once/</a><br />
<br />
Thankyou VentureCake!<div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=B1wtF9Ir"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=B1wtF9Ir" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=0HmjHbmK"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=0HmjHbmK" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=GXdsVOS2"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=GXdsVOS2" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=i98BT8Qg"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=i98BT8Qg" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=CVE3drv8"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=CVE3drv8" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=UDtdHhmm"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=UDtdHhmm" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=IyM26fNx"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=IyM26fNx" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=AuyYn4QT"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=AuyYn4QT" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/132435995" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-06-20T17:31:23-05:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/06/20/Excellent_Linux_Shell_Tricks</guid>
			<category>Link</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/06/20/Excellent_Linux_Shell_Tricks</feedburner:origLink></item>
		<item>
			<title>A good IBM article on the Linux kernel structure</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/132435996/A_good_IBM_article_on_the_Linux_kernel_structure</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[<a href="http://www.ibm.com/developerworks/linux/library/l-linux-kernel/index.html" target="_blank">http://www.ibm.com/developerworks/li...nel/index.html</a><br />
<br />
I fucking love these developerWorks articles.  They kick major ass.  Below is a great (if very simplified) overview of how the different parts of a Linux-based OS work together.<br />
<br />
<img src="http://dranok.deadgod.net/src/Pics/Random/figure2.jpg" border="0" alt="" /><br />
<br />
There's many more images in the actual article, as well as succinct overviews of the major components.  This article won't make you an expert, but at least it will give you a good idea of how things work ;)<div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=YzYKfmL6"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=YzYKfmL6" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=6jWmdStg"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=6jWmdStg" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=GBuGDBz0"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=GBuGDBz0" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=Yorkrvpo"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=Yorkrvpo" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=l2HZVLOS"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=l2HZVLOS" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=bERRWQZK"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=bERRWQZK" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=8eYbcO0y"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=8eYbcO0y" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=2TCQAi40"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=2TCQAi40" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/132435996" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-06-07T12:42:35-05:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/06/07/A_good_IBM_article_on_the_Linux_kernel_structure</guid>
			<category>Link</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/06/07/A_good_IBM_article_on_the_Linux_kernel_structure</feedburner:origLink></item>
		<item>
			<title>Maintain a tail -f on rotating log files</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/132435997/Maintain_a_quottail_-fquot_on_rotating_log_files</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[<font size="1"><b>Prerequisites:</b></font><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">o GNU tail
o Familiarity with the bash shell
o Familiarity with the tail command
o Beginner's knowledge of what a file descriptor is</pre></td></tr></tbody></table><br />
Running <i>tail -f /path/to/somefile.log</i> is one of the first commands a beginner learns.  Aside from use on the command line, tail can be used in scripts as well.<br />
<br />
Most log files rotate at some point or another (that is, they're renamed), and a new file starts being logged to.  This is a problem since tail will follow the file even through a rename.  This is because by default tail follows the descriptor, which doesn't actually change when the file gets moved.<br />
<br />
Say you're tailing /var/log/messages.  This file gets rotated to /var/log/messages.1 and a new /var/log/messages is created.  By default your tail will still be following the descriptor for /var/log/messages.1, which probably isn't what you want.<br />
<br />
To change this you need to make tail follow the name of the file rather than the file's descriptor.  This can be done with:<br />
<br />
<b><font size="1">Listing 1: Tail by name</font></b><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">tail --follow=name /var/log/messages</pre></td></tr></tbody></table><br />
The normal &quot;tail -f&quot; is equivalent to:<br />
<br />
<b><font size="1">Listing 2: Tail by descriptor (aka, <i>tail -f</i>)</font></b><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">tail --follow=descriptor /var/log/messages</pre></td></tr></tbody></table><br />
This is a good start, but there's one additional problem.  Normally, if a file becomes inaccessible for even a short period of time tail will quit.  This is a problem, since there will almost certainly be a delay between when the existing /var/log/messages is moved to /var/log/messages.1 and the new /var/log/messages is created.<br />
<br />
To overcome this problem we can use the &quot;--retry&quot; option:<br />
<br />
<b><font size="1">Listing 3: Tail retry option</font></b><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">tail --retry --follow=name /var/log/messages</pre></td></tr></tbody></table><br />
This is a bit bulky, so luckily GNU tail gives us a single flag to use instead, &quot;-F&quot;.  The &quot;-F&quot; flag is an alias for &quot;--retry --follow=name&quot;:<br />
<br />
<b><font size="1">Listing 4: Final, simplified command to tail by name</font></b><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">tail -F /var/log/messages</pre></td></tr></tbody></table><br />
Easy as that ;)<br />
<br />
<b><font size="1">Listing 5: Relevant section from the tail man page</font></b><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">       --retry
              keep trying to open a file even if it is inaccessible when  tail
              starts  or  if it becomes inaccessible later -- useful only with
              -f

       -f, --follow[={name|descriptor}]
              output appended data as the file grows; -f, --follow, and --fol-
              low=descriptor are equivalent

       -F     same as --follow=name --retry</pre></td></tr></tbody></table><br />
<div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=E4THl6ph"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=E4THl6ph" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=ckRK2f2a"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=ckRK2f2a" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=R46YSBBs"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=R46YSBBs" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=JbGdgSC2"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=JbGdgSC2" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=jD3KldhF"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=jD3KldhF" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=8cqjMrvB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=8cqjMrvB" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=PvGOJpSs"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=PvGOJpSs" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=rZbTbJYC"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=rZbTbJYC" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/132435997" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-06-06T17:24:53-05:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/06/06/Maintain_a_quottail_-fquot_on_rotating_log_files</guid>
			<category>Beginner</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/06/06/Maintain_a_quottail_-fquot_on_rotating_log_files</feedburner:origLink></item>
		<item>
			<title>Temporarily force a server to queue outgoing mail</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/132435998/Temporarily_force_a_server_to_queue_outgoing_mail</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[Email is often used as a tool for servers to send reports, notifications and customer correspondence.  It can be difficult to troubleshoot the content of messages, however, without resorting to lots of messy code changes or setting up a network of test mailboxes.<br />
<br />
This tutorial will show you how to temporarily stop all mail from being sent on a single server so you can inspect the individual mail messages and delete them before they're delivered to an actual person.  Any legit mail will not be lost and will be sent once your debugging is complete.<br />
<br />
<b><font size="1">Prerequisites:</font></b><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">o Familiarity with the bash shell
o Familiarity with firewall concepts
o Familiarity with the SMTP protocol
o Basic familiarity with the iptables command</pre></td></tr></tbody></table><br />
Most web and app servers run a local MTA (<a href="http://en.wikipedia.org/wiki/Mail_transfer_agent" target="_blank">Mail Transfer Agent</a>) for system crons and users to send mail with.  Frequently this MTA is bound to the localhost interface (127.0.0.1) so external hosts can't access it.<br />
<br />
Most applications use their host's local MTA instead of directly opening an outgoing SMTP connection to some random host on port 25.  Apps that don't directly use the local MTA are usually configured to use localhost (127.0.0.1) as their mail server so messages aren't lost if there is a network failure.<br />
<br />
All mainstream MTAs store mail messages in a queue if they are not able to be immediately sent (if they are disconnected from the network, for example, or if the relay they are trying to send mail to is down).  While a mail message is queued it is stored on the file system in plain text.<br />
<br />
We have two requirements while trying to debug our app's outgoing mail:<br />
<br />
1) We don't want our test messages to reach actual recipients who may be confused by the mail.<br />
2) We want real mail that wasn't part of our test to be delivered normally when we are finished.<br />
<br />
Yes, we could mess with the MTA's configuration to try to do this.  We could modify the app sending the messages to store them to a file instead.<br />
<br />
A much simpler method, however, is to use iptables instead.<br />
<br />
Since we want all outgoing messages to be queued we need to prevent the MTA from reaching any external host over port 25 (SMTP).  However, since our app may be trying to send mail to localhost (127.0.0.1), we must ensure that port 25 on localhost remains open.  To do this we need two iptable rules:<br />
<br />
<b><font size="1">Listing 1:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">iptables -A OUTPUT -p tcp -d 127.0.0.1 --dport 25 -j ACCEPT
iptables -A OUTPUT -p tcp  --dport 25 -j REJECT</pre></td></tr></tbody></table><br />
Most iptables rules are put on the INPUT chain--that is, they manage incoming traffic.  In this case we use &quot;-A OUTPUT&quot; because we want to manage <i>outgoing</i> traffic.<br />
<br />
The first rule says to ACCEPT all tcp traffic going to localhost (127.0.0.1) on port 25 (SMTP). <br />
<br />
The second rule says to REJECT all tcp traffic going to any destination on port 25.  <br />
<br />
Since the rule to accept localhost traffic is above the rule to deny all outgoing port 25 traffic we are still able to connect to port 25 of localhost.  Also note that it is important to use REJECT instead of DROP, since REJECT will cause the MTA's outgoing connection to fail immediatly, while DROP would cause it to hang until it times out.<br />
<br />
Running &quot;iptables -L&quot; should now report something similar to the following:<br />
<br />
<b><font size="1">Listing 2:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             localhost.localdomaintcp dpt:smtp
REJECT     tcp  --  anywhere             anywhere           tcp dpt:smtp reject-with
icmp-port-unreachable</pre></td></tr></tbody></table><br />
Now all mail being sent will be queued.  Your MTA's log file will most likely say the mail has been deferred due to a connection timeout.<br />
<br />
Where these messages are stored is entirely dependent on your MTA software and how it was configured.  In the case of sendmail, they will likely be in /var/spool/mqueue.  Sendmail separates the envelope header from the body.  The reasons for this are outside the scope of this article, however it is sufficient to explain that you may need to look at two separate files in order to see an entire email.<br />
<br />
Different MTAs use different naming schemes and IDs for these files, however it is generally fairly simple to figure out what each of these files is.  Once you find where your MTA stores it's queued messages it shouldn't be difficult to find the debug info you were looking for regardless of how much or little you know about the SMTP protocol and your specific MTA.<br />
<br />
Once you have what you need you should delete any files that you don't want sent.  Naming schemes vary, but in the case of sendmail all queue files are a string of letters followed by the message ID.  It's generally safe to just replace the first 3-5 characters of a file you want to delete in the queue directory with * so you delete all files associated with that message.<br />
<br />
For example, if you need to delete a file named &quot;dfj2BIK8802525&quot;, use &quot;rm *K8802525&quot; to make sure you delete all associated envelope files.  If no legit mail was sent during this time you can safely remove all files in the spool directly.<br />
<br />
Remove the iptables rules with &quot;iptables -F&quot; to clear the entire chain.  Note that this will remove ALL iptables rules, not just the two you added above.  If your had custom iptables rules setup you should either restore them after running &quot;iptables -F&quot; or selectively remove the two rules we added in this tutorial.<br />
<br />
The queued mail will now be sent the next time the MTA processes its queue, generally within an hour.  Most MTAs have the ability to force processing its queue--using sendmail, for example, you can issue &quot;/usr/sbin/sendmail -q&quot; to force processing of the queue.<br />
<br />
<b><font size="1">See Also:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">o IPTables
  <a href="http://en.wikipedia.org/wiki/Iptables" target="_blank">http://en.wikipedia.org/wiki/Iptables</a>
o The SMTP Protocol
  <a href="http://en.wikipedia.org/wiki/Smtp" target="_blank">http://en.wikipedia.org/wiki/Smtp</a>
o Sendmail
  <a href="http://en.wikipedia.org/wiki/Sendmail" target="_blank">http://en.wikipedia.org/wiki/Sendmail</a>
o Postfix
  <a href="http://en.wikipedia.org/wiki/Postfix_&#37;28software%29" target="_blank">http://en.wikipedia.org/wiki/Postfix_&#37;28software%29</a></pre></td></tr></tbody></table><br />
<div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=5gPtXtS5"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=5gPtXtS5" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=e1fJqoP5"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=e1fJqoP5" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=VnpBY8oj"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=VnpBY8oj" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=nInzucI4"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=nInzucI4" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=q99HASWX"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=q99HASWX" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=cjOn3UtI"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=cjOn3UtI" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=1zTCypnW"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=1zTCypnW" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=P1hFt5vT"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=P1hFt5vT" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/132435998" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-05-16T16:11:52-05:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/05/16/Temporarily_force_a_server_to_queue_outgoing_mail</guid>
			<category>Intermediate</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/05/16/Temporarily_force_a_server_to_queue_outgoing_mail</feedburner:origLink></item>
		<item>
			<title>Ugly files and how to get rid of them</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/132435999/Ugly_files_and_how_to_get_rid_of_them</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[<font size="1"><b>Prerequisites:</b></font><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">o Familiarity with the bash shell
o Familiarity with the find command
o Beginner's knowledge of what an inode is</pre></td></tr></tbody></table><br />
I've often ranted about what I consider to be a lack of competency in the IT field.  I blame much of this on the interview process--it's difficult to assess a candidate's skill by simply asking questions.  Having a candidate sit down in front of a laptop and try to solve an actual problem instead can be much more useful.  Below is one of many lab exercises I use.<br />
<br />
<b><font size="1">Listing 1:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;"><b>Problem:  You are tasked with removing the following files.
          You must remove each file individually.</b>

Neptune:/tmp/example3 # ls -lrat
total 12
drwxrwxrwt 11 root   root  8192 Mar 22 12:50 ..
-rw-r--r--  1 dranok users    0 Mar 22 12:51 -this-file-starts-with-a-dash
-rw-r--r--  1 dranok users    0 Mar 22 12:51 &#25968;&#29420;&#12301;
-rw-r--r--  1 dranok users    0 Mar 22 12:52         how many spaces
-rw-r--r--  1 dranok users    0 Mar 22 12:52 immutable
drwxr-xr-x  2 dranok users 4096 Mar 22 12:52 .</pre></td></tr></tbody></table><br />
I say each file must be removed individually because in real-life scenarios you're not going to be able to rm -rf the entire directory.  In fact, this is a dangerous idea when you have files with strange characters--you may end up deleting something important.  Further, there may be files in the directory you need to keep.  Besides, running rm -rf on the folder won't always work.<br />
<br />
I like this example because each of these files is increasingly difficult to remove. <br />
<br />
Most people try to remove the immutable file first.  They get the following error, even as root.<br />
<br />
<b><font size="1">Listing 2:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">Neptune:/tmp/example3 # rm immutable
rm: remove write-protected regular empty file `immutable'? y
rm: cannot remove `immutable': Operation not permitted</pre></td></tr></tbody></table><br />
Nope, this isn't an NFS share.  so why can't root delete this file?  We'll come back to this one.<br />
<br />
The &quot;how many spaces&quot; file (which starts with a number of spaces) is the easiest to remove.  Just use a wildcard and this one is simple:<br />
<br />
<font size="1"><b>Listing 3:</b></font><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">Neptune:/tmp/example3 # rm *how*
Neptune:/tmp/example3 # ls -lrat
total 12
-rw-r--r--  1 dranok users    0 Mar 22 12:51 -this-file-starts-with-a-dash
-rw-r--r--  1 dranok users    0 Mar 22 12:51 &#25968;&#29420;&#12301;
-rw-r--r--  1 dranok users    0 Mar 22 12:52 immutable
drwxrwxrwt 11 root   root  8192 Mar 22 13:00 ..
drwxr-xr-x  2 dranok users 4096 Mar 22 13:04 .</pre></td></tr></tbody></table><br />
The next easiest is the &quot;-this-file-starts-with-a-dash&quot; file.  Most people tend to struggle with this one.<br />
<br />
<b><font size="1">Listing 4:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">Neptune:/tmp/example3 # rm -this-file-starts-with-a-dash
rm: invalid option -- t
Try `rm ./-this-file-starts-with-a-dash' to remove the file
Try `rm --help' for more information.
Neptune:/tmp/example3 # rm *dash
rm: invalid option -- t
Try `rm ./-this-file-starts-with-a-dash' to remove the file
Try `rm --help' for more information.</pre></td></tr></tbody></table><br />
Even wildcards won't work here.  The problem is that rm is interpreting the dash as an argument.  The easiest answer is to remember that modern Linux commands use getopt, and that two dashes means &quot;end of options&quot;:<br />
<br />
<b><font size="1">Listing 5:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">Neptune:/tmp/example3 # rm -- *dash
Neptune:/tmp/example3 # ls -lrat
total 12
-rw-r--r--  1 dranok users    0 Mar 22 12:51 &#25968;&#29420;&#12301;
-rw-r--r--  1 dranok users    0 Mar 22 12:52 immutable
drwxrwxrwt 11 root   root  8192 Mar 22 13:00 ..
drwxr-xr-x  2 dranok users 4096 Mar 22 13:08 .</pre></td></tr></tbody></table><br />
Next we'll tackle the file that contains kanji (&#25968;&#29420;&#12301;).  If your terminal (or web browser) doesn't have the Japanese fonts installed this likely shows up as a series of boxes.  How do you selectively remove this file?<br />
<br />
The answer is to delete the file via its inode.  Among other things, an inode is a unique numerical ID for every file on your filesystem.<br />
<br />
To see these inode values, use &quot;ls -li&quot;:<br />
<br />
<b><font size="1">Listing 6:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">Neptune:/tmp/example3 # ls -li
total 0
2573051 -rw-r--r-- 1 dranok users 0 Mar 22 12:52 immutable
2573049 -rw-r--r-- 1 dranok users 0 Mar 22 12:51 &#25968;&#29420;&#12301;</pre></td></tr></tbody></table><br />
Now we know the inode is 2573049.  To remove it, we invoke the find command:<br />
<br />
<b><font size="1">Listing 7:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">Neptune:/tmp/example3 # find . -maxdepth 1 -inum 2573049 -ok rm {} \;
&lt; rm ... ./&#25968;&#29420;&#12301; &gt; ? y
Neptune:/tmp/example3 # ls -lrat
total 12
-rw-r--r--  1 dranok users    0 Mar 22 12:52 immutable
drwxrwxrwt 12 root   root  8192 Mar 22 13:12 ..
drwxr-xr-x  2 dranok users 4096 Mar 22 13:13 .</pre></td></tr></tbody></table><br />
Easy enough.  We use &quot;-ok&quot; here instead of &quot;-exec&quot; since &quot;-ok&quot; will prompt us before running the command.  Removing files with strange characters can be dangerous so it's always a good idea to take precautions.  We used &quot;-maxdepth 1&quot; to ensure find wouldn't recurse into subdirectories.<br />
<br />
That leaves us with that &quot;immutable&quot; file.  At this point, even trying to &quot;rm -rf&quot; the directory will fail:<br />
<br />
<b><font size="1">Listing 8:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">Neptune:/tmp # rm -rf example3
rm: cannot remove `example3/immutable': Operation not permitted</pre></td></tr></tbody></table><br />
The first thing to check when root cannot delete a local (non-NFS) file is the extended filesystem attributes.  This can be achieved with the &quot;lsattr&quot; command:<br />
<br />
<b><font size="1">Listing 9:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">Neptune:/tmp/example3 # lsattr
----i-------- ./immutable</pre></td></tr></tbody></table><br />
The &quot;i&quot; in the series of dashes means this file is immutable, or write-protected.  To remove this flag from the file you must use the change attribute command, chattr:<br />
<br />
<b><font size="1">Listing 10:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">Neptune:/tmp/example3 # chattr -i immutable
Neptune:/tmp/example3 # lsattr
------------- ./immutable
Neptune:/tmp/example3 # rm immutable
Neptune:/tmp/example3 # ls -lrat
total 12
drwxrwxrwt 12 root   root  8192 Mar 22 13:15 ..
drwxr-xr-x  2 dranok users 4096 Mar 22 13:18 .</pre></td></tr></tbody></table><br />
Congratulations!  All the files have been removed.<br />
<br />
Extended ext2/ext3 file attributes are very useful, however they are outside the scope of this article.  Links are provided at the end of this article for more information.<br />
<br />
<b><font size="1">See Also:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">o Removing files with strange characters
  <a href="http://www.faqs.org/faqs/unix-faq/faq/part2/section-1.html" target="_blank">http://www.faqs.org/faqs/unix-faq/fa...section-1.html</a>
  <a href="http://www.faqs.org/faqs/unix-faq/faq/part2/section-2.html" target="_blank">http://www.faqs.org/faqs/unix-faq/fa...section-2.html</a>
o Inodes
  <a href="http://en.wikipedia.org/wiki/Inode" target="_blank">http://en.wikipedia.org/wiki/Inode</a>
o The find command
  <a href="http://www.die.net/doc/linux/man/man1/find.1.html" target="_blank">http://www.die.net/doc/linux/man/man1/find.1.html</a>
o ext2/ext3 extended file attributes 
  <a href="http://www.die.net/doc/linux/man/man1/chattr.1.html" target="_blank">http://www.die.net/doc/linux/man/man1/chattr.1.html</a></pre></td></tr></tbody></table><br />
<div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=coaQPL3W"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=coaQPL3W" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=lzFc85S8"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=lzFc85S8" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=E86wE4nB"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=E86wE4nB" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=ONJh7Mgj"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=ONJh7Mgj" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=cb1aVZ7P"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=cb1aVZ7P" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=f4uCGsUK"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=f4uCGsUK" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=QT8At23q"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=QT8At23q" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=4XXKcdgV"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=4XXKcdgV" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/132435999" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-03-22T15:24:38-05:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/03/22/Ugly_files_and_how_to_get_rid_of_them</guid>
			<category>Intermediate</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/03/22/Ugly_files_and_how_to_get_rid_of_them</feedburner:origLink></item>
		<item>
			<title>How to override DNS on a per-user basis</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/132436000/How_to_override_DNS_on_a_per-user_basis</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[<font size="1"><b>Prerequisites:</b></font><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">o Familiarity with DNS, /etc/hosts and /etc/nsswitch.conf
   <a href="http://en.wikipedia.org/wiki/Name_Service_Switch" target="_blank">http://en.wikipedia.org/wiki/Name_Service_Switch</a>
o Basic understanding of iptables
   <a href="http://www.netfilter.org/" target="_blank">http://www.netfilter.org/</a>
   <a href="http://iptables-tutorial.frozentux.net/" target="_blank">http://iptables-tutorial.frozentux.net/</a></pre></td></tr></tbody></table><br />
<b>Lazy QA/Staging</b><br />
<br />
In the staging of production systems it is often desirable to override DNS to point at a local staging server instead of the production one.  For example, you may have a large number of scripts that call &quot;www.xyz.com&quot;; changing all of these to &quot;wwwtest.xyz.com&quot; would be a pain in the ass.<br />
<br />
Sure, there are good ways around this if you have a decent QA environment.  You can use a special QA network with its own DNS server.  To some extent you can use rule-based proxies.<br />
<br />
A large number of solutions involve editing your local hosts file (/etc/hosts under UNIX, \system32\drivers\etc\hosts on Windows) to override DNS.<br />
<br />
This works due to a file named /etc/nsswitch.conf.  This very useful file contains the rules that programs use to resolve host names and other directory services (sendmail aliases, autofs, etc).<br />
<br />
Basically, when a program wants to connect to &quot;www.xyz.com&quot; it makes a call to gethostbyname(), which consults /etc/nsswitch.conf.<br />
<br />
A common /etc/nsswitch.conf might contain the following line:<br />
<br />
<b><font size="1">Listing 1:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">hosts:          files dns</pre></td></tr></tbody></table><br />
This tells gethostbyname() to consult local files first (ie., /etc/hosts).  If it can't find what it's looking for there it will consult DNS.<br />
<br />
<i>NOTE: Not all programs respect /etc/resolv.conf.  For example, the &quot;nslookup&quot;, &quot;dig&quot; and &quot;host&quot; commands will return DNS information regardless of what is in /etc/hosts.</i><br />
<br />
Usually this works fine.  You'll resolve <a href="http://www.xyz.com" target="_blank">www.xyz.com</a> normally with the entry commented out in /etc/hosts and resolve it to the staging IP with the entry present.<br />
<br />
The problem comes in when you want certain users to use DNS, and certain users to use the overrides in /etc/hosts.<br />
<br />
<b>Per-user DNS overrides</b><br />
<br />
The important thing to remember about configuration files in /etc (/etc/hosts, /etc/nsswitch.conf, etc.) is that they are considered system-level confs.  That is, they apply to all users.  gethostbyname() doesn't care which user called it--it just blindly returns results based on the system-level rules in /etc.<br />
<br />
The trick to making this work is understanding how /etc/nsswitch.conf works.  Let's take a closer look at our above example, which specifies the search order as &quot;files dns&quot;.  This means it consults /etc/hosts first, and only if it fails or doesn't find an entry will it try DNS.<br />
<br />
The key is, &quot;if it fails.&quot;<br />
<br />
It's highly unlikely /etc/hosts will ever fail--it's just a flat file.  It <i>is</i> possible for DNS to fail, however.  In fact, since this requires network access, <i>we can make it fail</i>.<br />
<br />
Our goal is for some users to resolve <a href="http://www.xyz.com" target="_blank">www.xyz.com</a> publicly, while forcing other users to hit staging.  We can do this by providing public information via DNS and the staging IPs via /etc/hosts.<br />
<br />
Change /etc/nsswitch.conf to consult DNS first, only falling back on /etc/hosts if that fails:<br />
<br />
<b><font size="1">Listing 2:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">hosts:          dns files</pre></td></tr></tbody></table><br />
Now any entry we put into /etc/hosts for &quot;www.xyz.com&quot; will be ignored unless the DNS server fails to respond.  The next step is to force DNS to fail for certain users.<br />
<br />
Let's say user jdoe has a uid of 503.  We want Joe to hit staging.  using the &quot;-m owner&quot; feature of iptables we can block him from hitting udp/tcp port 53 (DNS).<br />
<br />
<b><font size="1">Listing 3:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">/sbin/iptables -A OUTPUT -p tcp --dport 53 -m owner --uid-owner 503 -j REJECT
/sbin/iptables -A OUTPUT -p udp --dport 53 -m owner --uid-owner 503 -j REJECT</pre></td></tr></tbody></table><br />
User jdoe will now be unable to make DNS requests since udp/tcp port 53 outgoing is blocked.  gethostbyname() will fail and thus fall back to /etc/hosts due to the options in /etc/nsswitch.conf.  We can similarly add iptables rules for any user we want to hit staging.<br />
<br />
You may need to restart your nscd service depending on how it's configured.  nscd is a caching daemon that runs by default on some systems (Solaris, SuSE, etc.).  More information can be found below:<br />
<br />
<a href="http://linuxmanpages.com/man8/nscd.8.php" target="_blank">http://linuxmanpages.com/man8/nscd.8.php</a><br />
<br />
There is one problem with this method--<i>all</i> hosts must be in /etc/hosts.  If jdoe gets bored of QAing and wants to visit slashdot.org, he can't do so unless this is in /etc/hosts or he removes the iptables rule.<br />
<br />
Packet filtering with iptables is very powerful and robust.  To learn more about it visit the two links provided above in the prerequisites section, as it is a must-have utility for any Linux professional.<div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=qmk7nPFz"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=qmk7nPFz" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=NdTo0ASl"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=NdTo0ASl" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=H69cdOrt"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=H69cdOrt" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=irWZk8px"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=irWZk8px" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=KjM0p78q"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=KjM0p78q" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=8rgtKMKL"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=8rgtKMKL" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=SlY4cTZF"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=SlY4cTZF" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=5qyc9AhO"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=5qyc9AhO" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/132436000" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-01-24T17:03:45-06:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/01/24/How_to_override_DNS_on_a_per-user_basis</guid>
			<category>Advanced</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/01/24/How_to_override_DNS_on_a_per-user_basis</feedburner:origLink></item>
		<item>
			<title>Multiple LUNs under Linux 2.4</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/132436001/Multiple_LUNs_under_Linux_24</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[<font size="1"><b>Prerequisites:</b></font><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">1) Ability to build a custom kernel    
    (Refer to your specific distro's documentation)
2) SCSI device addressing
    <a href="http://www.tldp.org/HOWTO/SCSI-2.4-HOWTO/scsiaddr.html" target="_blank">http://www.tldp.org/HOWTO/SCSI-2.4-HOWTO/scsiaddr.html</a>
3) The sg3_utils package
    <a href="http://sg.torque.net/sg/sg3_utils.html" target="_blank">http://sg.torque.net/sg/sg3_utils.html</a></pre></td></tr></tbody></table><br />
System administrators often wonder why Linux can't use a sane naming convention for its disks like Solaris does--/dev/dsk/c0t1d0s2 is simple to understand--scsi host 0, bus 1, device 0, lun 2.  Simple.  Elegant.<br />
<br />
On Linux 2.4 we get /dev/sdd1 (Under 2.6 we get sysfs and udev, neither of which is much better in my opinion).<br />
<br />
Thankfully the sg3_utils package contains the &quot;sg_map&quot; command, which is insanely helpful.  Let's take a basic system that has five disks:<br />
<br />
<b><font size="1">Listing 1:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">[root@host1 root]# sg_map -x
/dev/sg0  0 0 0 0  8
/dev/sg1  0 0 1 0  1  /dev/st0
/dev/sg2  1 0 0 0  0  /dev/sda
/dev/sg3  1 0 1 0  0  /dev/sdb
/dev/sg4  1 0 2 0  0  /dev/sdc
/dev/sg5  1 0 3 0  0  /dev/sdd
/dev/sg6  1 0 4 0  0  /dev/sde
/dev/sg7  1 0 6 0  3</pre></td></tr></tbody></table><br />
The -x flag is required to print out the numbers in the middle.  We only care about the first four numbers, which are, in order, &quot;host, bus, device, lun&quot; (the fifth digit is scsi type; read the sg_map man page for more info).<br />
<br />
On this particular system we have a tape drive on scsi host 0; our five disks are on scsi host 1.  They all share the same bus (0) and each disk has its own device id.  All disks use only LUN 0, even though each disk is separated into different partitions (/dev/sda1, /dev/sda2, etc).  Under Linux different partitions on the same disk do not become different LUNs.<br />
<br />
When you're only dealing with individual disks this is annoying but straightforward.  Problems can arise, however, If you have a SAN or direct-attached storage.  Many of these will arrange their disk volumes by LUN.  <br />
<br />
Problem is, by default the 2.4 Linux kernel will *only* scan LUN 0.<br />
<br />
To change this you must modify your kernel settings.  Install your kernel sources as per  your distro's documentation (compiling your own kernel is beyond the scope of this article).  When you're at the configuration step (whichever you use:  make menuconfig, make xconfig, etc) go down to the SCSI section and put a check in the line for &quot;enable scanning of multiple LUNs&quot;  Save your .config and finish compiling the kernel as usual.<br />
<br />
In your grub or lilo conf file, add &quot;max_scsi_luns=128&quot; to the end of your kernel line:<br />
<br />
<b><font size="1">Listing 2:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">title Red Hat Enterprise Linux WS (2.4.21-20.ELsmp-san)
        root (hd0,0)
        kernel /vmlinuz-2.4.21-20.ELsmp-san ro root=LABEL=/ console=tty0
console=ttyS0,9600n8 max_scsi_luns=128</pre></td></tr></tbody></table><br />
Reboot onto your new kernel and you should now be able to see all your LUNs.<br />
<br />
<font size="1"><b>Listing 3:</b></font><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">[root@host2 root]# sg_map -x
/dev/sg0  0 0 1 0  0  /dev/sda
/dev/sg1  2 0 0 0  0  /dev/sdb
/dev/sg2  2 0 0 1  0  /dev/sdc
/dev/sg3  2 0 0 2  0  /dev/sdd
/dev/sg4  2 0 0 3  0  /dev/sde
/dev/sg5  2 0 0 4  0  /dev/sdf
/dev/sg6  2 0 0 5  0  /dev/sdg</pre></td></tr></tbody></table><br />
This particular server has a single internal disk (/dev/sda on scsi host 0) and serveral SAN volumes (/dev/sdb-/dev/sdg on scsi host 0).  Note that all these SAN volumes have the same bus and device identifiers; they are separated only by LUN.<br />
<br />
This <i>should</i> be the end of this article, however due to a quirk in how Linux 2.4 handles LUN scanning one last important note must be addressed:<br />
<br />
<b>Linux 2.4 scans LUNs in order and will stop scanning if it finds a non-existent LUN.</b><br />
<br />
This is particularly troublesome if you have a SAN and only want certain hosts to see certain volumes.  Let's say you have six LUNs numbered 0-5.  If you want one host to only see LUNs 0, 1 and 2 this is easy enough--disableing luns 3, 4 and 5 from either your HBA or the SAN itself will cause Linux no problems.<br />
<br />
However, let's say you want a host to only see LUN 4.  This <i>will</i> cause a problem--Linux will scan LUN 0, find nothing, and move on.  It won't even attempt to scan LUNs 1-5.  If you want a host to see LUNs 0, 1, 2, 4 and 5 it will only see the first three (if Linux doesn't see LUN 3 it won't bother trying LUNs 4 or 5).<br />
<br />
This can lead to messy SAN setups and poses the risk of one machine accidentally mounting a disk it's not supposed to.  I'm not aware of a clean solution to this at this time with Linux 2.4 other than separating SAN volumes at a device level instead of using LUNs.  If anyone knows a good solution I'd be quite keen on learning about it.<div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=NQa4JVNf"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=NQa4JVNf" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=jwmqxRow"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=jwmqxRow" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=THUw9WLd"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=THUw9WLd" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=48VfuLi2"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=48VfuLi2" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=qLP8Nalm"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=qLP8Nalm" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=NY927PFm"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=NY927PFm" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=ZL3JHQyL"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=ZL3JHQyL" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=AN72YcoA"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=AN72YcoA" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/132436001" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-01-11T17:24:20-06:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/01/11/Multiple_LUNs_under_Linux_24</guid>
			<category>Advanced</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/01/11/Multiple_LUNs_under_Linux_24</feedburner:origLink></item>
		<item>
			<title>Special Bash Variables I</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/132436002/Special_Bash_Variables_I</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[Bash has several built-in special variables.  Although most are used only for scripting, there are several that are useful at the command line. <br />
<br />
The two I will address in this post are <b>!!</b> and <b>!$</b>.<br />
<br />
<b><u>Repeat entire last line: !!</u></b><br />
<br />
One of the useful parts of bash is its history system.  You can see a history of your commands by typing <b>history</b> at the command prompt.  The history command is considered a built-in command because it is not a binary that exists on the filesystem such as <b>ls</b> or <b>uptime</b>.  The <b>cd</b> command is another example of a bash built-in.<br />
<br />
Built-in bash commands will be covered in more detail in the future, as will the history command.  For now, however, know that you can repeat history commands by typing &quot;!&quot; followed by the history ID.<br />
<br />
Take the following example:<br />
<br />
<b><font size="1">Listing 1:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">dranok@Neptune:~&gt; history
    1  which uptime
    2  cd /tmp
    3  ls -l
    4  uptime</pre></td></tr></tbody></table><br />
The <b>which</b> command will tell you the full path of a program, assuming it is in a path specified by your $PATH environment variable.  If I wanted to run the <b>which uptime</b> command again, instead of typing it out I could instead type <b>!1</b>:<br />
<br />
<b><font size="1">Listing 2:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">dranok@Neptune:~&gt; !1
which uptime
/usr/bin/uptime</pre></td></tr></tbody></table><br />
<b>!1</b> gets expanded to the actual command <b>which uptime</b>.  Note <b>!1</b> doesn't get saved in your history--if you type history again you'll see the expanded <b>which uptime</b> command.  Likewise if you press the up key you'll see the expanded version there as well.<br />
<br />
Also note that when you use special bash variables the expanded command is printed on the subsequent line.  This is helpful in figuring out exactly what the bash shell actually ran.<br />
<br />
So how does this relate to <b>!!</b>?  <b>!!</b> is the bash built-in for the last command in your history file--the last command you ran.<br />
<br />
<font size="1"><b>Listing 3:</b></font><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">dranok@Neptune:~&gt; cat /tmp/happy
I'm happy!
dranok@Neptune:~&gt; !!
cat /tmp/happy
I'm happy!</pre></td></tr></tbody></table><br />
This is very useful in conjunction with the <b>sudo</b> command, among other things.  For example you might run a command as a non-privileged only to discover you need root access.  Running <b>sudo !!</b> is a fast way to achieve this.<br />
<br />
<font size="1"><b>Listing 4:</b></font><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">dranok@Neptune:~&gt; cat /tmp/rootonly.txt 
cat: /tmp/rootonly.txt: Permission denied
dranok@Neptune:~&gt; sudo !!
sudo cat /tmp/rootonly.txt 
This file can only be read by root.</pre></td></tr></tbody></table><br />
<br />
<b><u>Repeat last argument: !$</u></b><br />
<br />
<b>!$</b> is similar to <b>!!</b>, however instead of expanding to the entire last command it expands to the last argument of the last command.  This is best illustrated by example.<br />
<br />
<b><font size="1">Listing 5:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">dranok@Neptune:~&gt; cd /tmp/testdir
-bash: cd: /tmp/testdir: No such file or directory
dranok@Neptune:~&gt; mkdir !$
mkdir /tmp/testdir</pre></td></tr></tbody></table><br />
In this case we tried to cd into a directory which did not exist.  Since the last argument of the preceding command was <b>/tmp/testdir</b>, running <b>mkdir !$</b> is the equivalent of <b>mkdir /tmp/testdir</b><br />
<br />
Bash contains many other special variables like <b>!!</b> and <b>!$</b>, however these are two of the most ubiquitous and useful.<div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=cKs1FNKz"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=cKs1FNKz" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=7I8VaZVh"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=7I8VaZVh" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=YWSsBdmb"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=YWSsBdmb" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=0MGuGa7U"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=0MGuGa7U" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=GyaeZhcS"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=GyaeZhcS" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=KxBFY7jO"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=KxBFY7jO" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=zl3JTI8W"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=zl3JTI8W" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=ekoNcCR0"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=ekoNcCR0" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/132436002" height="1" width="1"/>]]></content:encoded>
			<dc:date>2007-01-01T00:15:19-06:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2007/01/01/Special_Bash_Variables_I</guid>
			<category>Beginner</category>
		<feedburner:origLink>http://linux.DeadGod.net/2007/01/01/Special_Bash_Variables_I</feedburner:origLink></item>
		<item>
			<title>Free memory on Linux</title>
			<link>http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~3/132436003/Free_memory_on_Linux</link>
			<content:encoded xmlns="http://www.w3.org/1999/xhtml"><![CDATA[One of the frustrations I deal with on nearly a day-to-day basis is people's misconceptions about how memory is allocated under Linux 2.4 and later.<br />
<br />
<b><font size="1">Listing 1: Tools to report memory usage</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">* top
* free -m
* cat /proc/meminfo</pre></td></tr></tbody></table><br />
Let's take a typical example.  The &quot;free -m&quot; output below is from a production system that has been running for 80 days.<br />
<br />
<b><font size="1">Listing 2:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">             total       used       free     shared    buffers     cached
Mem:          3956       3939         16          0         81       3504
-/+ buffers/cache:        353       3602
Swap:        16378          0      16378</pre></td></tr></tbody></table><br />
This system has 4GB of physical memory and 16GB of swap.  At first glance it looks like 99.57&#37; of the memory is in use.  Your first instinct would be to run &quot;top&quot;, press capital &quot;M&quot; to sort by memory usage and find out what the hell is taking up so much memory.  Doing so will yield no results, however--on this particular system top will show no process taking up more than around 100MB of memory.  This can be confirmed with the &quot;ps&quot; command.<br />
<br />
So where did all this memory go?  The answer lies in the theory of memory management.  In particular, the Linux memory management system believes in the following two principles:<br />
<br />
1) No matter how much memory is in use, system performance will not be impacted until it is required to use swap space.<br />
2) Unused physical memory is wasted.<br />
<br />
Now we can tackle the first line of the &quot;free -m&quot; output.<br />
<br />
<font size="1"><b>Listing 3:</b></font><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">             total       used       free     shared    buffers     cached
Mem:          3956       3939         16          0         81       3504</pre></td></tr></tbody></table><br />
The key lies in the last two columns:  buffers and cached.  The largest of these is cached.  Whenever Linux accesses a file on a filesystem it stores the content of that file in memory.  As long as the data doesn't change, subsequent requests for that file will be read from memory instead of physical disk.  This vastly improves file access time.<br />
<br />
Memory used in such a manner can be freed up almost instantly, thus should really be counted as free memory instead of used.  The &quot;-/+ buffers/cache&quot; line of our &quot;free -m&quot; output reflects this.<br />
<br />
<b><font size="1">Listing 4:</font></b><br />
<table border=0 cellpadding=0 cellspacing=0><tbody><tr><td style="background-color: #eeeeee; border: 1px solid #ccc; padding: 5px;"><pre style="margin-top: 0; margin-bottom: 0; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 10px; padding: 5px;">             total       used       free     shared    buffers     cached
Mem:          3956       3939         16          0         81       3504
-/+ buffers/cache:        353       3602</pre></td></tr></tbody></table><br />
Actual used memory here is 353MB.  Free memory is 3602MB (Don't add the original 16MB back to this--it's already accounted for).  That means over 90% of this system's memory is free and available for use.  Quite a bit different than only having 16MB of memory free.<br />
<br />
The 3602MB value comes from adding the 3504MB of cache with the 81MB of buffers and 16MB of actual free memory.  The 353MB of used memory comes from taking total memory and subtracting the &quot;virtually free&quot; 3602MB value.  Note that due to rounding these values may be a bit off.<div class="feedflare">
<a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=7elwYd9z"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=7elwYd9z" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=0NqsM3Z7"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=0NqsM3Z7" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=kUQ91n9Q"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=kUQ91n9Q" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=EuxjHP2h"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=EuxjHP2h" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=E9cuDVNo"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=E9cuDVNo" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=l2nkFuKE"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=l2nkFuKE" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=vJuQso1L"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=vJuQso1L" border="0"></img></a> <a href="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?a=djczVoiO"><img src="http://feeds.deadgod.net/~f/DranoksLinuxWisdom?i=djczVoiO" border="0"></img></a>
</div><img src="http://feeds.deadgod.net/~r/DranoksLinuxWisdom/~4/132436003" height="1" width="1"/>]]></content:encoded>
			<dc:date>2006-12-27T13:33:34-06:00</dc:date>
			<dc:creator>DranoK</dc:creator>
			<guid isPermaLink="false">http://linux.DeadGod.net/2006/12/27/Free_memory_on_Linux</guid>
			<category>Intermediate</category>
		<feedburner:origLink>http://linux.DeadGod.net/2006/12/27/Free_memory_on_Linux</feedburner:origLink></item>
	</channel>
</rss>
