<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>greynode &#187; Unix</title>
	<atom:link href="http://greynode.org/tag/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://greynode.org</link>
	<description>ingénierie de tous les aspects de vie</description>
	<lastBuildDate>Wed, 11 Aug 2010 04:10:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Why No Games on Linux?</title>
		<link>http://greynode.org/2010/05/11/why-no-games-on-linux/</link>
		<comments>http://greynode.org/2010/05/11/why-no-games-on-linux/#comments</comments>
		<pubDate>Tue, 11 May 2010 20:54:26 +0000</pubDate>
		<dc:creator>Jeff Aigner</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.greynode.org/?p=226</guid>
		<description><![CDATA[Thought I would share an interesting article on why there are no games on linux. Want more games on linux? Solve these problems!]]></description>
			<content:encoded><![CDATA[<p>Thought I would share an interesting article on why <a href="http://linuxlock.blogspot.com/2010/05/why-games-dont-get-ported-to-linuxa.html">there are no games on linux</a>. Want more games on linux? Solve these problems!</p>
]]></content:encoded>
			<wfw:commentRss>http://greynode.org/2010/05/11/why-no-games-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Incremental Backup on FreeBSD with tar</title>
		<link>http://greynode.org/2010/05/10/incremental-backup-on-freebsd-with-tar/</link>
		<comments>http://greynode.org/2010/05/10/incremental-backup-on-freebsd-with-tar/#comments</comments>
		<pubDate>Mon, 10 May 2010 22:46:38 +0000</pubDate>
		<dc:creator>Jeff Aigner</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[freebsd]]></category>

		<guid isPermaLink="false">http://blog.greynode.org/?p=221</guid>
		<description><![CDATA[Recently the rsync server at work broke down, and I needed a quick solution for incremental backup using just FTP. As it turns out, the FreeBSD version of tar is not GNU tar. So in order to use the following trick on FreeBSD, the gtar port must be installed. Once you have the software, making [...]]]></description>
			<content:encoded><![CDATA[<p>Recently the rsync server at work broke down, and I needed a quick solution for incremental backup using just FTP. As it turns out, the FreeBSD version of tar is not GNU tar. So in order to use the following trick on FreeBSD, the gtar port must be installed. Once you have the software, making an increment backup with tar is easy:</p>
<blockquote><p>
$ gtar -g /backup/tar-incremental.log -cjvf /backup/backup.tar.bz2 /etc /usr/local/etc/ /usr/www
</p></blockquote>
<p>The tar-incremental.log file must be saved as it contains information for the incremental backup. Every time you run this file a new file will be created, so do not over-write your files. A more in-depth discussion can be found on the <a href="http://www.gnu.org/software/automake/manual/tar/Incremental-Dumps.html">GNU tar incremental backup page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://greynode.org/2010/05/10/incremental-backup-on-freebsd-with-tar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pdnsd and NetworkManager</title>
		<link>http://greynode.org/2010/05/09/pdnsd-and-networkmanager/</link>
		<comments>http://greynode.org/2010/05/09/pdnsd-and-networkmanager/#comments</comments>
		<pubDate>Mon, 10 May 2010 07:52:55 +0000</pubDate>
		<dc:creator>Jeff Aigner</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[arch]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.greynode.org/?p=211</guid>
		<description><![CDATA[If you run arch linux or a similar minimal distro, you may be familiar with the local dns server pdnsd, used to cache DNS queries. If you try to run pdnsd on the same computer as NetworkManager, you may run into a problem. Using default configurations, your DNS lookups end up in a vicious loop [...]]]></description>
			<content:encoded><![CDATA[<p>If you run arch linux or a similar minimal distro, you may be familiar with the local dns server pdnsd, used to cache DNS queries. If you try to run pdnsd on the same computer as NetworkManager, you may run into a problem. Using default configurations, your DNS lookups end up in a vicious loop redirecting to 127.0.0.1. To circumvent this problem, I did the following.</p>
<p>I let NetworkManager generate my /etc/resolv.conf file. I then copied it to /etc/resolv.conf.head. Once this was done, the server section in /etc/pdnsd.conf was edited to contain the following:</p>
<p><code>server {<br />
      label= "comcast;<br />
      file = "/etc/resolv.conf.head";  # Preferably do not use /etc/resolv.conf<br />
  #   proxy_only=on;     # Do not query any name servers beside your ISP's.<br />
      timeout=4;         # Server timeout; this may be much shorter<br />
                 # that the global timeout option.<br />
      uptest=if;         # Test if the network interface is active.<br />
      interface=wlan0;    # The name of the interface to check.<br />
      interval=10m;      # Check every 10 minutes.<br />
      purge_cache=off;   # Keep stale cache entries in case the ISP's<br />
                           # DNS servers go offline.<br />
  }</code></p>
<p>Notice the file variable which tells pdnsd where to find the nameservers it will query. Once this is complete, the pdnsd daemon can be restarted. Now, NetworkManager must be told to use localhost for DNS lookups. This can be done by right-clicking the nm-applet icon and configuring the wireless for &#8220;Automatic (DHCP) Address Only&#8221;, and enter 127.0.0.1 as the DNS server. Once this is complete, you can test it with the following commands:</p>
<p><code>jaigner /var/cache $ dig kernel.org | grep Query<br />
;; Query time: 75 msec<br />
jaigner /var/cache $ dig kernel.org | grep Query<br />
;; Query time: 0 msec<br />
</code></p>
<p>The second time the command was called, the cached result was fetched. If your Query time is greater than 1ms, it is likely that something is misconfigured.</p>
]]></content:encoded>
			<wfw:commentRss>http://greynode.org/2010/05/09/pdnsd-and-networkmanager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Functional Programming with the Unix Command Line</title>
		<link>http://greynode.org/2009/06/25/functional-programming-with-the-unix-command-line/</link>
		<comments>http://greynode.org/2009/06/25/functional-programming-with-the-unix-command-line/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 06:29:30 +0000</pubDate>
		<dc:creator>Jeff Aigner</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[one liners]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scripting languages]]></category>

		<guid isPermaLink="false">http://greynode.org/?p=66</guid>
		<description><![CDATA[I was pondering the unix command line the other day while reading sed &#38; awk, and I came to the following revelation: variables aside, the unix command line is a lot like functional programming. Using the command line, you can build a functional program by redirecting I/O between various programs, or functions. Many of the [...]]]></description>
			<content:encoded><![CDATA[<p>I was pondering the unix command line the other day while reading <em>sed &amp; awk</em>, and I came to the following revelation: variables aside, the unix command line is a lot like functional programming. Using the command line, you can build a functional program by redirecting I/O between various programs, or <em>functions</em>. Many of the programs one uses to build one-liners are essentially <a href="http://en.wikipedia.org/wiki/Pure_function"><strong>pure functions</strong></a>. An example of a pure function on the unix command line might be the programs <em>uniq</em> or <em>sort</em>. Various other functions such as <em>ps</em> and <em>wget</em> are not so pure, as their output relies on I/O with the operating sytem or server.</p>
<p>All theory aside, here are a few good one-liners.</p>
<h2>Uploading Files</h2>
<blockquote>
<pre>tar cjvf - yourDirectory | ssh uname@host "cat &gt; yourDirectory.tar.bz2"</pre>
</blockquote>
<p>This command will create an archive of &#8220;yourDirectory&#8221; and upload it to your server via SSH, all in one chained command. Quite handy for uploading local content for sharing or backup.</p>
<p><strong>Edit:</strong> Apparently this command transfers large files extremely slow. Oops.</p>
<h2>Checking FreeBSD UPDATING File Automatically</h2>
<blockquote>
<pre>portversion | awk '/&lt;/ {print $1}' |
xargs -I '{}' awk '/AFFECTS:.*{}/ {print}' /usr/ports/UPDATING &gt; updates.txt</pre>
</blockquote>
<p>Ok. So this command pertains to the FreeBSD ports system. It is not recommended that you upgrade all your ports at once. There is often information contained in the file /usr/ports/UPDATING about special instructions you may have to follow while upgrading a package. Often times you may have to recompile other packages, or add a line to a configuration file, etc. The string above will check all of the ports tht are out of date, and compare them to the UPDATING file to see if the package is contained. If it is, it writes the name of that port to updates.txt. You can then use this file to know which ports have special instructions. You should probably write an alias for this one.</p>
<h2>Converting Line Endings</h2>
<p>The following two commands should help with reformatting files. Often times I find myself getting web designs from someone who uses windows. Most editors on windows will save files with DOS line endings. When you open one of these files in unix (in certain editors), the line endings won&#8217;t appear properly. The following commands will circumvent this problem, in either situation.</p>
<h3>Convert from unix (\n) to DOS (\r\n)</h3>
<blockquote>
<pre>awk '{sub(/$/, "\r")};1' unix_endings.txt &gt; dos_endings.txt</pre>
</blockquote>
<h3>Convert from DOS (\r\n) to unix (\n)</h3>
<blockquote>
<pre>awk '{sub(/\r$/, "")};1' dos_endings.txt &gt; unix_endings.txt</pre>
</blockquote>
<p>And yes, I realize that I use too many commas when I write: I&#8217;m working on it.</p>
]]></content:encoded>
			<wfw:commentRss>http://greynode.org/2009/06/25/functional-programming-with-the-unix-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scripting Languages</title>
		<link>http://greynode.org/2009/06/22/scripting-languages/</link>
		<comments>http://greynode.org/2009/06/22/scripting-languages/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 22:02:04 +0000</pubDate>
		<dc:creator>Jeff Aigner</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[GNU]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scripting languages]]></category>

		<guid isPermaLink="false">http://www.greynode.org/?p=48</guid>
		<description><![CDATA[I just thought I&#8217;d share with you Random thoughts on scripting languages by Brian Kernighan. After reading this, I looked up the source code to the unix utility wc. The GNU wc program was written in C, and amounted to about 800 lines with comments. A similar program written in awk is a mere 2 [...]]]></description>
			<content:encoded><![CDATA[<p>I just thought I&#8217;d share with you <a title="Random thoughts on scripting languages by Brian Kernighan" href="http://www.greynode.org/pdf/CS152-Lecture_14-Kernighan.pdf">Random thoughts on scripting languages by Brian Kernighan</a>.</p>
<p>After reading this, I looked up the <a title="source code for coreutils" href="http://www.gnu.org/software/coreutils/">source code to the unix utility wc</a>. The GNU <em>wc</em> program was written in C, and amounted to about 800 lines with comments. A similar program written in <a title="awk" href="http://www.gnu.org/manual/gawk/gawk.html"><strong>awk</strong></a> is a mere 2 lines long:</p>
<blockquote>
<pre>{ nc += length($0) + 1; nw += NF }
END { print NR, "lines", nw, "words", nc, "characters" }</pre>
</blockquote>
<p>I know you are probably thinking that I just made an unfair comparison. Yes, I did.</p>
]]></content:encoded>
			<wfw:commentRss>http://greynode.org/2009/06/22/scripting-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replace Text Recursively with sed</title>
		<link>http://greynode.org/2009/06/17/replace-text-recursively-with-sed/</link>
		<comments>http://greynode.org/2009/06/17/replace-text-recursively-with-sed/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 20:53:31 +0000</pubDate>
		<dc:creator>Jeff Aigner</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[one liners]]></category>

		<guid isPermaLink="false">http://www.greynode.org/?p=45</guid>
		<description><![CDATA[Here is a quick little trick I discovered today when I needed to replace text in multiple files recursively: grep -rl -e &#60;searchterm&#62; * &#124; xargs sed -i .bak 's/searchterm/newterm/i' There might be a problem with files that have spaces in the names (because xargs will take a space as the start of a new [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick little trick I discovered today when I needed to replace text in multiple files recursively:</p>
<blockquote>
<pre>grep -rl -e &lt;searchterm&gt; * | xargs sed -i .bak 's/searchterm/newterm/i'</pre>
</blockquote>
<p>There might be a problem with files that have spaces in the names (because xargs will take a space as the start of a new argument). To solve this problem, you should be able to do something like this:</p>
<blockquote>
<pre>grep -rl --null -e &lt;searchterm&gt; * |</pre>
<pre>xargs -0 sed -i .bak 's/searchterm/newterm/i'</pre>
</blockquote>
<p>If you are using GNU grep, you could also use -Z instead of &#8211;null. I happen to be using the BSD version of grep, so -Z isn&#8217;t an alias for &#8211;null.</p>
]]></content:encoded>
			<wfw:commentRss>http://greynode.org/2009/06/17/replace-text-recursively-with-sed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->