<?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"
	>

<channel>
	<title>Rudd-O.com &#187; Tutorials</title>
	<atom:link href="http://rudd-o.com/archives/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://rudd-o.com</link>
	<description>We only do fun stuff.</description>
	<pubDate>Thu, 24 Jul 2008 20:34:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>A primer into software package management using RPM</title>
		<link>http://rudd-o.com/archives/2007/11/14/a-primer-into-software-package-management-using-rpm/</link>
		<comments>http://rudd-o.com/archives/2007/11/14/a-primer-into-software-package-management-using-rpm/#comments</comments>
		<pubDate>Wed, 14 Nov 2007 18:29:45 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[RPM]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/11/14/a-primer-into-software-package-management-using-rpm/</guid>
		<description><![CDATA[Since apparently my last article ignited a small flamewar, let’s talk a bit about package management in RPM-based distros.  Yeah, Fedora, Red Hat, SuSE, Mandrake, those.  And when I say package management, all I mean is software installation, really.



This will be a command-line tutorial-style article, and we’re gonna get down to basics, so [...]]]></description>
			<content:encoded><![CDATA[<p>Since apparently <a href="http://rudd-o.com/archives/2007/11/14/i-dunno-what-people-say-when-they-talk-about-rpm-hell/" title="I dunno what people mean when they talk about RPM hell">my last article ignited a small flamewar</a>, let’s talk a bit about package management in RPM-based distros.  Yeah, Fedora, Red Hat, SuSE, Mandrake, those.  And when I say package management, all I mean is software installation, really.</p>

<p><span id="more-1819"/></p>

<p>This will be a command-line tutorial-style article, and we’re gonna get down to basics, so no GUIs or automated installatinos from the Internet (automated dependency management) here.  I will, however, make a recommendation as to which dependency management system you should use, because nowadays it would be rather insane to do the following work manually — except for very particular cases in which this tutorial will come in very handy.</p>

<h2>Installing packages</h2>

<p>You want new software?  You have to install it.  First you download it from the ‘Net (you’re gonna be looking for a file ending in <code>.rpm</code>), then you install it on your system.  As simple as that… in theory.</p>

<p>The basic installation operation in RPM is <code>rpm -i packagename-x.y.z.rpm</code>.  I tend to combine it with the <code>-vh</code> arguments which cause a progress bar to appear, and verbose messages to be printed onscreen for a variety of operations within the transaction.</p>

<p><em>Transaction</em>.  With RPM, to ensure the integrity of your computer, either the package installation happens, or it doesn’t happen at all.  If you request to install 450 packages in a single command (which you could easily do), and one of them cannot be fit into the system, the transaction fails and your system remains untouched.  Reasons for a failure may include that:</p>

<ul>
<li>the package you requested to install is already installed, whether the installed one is an older or a newer version </li>
<li>the package would trample on files owned by another installed package</li>
<li>the package is bad</li>
<li>the package requires another package or set of packages installed beforehand — this is called a <em>dependency</em></li>
</ul>

<p>All of those reasons, and a couple more, could leave your system broken if RPM were actually to go through with installation.  Therefore, RPM stops when it detects any of these conditions.</p>

<h3><code>--force</code></h3>

<p>Unless you augment the command with the <code>--force</code> argument.  Trust me when I say this: if RPM is refusing to install a package, under no circumstances should you use <code>--force</code> even if you badly need to.  RPM is probably much better informed than you are as to what the system actually needs to continue functioning properly, and you should trust it.  <code>--force</code> is only handy when you’re absolutely sure of how the different related components of your system relate to each other.</p>

<h3>Upgrades and downgrades</h3>

<p>We see that <code>rpm -i</code> will fail if you attempt to install a newer or an older version:</p>

<ul>
<li>If you really need to downgrade, you can always append <code>--oldpackage</code> to the command line, and if the integrity checks are A-OK, RPM will downgrade a package for you.</li>
<li>Conversely, if you want to upgrade, you use <code>rpm -U</code> instead of <code>rpm -i</code>.  As a matter of fact, <code>rpm -U</code> will both install and upgrade packages happily, so you can just use <code>rpm -U</code> most of the time, and forget about <code>-i</code>.</li>
</ul>

<p>RPM will also, in the spirit of preserving your system as pure and functional as possible, refuse to overwrite custom configuration files in your computer.  It will, however, deposit them in the folder where they were meant to live, by appending a <code>.rpmnew</code> extension to the new file — so you can use the standard <code>find</code> command to find and inspect these config files, see if they bring anything new and useful to the table.</p>

<h3>Controlled mass upgrades of what you already have</h3>

<p>What if your best friend shared a CD-ROM with the latest updates — say, 850 RPM files — for your Linux distribution?  You could go one by one and install each.  That’s not gonna go well, because many of those updates may not be installed on your system.</p>

<p>What you could do instead is use <code>rpm -F</code>.  Like issuing a command <code>rpm -Fvh *.rpm</code> while on the CD-ROM directory.  <code>-F</code> means <em>freshen</em> — it will only upgrade packages for which older version are already installed on your system.</p>

<p>In theory, you could perform an entire operating system upgrade this way.  In practice, it’s a little more complicated because as distros evolve, they start requiring more base packages which you don’t have installed, and <code>-F</code> won’t know which ones are these (although it will tell you which dependency it failed to find installed!).  When I say in practice, I mean it — I have used this method to upgrade a machine that just didn’t have enough RAM to run an installer on — and I succeeded, but I had to go in smaller batches of <code>rpm -F</code>’s with some <code>rpm -U</code>’s in between.</p>

<h2>Package removal</h2>

<p>Want to remove a package? <code>rpm -e</code> is what you’re looking for.  As discussed in the previous section, if a removal would break your system, RPM would not let you perform.</p>

<p>Config files are also dealt with gracefully.  If you’ve changed any, RPM will save them with the same file name, and a <code>.rpmsave</code> extension.  This is incredibly well-thought-out, because you will often need them sooner or later!</p>

<h2>Listing and inspecting packages on your system</h2>

<p>Do <code>rpm -qa</code>.  The <code>-q</code> stands for <em>query</em>, and the <code>-a</code> stands for <em>all</em>.  Most RPM commands accept <code>-a</code> as an argument to say <em>all</em> anyway, so it’s good to keep it in mind.</p>

<p>By default, it will present you a one-column list with all the package names and currently installed versions of them.  If you want more specific information, <code>rpm -qi packagename</code> (note the use of a package name as opposed to a file name) is usually what you want.  And <code>rpm -qpi packagename-x.y.z.rpm</code> (note the filename) is used to inspect uninstalled RPM packages on disk.</p>

<p>Want to know which package a file belongs to? <code>rpm -qf /path/to/said/file</code> will tell you.  Very handy!</p>

<h2>Integrity verification</h2>

<p>Want to see if any files have been modified, and how?  <code>rpm -V packagename</code> is the command.  It will display a series of lines, one for each file that has been modified, or nothing at all if no files have been touched.  Several aspects are displayed in a column-packed display: file times, permissions, integrity and a whole lotta more are included.  Checkt he RPM manual page to see what each column means.</p>

<p>Perhaps you’d like a full audit of what’s on your system and what’s been changed?  Combine two popluar arguments into <code>rpm -Va</code>.  Verify all.  It will probably be a long list so make sure to redirect the output to a file.</p>

<h2>Getting packages for your distro</h2>

<p>Easy.  Go to Google, type the name of the package followed by a space and the letters “RPM”.  Lots of results will follow.  Find those results that appear from RPM repositories (those sites usually say they are RPM repositories, so you’ll have no problem).  If one of your packages has a dependency problem, you can also type the dependency name into Google followed by “RPM” — and that will most likely help you solve dependency problems.</p>

<h3>Get Smart!</h3>

<p>But, honestly, that’s inefficient.  Just get <a href="http://www.smartpm.org/">Smart</a>, where you’ll be able to add said repositories to the Smart configuration (don’t panic, it’s usually an URL that needs to go into a file in <code>/etc/smart/channels</code> plus a command to import the security key of the repository — and repositories explain this procedure quite more eloquently than I do when I’m this sleepy).  Then you will be able to invoke Smart via the command line or the nice GUI it has, request a particular package and install it.  Smart will automatically download all the depended packages and install them for you.</p>

<p>Don’t forget to read the Smart manual page!</p>

<h2>Conclusions</h2>

<p>And that concludes our RPM crash course.  If you have any doubts, please add them as comments below.  And discuss!</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/11/14/a-primer-into-software-package-management-using-rpm/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to divide and conquer a problem the UNIX way</title>
		<link>http://rudd-o.com/archives/2007/11/02/how-to-divide-and-conquer-a-problem-the-unix-way/</link>
		<comments>http://rudd-o.com/archives/2007/11/02/how-to-divide-and-conquer-a-problem-the-unix-way/#comments</comments>
		<pubDate>Fri, 02 Nov 2007 16:37:59 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/11/02/how-to-divide-and-conquer-a-problem-the-unix-way/</guid>
		<description><![CDATA[If you’re one of our regular readers, you’ll remember reading the article and script I wrote on automating BitTorrent downloads with TorrentFlux and rsync.  The script has come to be quite handy to me, but the process of writing it is much more fun and appealing.  Here’s how I did it.



What you’re about [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re one of our regular readers, you&#8217;ll remember reading the article and script I wrote on <a href="post:how-to-automate-torrent-downloads-using-torrentflux-b4rt-cron-and-rsync">automating BitTorrent downloads with TorrentFlux and rsync</a>.  The script has come to be quite handy to me, but the process of writing it is much more fun and appealing.  Here&#8217;s how I did it.</p>

<p><span id="more-1796"></span></p>

<p>What you&#8217;re about to read is a short, true story that details how I went from idea to solution, using the &#8220;UNIX way&#8221; (divide a problem in little pieces, then jump each hurdle with the help of a domain-specific solution, and finally combine each response).</p>

<p>The story is &#8212; honest! &#8212; more about the underlying thought process than the technology I used &#8212; in fact, while I do know Python and I&#8217;ve grown white hairs using Linux, most of the stuff you&#8217;ll see here I taught myself in the course of this challenge.</p>

<h2>TorrentFlux: what it is, how it works</h2>

<p>TorrentFlux is a very interesting Web application you can install on your Web server.  Once installed, it lets you in to a nice interface like any other BitTorrent program where you get to add .torrent files so the torrent gets downloaded directly in your Web server.  Here it is:</p>

<p style="text-align:center"><a href="post:torrentflux-b4rt" rel="attachment wp-att-1800" title="TorrentFlux-b4rt"><img src="content:2007/11/torrentflux.jpg" alt="TorrentFlux-b4rt"/></a></p>

<h3>Advantages of using TorrentFlux</h3>

<p>The reasons to use such a program instead of a normal desktop BitTorrent client are varied:</p>

<ul>
<li>you would like to have a particular, big file (think Linux distro) right away on the server instead of uploading it through your ISP&#8217;s connection</li>
<li>your ISP throttles or blocks BitTorrent (think Comcast)</li>
<li>you would like to avoid downloading through 50 TCP connections at home, and just use one (think speedier Web browsing)</li>
<li>you want to take advantage of the (usually) higher bandwidths available in your Web server during the day, and you&#8217;d like to download the file once it&#8217;s done, from beginning to end (think videos)</li>
<li>you would like to queue up a download while away from home (think vacations)</li>
</ul>

<h3>Disadvantages</h3>

<p>The disadvantages, compared to a regular BitTorrent client, are that:</p>

<ul>
<li>if you want the download in your PC, you need to queue it up separately in a download manager on your PC through FTP,</li>
<li>you need to check TorrentFlux periodically to see if the torrent is done downloading, because you can&#8217;t download a torrent to your PC until the torrent is done,</li>
<li>you can&#8217;t queue up downloads from TorrentFlux to your home PC if you&#8217;re away from your computer, can you?</li>
<li>disk space might be limited in your Web server.</li>
</ul>

<p>What we&#8217;ll do in this article is destroy these disadvantages.</p>

<h2>The problem in a nutshell</h2>

<p>From the aforementioned disadvantages we can clearly see what the problem is.  Being the lazy bastards we are, we want the downloads in our home computer ASAP, without manual intervention.  Our ultimate goal is to:</p>

<ol>
<li>queue up a BitTorrent download in TorrentFlux, and</li>
<li>as soon as it&#8217;s finished, have our home PC automatically &#8220;check it out from the counter&#8221;, and then</li>
<li>erase the file from the TorrentFlux server.</li>
</ol>

<p>Let&#8217;s go do it.</p>

<h2>How I solved it</h2>

<h3>Remoting my server</h3>

<p>How am I going to talk to my server?  This question crossed my mind many times.  In the end, I chose SSH, because it&#8217;s extremely easy to automate and have it work securely without constant interruptions &#8212; remember, we don&#8217;t want to be interrupted with password prompts or anything like it.</p>

<p>I wrote the code that more or less provided enough help for it to work.  As programming languages go, Python is by far the best for the task at hand, so I used it.  OK, I&#8217;ll admit it, I&#8217;m a Python junkie:</p>

<p><pre>#!/usr/bin/env python</pre></p>

<p>from subprocess import Popen,PIPE,STDOUT,call
import fcntl
import re
import os
import sys
import signal</p>

<p>def getstdout(cmdline):
        p = Popen(cmdline,stdout=PIPE)
        output = p.communicate()[0]
        if p.returncode != 0: raise Exception, "Command %s return code %s"%(cmdline,p.returncode)
        return output
def getstdoutstderr(cmdline,inp=None): # return stoud and stderr in a single string object
        p = Popen(cmdline,stdin=PIPE,stdout=PIPE,stderr=STDOUT)
        output = p.communicate(inp)[0]
        if p.returncode != 0: raise Exception, "Command %s return code %s"%(cmdline,p.returncode)
        return output
def passthru(cmdline): return call(cmdline) # return status code, pass the outputs thru
def getssh(cmd): return getstdout(["ssh","-o","BatchMode yes","-o","ForwardX11 no",torrentflux_server] + [cmd]) # return stdout of ssh.  doesn't return stderr
def sshpassthru(cmd): return call(["ssh","-o","BatchMode yes","-o","ForwardX11 no",torrentflux_server] + [cmd]) # return status code from a command executed using ssh</p>

<p>Interesting, isn&#8217;t it?  Now I have two functions:</p>

<ul>
<li>one that gets me the text of a command executed by SSH, and</li>
<li>another that discards the text but returns the return value of the executed command &#8212; which, if you know the UNIX convention, it&#8217;s zero for success, and anything else for errors.</li>
</ul>

<h3>Determining which torrents are done</h3>

<p>The first hurdle I need to surpass: which torrents from the torrent list are already done?  After a little poking around the Web, I discovered that with the help of a command called <code>fluxcli</code> that ships with TorrentFlux, I can get a list of active torrents in text form.</p>

<p>So that&#8217;s solved.  All I needed is some code that parses the rows returned, selects only those rows that say Done or Seeding in the status column, and that should return the name of each torrent that&#8217;s ready to download.</p>

<p>The code in question is this:</p>

<p><pre>def get_finished_torrents():
        stdout = getssh("%s transfers"%fluxcli)
        stdout = stdout.splitlines()[2:-5]
        stdout = [ re.match("^- (.+) - [0123456789.]+ MB - (Seeding|Done)",line) for line in stdout ]
        return [ match.group(1) for match in stdout if match ]</pre></p>

<p>Stupidly simple, and it makes use of the SSH remoting functions (dare I say hacks?) I wrote before.  And, may I say, only three lines, really.  It returns a list with the names of the torrents.</p>

<p>Next up, getting the file names inside the torrents.</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/11/02/how-to-divide-and-conquer-a-problem-the-unix-way/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Six things to demand from your Internet Service Provider</title>
		<link>http://rudd-o.com/archives/2007/10/31/how-to-choose-a-good-internet-service-provider-what-criteria-really-matter/</link>
		<comments>http://rudd-o.com/archives/2007/10/31/how-to-choose-a-good-internet-service-provider-what-criteria-really-matter/#comments</comments>
		<pubDate>Thu, 01 Nov 2007 00:36:49 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Ethics]]></category>

		<category><![CDATA[ISPs]]></category>

		<category><![CDATA[Personal freedoms]]></category>

		<category><![CDATA[Politics]]></category>

		<category><![CDATA[Privacy]]></category>

		<category><![CDATA[Tips]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/10/31/how-to-choose-a-good-internet-service-provider-what-criteria-really-matter/</guid>
		<description><![CDATA[In the world of Internet service advertising, we’re perpetually bombarded with ads that, above all, extol the “virtues of a faster Internet experience”.  Don’t fall into the trap — here are six aspects you should evaluate beyond the “numbers” in your current or future Internet contract:




    Real speed
    [...]]]></description>
			<content:encoded><![CDATA[<p>In the world of Internet service advertising, we’re perpetually bombarded with ads that, above all, extol the “virtues of a faster Internet experience”.  Don’t fall into the trap — here are six aspects you should evaluate beyond the “numbers” in your current or future Internet contract:</p>

<p><span id="more-1794"/></p>

<ul>
    <li>Real speed</li>
    <li>Guaranteed bandwidth</li>
    <li>Unfiltered, unthrottled service</li>
    <li>Reliability and quality of service</li>
    <li>Access from the outside world</li>
    <li>Privacy, neutrality and censorship</li>
</ul>

<p>Each and every one of these aspects can make or break the honeymoon with your ISP.  Each matter independently, and once you’ve done a little research on what your ISP of choice is doing to grant (or deny) them to you, you’ll be in a position to make a much more informed decision.</p>

<h2>Bandwidth is <em>not</em> speed.  <em>Latency</em> is.</h2>

<p>If you are anything like the next person, by now you’ve been led to believe that your Internet experience is determined by bandwidth.  That’s bullshit. Bandwidth is hoy many bytes you can download per second — and nothing more.</p>

<p>Anything above 500 kbits per second guarantees enough speed to make Web surfing snappy — <strong>if, and only if, the latency of your connection is low enough</strong>.   Becaus, you see, <a href="http://rescomp.stanford.edu/~cheshire/rants/Latency.html">latency is key</a> — it’s the time your computer takes to initially communications with Web (or other types of Internet) servers.</p>

<h3>What happens when you click on a link</h3>

<p>After you click on a hyperlink, your Web browser (more or less) goes through the following steps:</p>

<ol>
    <li>It connects your computer to a Web server and requests a Web page.</li>
    <li>It receives the response, starts processing it and (in parallel) starts other requests — to get the images, videos, styles and scripts that actually form the page.  But only four of those at a time.</li>
</ol>

<p>If each of those steps can be started in, say, 50 milliseconds, you’re golden — the page more or less snaps in front of your eyes.  But if they take over a second each… well, let’s say you have a problem because, for the average Web page, you will never see it settle down before ten or so seconds since your last click.</p>

<h3>What happens when you play games over the Internet</h3>

<p>Let’s imagine for a moment that you’re playing Unreal Tournament, or any other fast-paced first person shooter kinda game.  Just blink once — boom, you’re dead.  That’s how long it takes for someone to shoot your neck and rip your head off.</p>

<p>A blink of an eye is, literally, 25 milliseconds.  Not a problem for wireless or wired local networks — because the bullets traveling through the network take less than two milliseconds to get eaten by your enemies.  But if you’re gaming through an Internet connection and your enemy is sitting just 200 milliseconds “away”, you’re going to have real trouble making any kills.</p>

<p>Sure, modern games incorporate mechanisms that attempt to compensate for that latency problem.  But they only go so far.</p>

<h3>What determines latency</h3>

<p>Latency is determined by two factors:</p>

<ol>
    <li>The physical distance of the route that information takes through the Internet.  Not a really big hurdle, since information travels at a rather close factor to the speed of light.</li>
    <li>The time each “hop” (Internet router) takes to process and forward that information to the next hop.</li>
</ol>

<p>You can verify this yourself.  Open a command line (<code>cmd.exe</code> on Windows, <code>konsole</code> or <code>gnome-terminal</code> on Linux) and type (on Windows) <code>tracert google.com</code> (on Linux, substitute <code>tracert</code> for <code>traceroute</code>).  You’ll see a table grow: each row is a hop, and the three columns on the right side are the times, in milliseconds, that information took to reach that hop.  The last row will contain the final destination’s latency measurement.  You can substitute <code>google.com</code> for your favorite Web site’s address or your gaming friend’s IP address.</p>

<p>So latency is key — now you know that.  Next up: how much bandwidth you’re really getting?</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/10/31/how-to-choose-a-good-internet-service-provider-what-criteria-really-matter/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Memo from Freesoftwareburg: How to effectively address the free software community</title>
		<link>http://rudd-o.com/archives/2007/10/08/memo-from-freesoftwareburg-how-to-effectively-address-the-free-software-community/</link>
		<comments>http://rudd-o.com/archives/2007/10/08/memo-from-freesoftwareburg-how-to-effectively-address-the-free-software-community/#comments</comments>
		<pubDate>Mon, 08 Oct 2007 23:56:56 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Free software]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/10/08/memo-from-freesoftwareburg-how-to-effectively-address-the-free-software-community/</guid>
		<description><![CDATA[Winds of change are sweeping through the software industry.  Today, it’s no longer fashionable to decry free software types as it was just a few years ago — the cool kids are all “leveraging” and reaching out to free software communities.  But not everyone’s doing it right, so let’s explore seven principles to [...]]]></description>
			<content:encoded><![CDATA[<p>Winds of change are sweeping through the software industry.  Today, it’s no longer fashionable to decry free software types as it was just a few years ago — the cool kids are all “leveraging” and reaching out to free software communities.  But not everyone’s doing it right, so let’s explore seven principles to start a positive relationship with free software.</p>

<p><span id="more-1709"/></p>

<p><em>This is a work in progress. I expect and will take your contribution into consideration — use the <a href="#respond">comment form</a> below to voice your doubts, tips or flames.</em></p>

<p>With so many companies finally realizing the potential of free software and open source, it’s not surprising at all that some are failing miserably to engage free software communities effectively.  Instead of focusing on what they’re doing wrong, let’s focus instead on what they must get right.</p>

<p>With that intent in mind, let’s explore seven principles that will make your life easier when engaging free software types.  In summary:</p>

<ol>
<li>Know your audience</li>
<li>Your argument must rely on facts and reason</li>
<li>Respect community members’ time, rules and terms</li>
<li>Develop a thick skin</li>
<li>Contribute</li>
<li>Be humble</li>
<li>Make it interesting, make it fun</li>
</ol>

<p>Here’s each principle explained.</p>

<h2>Know your audience</h2>

<p>We’re not all the same.  Before even attempting to address us, do your research and figure out the “rules” of the particular community you’re trying to touch base with.</p>

<p>Despite the title of this article, there is most definitely no single “free software community” to address in the first place.  It’s all a multitude of communities centered around their own projects, and collaborating between each other in a loosely coupled fashion.</p>

<p>You see, the closest thing we get to have in common is the common core value of <em>sharing = good</em> — and even so, many in our own collective of communities do not necessarily place that value up high in their own scale of values (witness Linus Torvalds, for example).  You could possibly argue we all share a passion for technology — which might be true — but we all most definitely do not share even technical proficiency; modern free software communities are chock-full of people doing translation, usability and multimedia artwork.</p>

<p>Some communities are led by consensus.  Others, by meritocracy.  Some have benevolent dictators.  Many projects out there have no defined leadership and are in a stage of transition.</p>

<p>Corollary: do not assume.  Do your homework.</p>

<p>Fortunately, this homework is easy:</p>

<ul>
<li>You can easily poke around a project’s Web site, skim over technical documents, and invest a couple of minutes reading mailing list archives, to get a general idea of how that particular community beats its drum.</li>
<li>You can also look stuff up (Google is very free software-friendly).</li>
<li>Try to familiarize yourself with the issues (esp. technical details).  That goes double if you’re a reporter — there are reams of inaccurate stories out there, just because the reporter was lazy enough not to “go to the source”.</li>
<li>Some communities (the most mature ones, usually) even list guidelines for contributors and explicit rules of engagement.</li>
</ul>

<p>Therefore, be informed.  An ounce of prevention beats a hundred pounds of hammering.</p>

<h2>Your argument must rely on facts and reason</h2>

<p>In general, free software communities place extremely high value on the ability to argue and persuade using facts and reason.</p>

<p>The reason this is so pervasive in free software is quite clear: every single last drop of development and communication happens absolutely in the open — usually with easily accessible public records.  Think about it: past discussions, decisions and the reasons behind each and every one of them are archived somewhere and usually accessible by poking around search engines with the right keywords.</p>

<p>Another reason (I love to call it the “doers factor”) is that, since new ideas can be tested quickly and pitted against each other.  Do you think Project X will fare better with wings rather than legs?  Prove it!  In fact, cloudy proposals usually meet head-on with that sentence in our public discussion forums.</p>

<p>As you can see, “conventional politics” stand little chance against the gospel of “try it and support it” (though they infrequently win some points).</p>

<p>So don’t attempt to convince a community of developers by using slick persuasion.  You will be called on it and asked to provide facts backing your points of view.  You might also get reprimanded by project leaders because you weren’t diligent enough to “check the archives”.  In the worst case, you will be shunned for long.</p>

<h2>Respect community members’ time, rules and terms</h2>

<p>You need to understand that many people involved with the free software movement are volunteers.  Though a large subset of those people will be happy to help you fix any issue you may have, efficiency is key.</p>

<p>That’s why we:</p>

<ul>
<li>use mailing lists with public archives,</li>
<li>use bug tracking systems,</li>
<li>idle a lot on Internet relay chat channels,</li>
<li>respond sparsely and oftentimes with the dreaded <acronym title="Read The Fucking Manual">RTFM</acronym> acronym.</li>
</ul>

<p>If you find a bug, please don’t just mumble to yourself — report it through the appropriate channel.  Doing so, while requiring a bit of an extra effort on your part, multiplies the effect your report has, because it benefits everyone — not just you.</p>

<p>If you have an idea that you think it may be worthwhile to pursue within the scope of a community, bring it to the table.  Try to address everyone in the conversation, not just particular project authors.  That way everyone gets an opportunity to shape the idea or to strike it down (in case it’s a bad one).</p>

<p>Same goes if you need help.  Especially in this case, you should try to consult with the Lazyweb — mailing lists and search engines should be your first stop.  Chances are, someone else already asked and got a publicly available reply.</p>

<h2>Develop a thick skin</h2>

<p>If you make a mistake, most free software types will call you on it.</p>

<p>Some of us are callous individuals.  Sometimes, everyone is distressed or tired.  We all are guilty of calling people names at some point.  Don’t get discouraged by these events.  We might call you an idiot today — that doesn’t mean you’re really an idiot, and sometimes we don’t even mean it!</p>

<p>Some communities appreciate sparseness in discourse.  This might be construied by some people to be the equivalent of “go away, outsider; we don’t need you here”.  Nothing could be further from the truth — most free software aficionados are efficiency buffs, and talk is expensive.  Imagine yourself dealing with hundreds or thousands of e-mails daily in addition to coding or management tasks, and you’ll have a clear idea of what managing a free software project is like.  Efficiency is key.</p>

<p>Source code and conversations may contain tons of expletives.  I read years ago a report on profanity in the Linux kernel.  It’s not pretty if you’re into political correctness but, come to think about it, doesn’t it work just fine that way?  Then who cares about the cuss thrown around sparsely?</p>

<p>So try to develop thick skin.  Become immune to callous comments, and keep pressing important issues calmly.</p>

<p>And comfort yourself with the fact that, in the medum-to-long run, projects with truly contentious members drown anyway.</p>

<h2>Contribute</h2>

<p>The whole notion of free software is based on <em>quid pro quo</em>.</p>

<p>We give you something for you to take advantage in any way you please.  We expect you to share in equal terms with you.  And your contribution has value.  We need you.  Here are some clever ways you can contribute in effectively:</p>

<ul>
<li>We hate bugs, so please report them.  Try to provide as much info as you humanly can within time constraints.  Try to keep yourself “in the loop” during the process.</li>
<li>Maintain Web sites and blogs.</li>
<li>Help with project marketing.</li>
<li>Write manuals, guides or tips on public sites.</li>
<li>Deploy a project across the board — then report your issues so everyone benefits.</li>
<li>Publish improvements to free software projects.</li>
<li>Develop new code.</li>
<li>Allocate manpower on collaboration with non-engineering tasks: artwork, translations.</li>
<li>Fund or donate to projects.  A million dollars is fine, but $10 may do it as well.</li>
</ul>

<p>If you do any of these things (OK, OK, I’ll recognize, some of them are more valuable to us than others), your message is way more likely to come across.  Bonus points (yay!) for directly helping the project build its next “killer feature”.</p>

<p>Fact is, if you have something to show, you’ll generate an incredible amount of goodwill towards you.</p>

<h2>Be humble</h2>

<p>I’ve heard all manner of derogatory comments against us free software developers, from the classic “pinko” to the Cold war-era “hippie”, through the equally ignorant “amateur”.</p>

<p>We’re not amateurs, so get rid of those misconceptions.  Each and every one of us is highly likely to be much more proficient and professional in our field of expertise than you.  We’ve made a career out of seeding high-quality products and harvesting respect and reputation out of it.  Technical prowess is the name of the game for us.</p>

<p>In each field of technical expertise, there probably are a handful of gurus in the closed software industry — and probably an even smaller group of free software developers which are in all likelihood as proficient or even more so than their counterparts doing closed source.  This should be self-evident, since free software developers have had access to much more code and learned much more from collective experience resources while having fun at it, whereas the rest probably did it for the money only.  You might be recognized by anywhere between ten and a hundred punks in your company, but we’re recognized, revered and relied as sources of opinion and technical expertise for considerably many more people — some of us count their fans and users in the tens of millions.</p>

<p>Each and every one of us has made a name for ourselves.  Can you say the same of you?  Even if you could, can you co-opt your reputation and technical expertise for the community you’re about to address?</p>

<p>So coming with an attitude of superiority (whatever your reason for that attitude) isn’t going to help your cause.</p>

<p>Be humble, punk.</p>

<p>But don’t get the idea that we’re arrogant just yet.  99% of us are eager to share a few beers with anyone else in equal terms.  The other 1% usually die young from lack of human warmth (and alcohol?).</p>

<h2>Make it interesting, make it fun</h2>

<p>Free software types, believe it or not, are much more play than work.  We are honestly entertained by what we do, and when we no longer have fun, we usually delegate our project to someone else with a more pressing need or a newfound passion for our project.</p>

<p>In a sense, we are probably the luckiest people in the world.  People who actually enjoy what they do from the outset (as opposed to people who secretly want to hang their boss, or people who have had to learn to like what they do by sheer necessity) are far and few between.  And some of us even get paid doing it.  I know I do.</p>

<p>Moral: If you can wrap your message around fun and challenge, you’ll benefit.</p>

<h2>Conclusion</h2>

<p>Let’s recap, one more time:</p>

<ol>
<li>Know your audience</li>
<li>Your argument must rely on facts and reason</li>
<li>Respect community members’ time, rules and terms</li>
<li>Develop a thick skin</li>
<li>Contribute</li>
<li>Be humble</li>
<li>Make it interesting, make it fun</li>
</ol>

<p>These principles might sound like common sense, mixed with a few unexpected nuggets of unique free software idiosyncrasies.  Even so, every day people fail to heed this advice — hey, I’m guilty of it myself!  But it’s never too late to bump the steering wheel and change course.</p>

<p>I hope this article enriches your future experiences with the free software community as much as writing it has enriched me.  I wish you the best of luck, and welcome to the free software world!</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/10/08/memo-from-freesoftwareburg-how-to-effectively-address-the-free-software-community/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tales from responsivenessland: why Linux feels slow, and how to fix that</title>
		<link>http://rudd-o.com/archives/2007/10/02/tales-from-responsivenessland-why-linux-feels-slow-and-how-to-fix-that/</link>
		<comments>http://rudd-o.com/archives/2007/10/02/tales-from-responsivenessland-why-linux-feels-slow-and-how-to-fix-that/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 03:21:05 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Performance]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/10/02/tales-from-responsivenessland/</guid>
		<description><![CDATA[Desktop performance on Linux computers has been a hot-button issue of late, and a source of longstanding fights among the Linux developers.  Today, I want to show you how I boosted (and you can boost) desktop performance dramatically.



The problem

What’s the number one cause of desktop performance problems?

Let me answer that question with another set [...]]]></description>
			<content:encoded><![CDATA[<p>Desktop performance on Linux computers has been a hot-button issue of late, and a source of longstanding fights among the Linux developers.  Today, I want to show you how I boosted (and you can boost) desktop performance dramatically.</p>

<p><span id="more-1703"/></p>

<h2>The problem</h2>

<p>What’s the number one cause of desktop performance problems?</p>

<p>Let me answer that question with another set of questions:</p>

<ul>
<li>Have you noticed how slow your computer is after  after unzipping a big file?</li>
<li>Perhaps you can also notice this effect overnight as well — you return to your computer, and every open application takes a while before they behave snappily again.</li>
<li>Do you use Amarok?  Then you’ll notice this effect after Amarok has finished scanning your music collection.</li>
</ul>

<p>This problem happens all the time.  In fact, I would be willing to bet this is the cause most people find Linux to be slow.</p>

<h2>The source of the problem</h2>

<p>Here’s my chief finding: desktop performance has very little to do with schedulers and real performance.  It has everything to do with disk caching and <em>perceived</em> performance.</p>

<p>Now, bear with me for a second, because what I’m about to explain will let you understand the following.  Based on my limited understanding of the Linux kernel (please correct me if I’m wrong, especially about the terminology), there are two distinct cache types:</p>

<ul>
<li>a block cache: caches block device contents</li>
<li>a inode/dentry cache: one layer above the block cache, caches directory entries and other filesystem-related things that cost more to look up than just block device contents</li>
</ul>

<p>Problem number 1 is that the block cache competes with applications for RAM.  Problem number two is that the block cache competes with the inode/dentry cache.</p>

<p>On a normal desktop Linux computer, when you’re short of RAM, Linux will aggressively try to free memory to enlarge the caches.  It usually does this by paging out unused portions of applications to disk.  This is not good.</p>

<p>Why?  Since disks are slow, the following consequences follow:</p>

<h3>Let’s get technical (skip this heading if you’re uncomfortable with technicalities)</h3>

<p>For desktop performance, where workloads are unpredictable, responsiveness needs dictate that applications’ working sets should be in core as much as possible, because the probability of major page faults in desktop loads is much larger than on server loads.</p>

<p>Let me rephrase that: <span style="font-size: xx-large">Screw data.  Prioritize code.</span></p>

<p>In other words: it’s OK if your application stalls a bit while reading non-cached <em>data</em> from disk, because that isn’t going to make the application seem frozen for a couple of seconds.  It’s <em>not</em> OK if the application freezes because it needs to execute code that was paged out to disk.</p>

<h3>All in all, how Linux uses your RAM matters a lot for desktop performance</h3>

<p>You can see where this is going: if you have 1 GB of RAM (or less) you unzip a 300 MB archive, and the Linux kernel will swap out portions of your applications to disk in an effort to accomodate both the 300 MB file and the blocks of the uncompressed files about to be written on disk.  It will also shrink the inode/dentry cache.</p>

<p>Linux, of course, thinks it’s doing a good thing — the archive uncompresses, in effect, rather quickly because of this.  You, of course, want to kick Linux in the nuts because while (and after) the uncompress took place, starting an application or opening a new browser window suddenly takes ages, and your open applications “blank out” for a couple of seconds before reacting to your clicks and keystrokes.</p>

<p>Think about it: Linux is catering to the needs of the uncompression program, and you are actively telling your computer you want to do other stuff while it happens.  Linux starts to scramble between reading the archive, writing data to disk, and bringing the portions of the applications you’re using “back from the dead” (from swap).  Guess who loses?  If you guessed “the applications” or “you”, you’d have been right.</p>

<p>Even worse: suppose you want to browse your home directory while all of this happens.  In addition to the fact that your file manager is probably half-on-disk by now, you’ve got the problem that Linux needs to re-read your home directory, since the inode/dentry cache has been squashed.</p>

<p>Not good.  I posit that the default settings may be very good for workloads with many repeating tasks, but definitely <em>un</em>good for desktop situations, when applications (and code paths) are diverse and respond only to the whims of the user.</p>

<h3>What we want is perceived performance</h3>

<p>Let’s take a file manager for example. Let’s focus on Konqueror (it’s a nice case study, and it’s a nice file manager).  Suppose I hit the home button on my panel, which shows one of the (usually hidden and prelaunched) Konqueror instances and prompts it to browse my home directory.</p>

<p>If you have lots of RAM, it won’t be a problem — both Konqueror and the contents of your home directory will be in memory, so it’ll be blindingly fast.  But if you’re rather short of memory, it’s a different matter — what happens next determines whether you feel your computer slow or fast.</p>

<p>If Konqueror has been paged out, it will appear to be frozen (or take longer to “start up”) for a couple of seconds, until Linux has paged necessary code paths in.  If, on the contrary, my home directory has been evicted from the RAM cache, Konqueror will show up instantly and be responsive, while the home directory loads.</p>

<p>I’d much rather wait for the directory display than have to wait for Konq to unfreeze because it was paged out.  The difference is that in the first scenario, I can close the window, use the menus, navigate among the window controls, change the URL, abort the operation; in the second case, I’m screwed until Linux decides to fully pagein whatever Konq needs.</p>

<p>That’s what I’m arguing for — perceived performance, not throughput.  It matters to me that I can manipulate my file manager half-a-second after I’ve hit the home button.  It doesn’t matter to me that, because of this preference, the home directory actually takes one second longer to finish displaying.</p>

<p>Variations of this pattern can be found everywhere: in file open dialogs, in multimedia applications with collection managers, basically everywhere an operation requires some sort of progress report.</p>

<h2>The solution</h2>

<p>There are two distinct and complementary measures we’ll take to solve this problem.  Keep reading to find out about them.</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/10/02/tales-from-responsivenessland-why-linux-feels-slow-and-how-to-fix-that/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Making Steinberg Nuendo work on Linux</title>
		<link>http://rudd-o.com/archives/2007/08/24/making-steinberg-nuendo-work-on-linux/</link>
		<comments>http://rudd-o.com/archives/2007/08/24/making-steinberg-nuendo-work-on-linux/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 16:45:32 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[MP3/música]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/08/24/making-steinberg-nuendo-work-on-linux/</guid>
		<description><![CDATA[My passion for music doesn’t stop at enjoyment.  I love to remix, and Nuendo’s the best for that.  Unfortunately, my Windows setup can’t cope with my hardware.



So what do I do?

I run Nuendo on Linux.  Here’s a quick primer — you should be familiar, very familiar with Linux in order to do [...]]]></description>
			<content:encoded><![CDATA[<p>My passion for music doesn’t stop at enjoyment.  I love to remix, and Nuendo’s the best for that.  Unfortunately, my Windows setup can’t cope with my hardware.</p>

<p><span id="more-1664"/></p>

<p>So what do I do?</p>

<p>I run Nuendo on Linux.  Here’s a quick primer — you should be familiar, very familiar with Linux in order to do this.</p>

<p>But Nuendo didn’t work originally.  That’s because Nuendo requires something called ASIO, related to low-latency audio output — why this is required on Linux as well escapes my comprehension, since Linux already has very low-latency output.</p>

<p>Here’s what I did.</p>

<h2>Install <code>wine</code> and <code>wine-dev</code></h2>

<p>I’m using KUbuntu Feisty, so your mileage may vary, but you need both packages (yes, the development package as well) because you will be compiling something after a few minutes.  In case you’re using RPM-based distros like CentOS or Fedora, the development package is <code>wine-devel</code>.</p>

<h2>Link Nuendo to your ~/.wine/drive_c folder</h2>

<p>I never “installed” Nuendo using the installation software.  I just linked my Windows partition to <code>/home/rudd-o/.wine/drive_c</code>.  In my machine, that’s where Wine expects to find the <code>C:</code> drive.</p>

<p>Your mileage may vary.  You may want to copy the contents of your <code>C:</code> drive there, or use <code>winecfg</code> to point Wine to the right directory.</p>

<h2>Download wineasio</h2>

<p><code>wineasio</code> is a library that allows Wine’s JACK output plugin to serve ASIO programs.  Nuendo is one of those.</p>

<p><a href="http://people.jacklab.net/edogawa/files/wineasio/wineasio-0.3.tar.gz">Here’s the download</a>.</p>

<h2>Install JACK and its development files</h2>

<p>In my machine, the two packages I needed to install were <code>jackd</code> and <code>libjack0.100.0-dev</code>.  Again, your mileage may vary.</p>

<h2>Get <code>asio.h</code></h2>

<p><code>asio.h</code>… I got that file using a <em>samizdat</em> method, because otherwise I would have had to sign an agreement with Steinberg.  Turns out asio.h is quite widespread in the World Wide Blag.  <a href="http://www.google.com/codesearch?hl=en&amp;q=+file:asio.h+show:X9n9dsLtoxQ:Q16wUaIveqQ:Br0SaOEe8r0&amp;sa=N&amp;cd=4&amp;ct=rc&amp;cs_p=http://muonics.net/extras/GRL_ROTTERDAM_KPN_APP/OSXSRC.zip&amp;cs_f=OSXSRC/libs/rtAudio/asio.h#a0">Just jump here and copy the text</a>.  If this link ever dies, just look for <code>file:asio.h</code> in Google Code Search.</p>

<h2>Uncompress the <code>wineasio</code> tarball</h2>

<p>And then place the <code>asio.h</code> file in the uncompressed folder.</p>

<h2>Compile and deploy</h2>

<ul>
<li>Open a terminal and change to the <code>wineasio</code> uncompressed folder.</li>
<li>Run <code>make</code>.  At this point, if you failed to install the required development packages, you will see a slew of compiler error messages.  Go back and reread the earlier sections.</li>
<li>Then, as root, run <code>make install</code>.</li>
<li>Then, back as your regular user, run <code>regsvr32 wineasio.dll</code>.</li>
</ul>

<h2>Configure Wine to use the JACK driver</h2>

<p>Run <code>winecfg</code> on the terminal.  On the Audio tab, select the JACK output plugin.</p>

<p>Now I had to do a fix, because my Wine installation wasn’t finding a file named <code>libjack.so.0</code>.  I did this:</p>

<p><pre>ln -s /usr/lib/libjack-0.100.0.so.0.0.23 /usr/lib/libjack.so.0</pre></p>

<p>So go find a library named <code>libjack-0.<em>something.so.something</em></code>, and link it so it’s named <code>/usr/lib/libjack.so.0</code>.  Why my distribution failed to do this for me, escapes my understanding.</p>

<h2>Start the JACK driver</h2>

<p>This is easy.  I used the command <code>jackd -d alsa -r 44100</code>.</p>

<h2>Start Nuendo</h2>

<p>Use your terminal to change to your Nuendo folder, and then run <code>wine nuendo.exe</code>.</p>

<p>Pay attention to any of the error messages.  If Nuendo starts up and doesn’t say that the audio engine couldn’t be enabled, then you’re set to start recording and playing back.</p>

<p>Good luck with your Nuendo and Linux.  Now, if you’ll excuse me, I’m heading for my latest 6-hour set/megamix.</p>

<p>Update: I have a showcase of <a href="http://rudd-o.com/archives/2007/10/19/the-ultimate-linux-audio-hack/" title="The ultimate Linux audio hack">two</a> <a href="http://rudd-o.com/archives/2007/10/20/solving-choppy-sound-and-audio-stutter-in-vmware/" title="Solving choppy sound and audio stutter in VMware">alternate</a> methods  that use VMware and Windows directly if you can’t make this work.  I know it’s hard to make this method work, and with my machine recently updated to Kubuntu Gutsy Gibbon, this method stopped working.</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/08/24/making-steinberg-nuendo-work-on-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Managing and keeping tabs of network traffic on Linux</title>
		<link>http://rudd-o.com/archives/2007/08/23/keeping-tabs-on-network-traffic-on-linux/</link>
		<comments>http://rudd-o.com/archives/2007/08/23/keeping-tabs-on-network-traffic-on-linux/#comments</comments>
		<pubDate>Thu, 23 Aug 2007 13:15:08 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Free software]]></category>

		<category><![CDATA[Information security]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Networking]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/08/23/keeping-tabs-on-network-traffic-on-linux/</guid>
		<description><![CDATA[Is your Net connection slow?  Ever wonder what the hell’s going down the wire?  Here are five free and effective tools to diagnose network traffic issues.



If you’ve been using Linux for a while, no doubt you’re already amazed with the amount of software there is for you to use, for free.  My [...]]]></description>
			<content:encoded><![CDATA[<p>Is your Net connection slow?  Ever wonder what the hell’s going down the wire?  Here are five free and effective tools to diagnose network traffic issues.</p>

<p><span id="more-1646"/></p>

<p>If you’ve been using Linux for a while, no doubt you’re already amazed with the amount of software there is for you to use, for free.  My own last count revealed in excess of three thousand applications ready to install and use.  But how do we find the gems?</p>

<p>Look no further, because here they are.  These are tools I use on a daily basis to both diagnose my own Internet connections and network performance in remote hosts.  You can’t claim to be a network management expert if you haven’t used at least 5 of these tools, but you don’t need to be an expert to use them either, because they’re brutally easy to use.</p>

<h2>The net essentials in our toolbox</h2>

<p>Let’s explore the first three tools in our toolset.  They’re powerful and easy enough for you to get an overview of what’s going on with your Net connection.</p>

<h3>KSysGuard: view aggregate network traffic</h3>

<p>My favorite, in all aspects, is KSysGuard.  With it, you can plot network usage for all your network interfaces (even though in 99% of all cases, there’s only one network interface, and it’s named <code>eth0</code>).  Take a look at this screenshot:</p>

<p><img src="http://rudd-o.com/wp-content/uploads/2007/08/networking-management-guide-ksysguard.png" alt="Networking management guide: KSysGuard"/></p>

<p>It’s not black magic.  It’s a sheet divided in rectangles, where you can drag and drop the sensors listed on the left to any of the empty rectangles on the right.  When you place any of the sensors on the left, KSysGuard starts plotting.</p>

<p>Bonus points for KSysGuard: you can keep tabs on a remote machine via SSH.  All you need to do is:</p>

<ul>
<li>create an account on the remote machine,</li>
<li>install a small program named <code>ksysguardd</code> (which you can find after installing KSysGuard in the path <code>/usr/bin/ksysguardd</code>) on the remote machine,</li>
<li>set up passwordless SSH authentication for that account,</li>
<li>connect with KSysGuard to the remote machine using <em>File -&gt; Connect to machine…</em></li>
</ul>

<p>The <code>ksysguardd</code> program is self-contained so you can be confident you won’t be introducing security issues.</p>

<p>Here’s an overview sheet plotted from a remote machine (in this case, this Web host):</p>

<p><img src="http://rudd-o.com/wp-content/uploads/2007/08/networking-management-guide-ksysguard-rudd-ocom.png" alt="Networking management guide: KSysGuard Rudd-O.com"/></p>

<p>Here’s another, showing my MythTV PVR and backup machine:</p>

<p><img src="http://rudd-o.com/wp-content/uploads/2007/08/networking-management-guide-ksysguard-gabriela.png" alt="Networking management guide: KSysGuard Gabriela"/></p>

<p>Oh, did I mention KSysGuard can plot much, much more than just network traffic?  I guess not, but the screenshots speak for themselves.  Oh, and the screens are fully customizable, down to the colors used to plot the graphs.  You can save the worksheets for later usage as well.</p>

<p>To install this tool, use your distribution’s favorite package manager, and look for KSysGuard or the <code>kdeadmin</code> package.</p>

<p>In the next page, we’ll explore the different uses of <code>netstat</code>.</p>

<p><em>(May I respectfully request, if you like this article, that you use one of the links right below to submit it to your favorite news site?)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/08/23/keeping-tabs-on-network-traffic-on-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Controlling runaway processes on Linux</title>
		<link>http://rudd-o.com/archives/2007/08/01/controlling-runaway-processes-on-linux/</link>
		<comments>http://rudd-o.com/archives/2007/08/01/controlling-runaway-processes-on-linux/#comments</comments>
		<pubDate>Wed, 01 Aug 2007 13:37:11 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/08/01/controlling-runaway-processes-on-linux/</guid>
		<description><![CDATA[Sometimes, buggy memory hogs can choke your machine.  Here, two tricks: one to recover from a memory choke, another to prevent memory chokes forever.



Misbehaving application frozen?

Has an application stopped responding on your machine?  Well, as long as your machine is still responsive, you can use these tricks to nuke it safely.

On KDE

Hit Ctrl+Alt+Esc. [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, buggy memory hogs can choke your machine.  Here, two tricks: one to recover from a memory choke, another to prevent memory chokes forever.</p>

<p><span id="more-1627"></span></p>

<h2>Misbehaving application frozen?</h2>

<p>Has an application stopped responding on your machine?  Well, as long as your machine is still responsive, you can use these tricks to nuke it safely.</p>

<h3>On KDE</h3>

<p>Hit Ctrl+Alt+Esc.  Your mouse cursor will change &#8212; from an arrow to a small skull/crossbones combo.  Hit the stubborn application with the skull.</p>

<p>It&#8217;ll die.</p>

<h3>On GNOME</h3>

<p>Add a new launcher to your panel and set it so it executes the <code>xkill</code> application.  Now, when an application starts stupidifying itself, just hit the launcher you created (the cursor will change to a square-type &#8220;target&#8221;), then hit the application with your mouse cursor.</p>

<p>It&#8217;ll die.</p>

<h2>Application choking your machine?</h2>

<p>Of course, if your machine is already too slow to use these tricks, they won&#8217;t help you much.  Here&#8217;s why, sometimes, your machine ditches itself into a molasses pit, and how to rescue it from certain death.</p>

<h3>Memory and pathologies</h3>

<div style="font-size: 150%; text-align: right; width: 30%; float: right; margin-left: 1em;">&#8230;almost all applications have this pathological idea (encouraged by the operating system) that memory is a limitless resource&#8230;</div>

<p>You see, almost all applications have this pathological idea (encouraged by the operating system) that memory is a limitless resource &#8212; and when they go overboard, the operating system just dips into the hard disk to simulate memory.</p>

<p>Sometimes, <a href="http://kushaldas.in/?p=170">bugs in an application</a> do cause them to go haywire, requesting memory like there&#8217;s no end.  Once your machine goes down that lane, there isn&#8217;t a simple way to recover it, short of powering it off forcibly.</p>

<p>A fortress-like operating system like Linux isn&#8217;t supposed to die, and yet it does.  However, the fortress I&#8217;m so proud of can, and does, provide you with effective measures against premature deaths of these sort.</p>

<h2>A last-resort trick to recover your machine from the brink of death</h2>

<p>Have you heard of the <em>magic SysRq key</em>?</p>

<p>No?</p>

<p>Well, it&#8217;s <em>magic</em>.  It&#8217;s directly shunted to the Linux kernel.  You press ALT, press the PrintScreen (SysRq) key, and while holding them both down, press one of the letters (each letter has a different function assigned to it).</p>

<p>It&#8217;s not normally enabled, but you can enable it by putting</p>

<p><pre>kernel.sysrq = 1</pre></p>

<p>in your machine&#8217;s <code>/etc/sysctl.conf</code> file.  Oh, and then rebooting.</p>

<p>Here&#8217;s why it&#8217;s useful.</p>

<h3>So, what does SysRq do, really?</h3>

<div style="font-size: 150%; text-align: right; width: 30%; float: right; margin-left: 1em;">Hit Alt+SysRq+K &#8212; the windowing system will restart.  More effective than Ctrl+Alt+Backspace.</div>

<p>Suppose a GUI application you just opened is starting to swallow massive amounts of RAM.  Like, one gigabyte, perhaps?  Your machine is locking up, and you feel the mouse start to stutter at first, then freeze completely &#8212; while the hard disk light in your computer&#8217;s front panel is lighting up frantically, gasping for <del datetime="2007-08-01T13:38:31+00:00">air</del>memory.</p>

<p>You now have three choices:</p>

<ol>
<li>Sit it out and let the Linux kernel detect this situation and kill the abusive application.  This can take way more than 15 minutes.</li>
<li>Press the computer&#8217;s power off button for 5 seconds.  This shuts your machine down uncleanly and leads to data loss.</li>
<li>Hit the magic SysRq combo: <em>Alt+SysRq+K</em>.</li>
</ol>

<p>Should you choose option 3, the graphical subsystem dies immediately.  That&#8217;s because Alt+SysRq+K kills any application that holds the keyboard open &#8212; and, you guessed it, the graphical subsystem is holding it open.  This premature death of the GUI causes all GUI applications to die in a cascade, including the abusive application.</p>

<p>Two to ten seconds later, you will be presented with a login prompt.</p>

<p>Sure, you lost changes to all files you haven&#8217;t saved, and all the tabs in your Web browser&#8230; but at least you didn&#8217;t have to reboot uncleanly, did you?</p>

<h3>But, Ctrl+Alt+Backspace?</h3>

<p>Once the machine is in a critically heavy memory crunch, Ctrl+Alt+Backspace will take too much time to work, because the windowing system will be pressed for memory to even execute.  The magic SysRq key has the luxury of not having that problem <img src='http://rudd-o.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> &#8212; if Ctrl+Alt+Backspace were an IV drip, SysRq would be like a central line.</p>

<h3>Why this key combination exists</h3>

<p>The reason this key combo exists is simple.  Alt+SysRq+K is called SAK (System Attention Key).  It was designed back in the days of, um, yore, to kill all applications snooping on the keyboard &#8212; so administrators wishing to log in could safely do so without anyone sniffing their passwords.</p>

<p>As a preventative security measure, it sure works against keyloggers and other malware that may be snooping on your keyboard, may I say.  And it most definitely works against your run-of-the-mill temporary memory shortage ;-).</p>

<h3>Advantages/disadvantages</h3>

<p>Well, the major disadvantages are:</p>

<ul>
<li>Anyone with keyboard access can reboot or hang your machine using a SysRq key combination.</li>
<li>Once you hit it, since the GUI dies, all of your open applications close, forcibly.</li>
</ul>

<p>But, on a memory crunch, this beats rebooting hands-down.  And that&#8217;s the biggest advantage.</p>

<h2>A definitive cure to runaway applications</h2>

<p>Become an administrator (root) and use your  favorite text editor to open the file <code>/etc/security/limits.conf</code>:</p>

<p><pre># /etc/security/limits.conf
#</pre></p>

<h1>Each line describes a limit for a user in the form:</h1>

<p>#</p>

<h1>&lt;domain&gt;        &lt;type&gt;  &lt;item&gt;  &lt;value&gt;</h1>

<p>#</p>

<h1>Where:</h1>

<h1>&lt;domain&gt; can be:</h1>

<h1>- an user name</h1>

<h1>- a group name, with @group syntax</h1>

<h1>- the wildcard *, for default entry</h1>

<h1>- the wildcard %, can be also used with %group syntax,</h1>

<h1>for maxlogin limit</h1>

<p>#</p>

<h1>&lt;type&gt; can have the two values:</h1>

<h1>- "soft" for enforcing the soft limits</h1>

<h1>- "hard" for enforcing hard limits</h1>

<p>#</p>

<h1>&lt;item&gt; can be one of the following:</h1>

<h1>- core - limits the core file size (KB)</h1>

<h1>- data - max data size (KB)</h1>

<h1>- fsize - maximum filesize (KB)</h1>

<h1>- memlock - max locked-in-memory address space (KB)</h1>

<h1>- nofile - max number of open files</h1>

<h1>- rss - max resident set size (KB)</h1>

<h1>- stack - max stack size (KB)</h1>

<h1>- cpu - max CPU time (MIN)</h1>

<h1>- nproc - max number of processes</h1>

<h1>- as - address space limit</h1>

<p>Add the following line anywhere on the file:</p>

<p><pre>*      soft      as      512000</pre></p>

<div style="font-size: 150%; text-align: right; width: 30%; float: right; margin-left: 1em;"><code>limits.conf</code> is a little-known godsend, and a definite requirement to keep large computing farms or terminal servers under control.</div>

<p>You will need to restart any sessions (graphical/terminal) for this change to take effect.  Additionally, you will need to restart the graphical session manager (GDM or KDM).</p>

<p>Of course, 512000 is just my favorite setting &#8212; but that&#8217;s because I have the privilege of using multi-gigabyte memory sticks on my machine.  If you have much less memory than me, you will want to tune this, while keeping in mind that modern applications can and do take more than 300 MB under exceptional circumstances.</p>

<p>Like, for example, Firefox with 50 tabs/windows open.  Or Evolution managing 2 GB of e-mail.  Hey, both circumstances happen to me, but I guess I&#8217;m an oddball.</p>

<h3>What this &#8220;magic incantation&#8221; in <code>limits.conf</code> does</h3>

<p><code>limits.conf</code> is the file that lets you set per-user/process/system resource limits.  There are several limits to choose from.</p>

<p>One of them is the address space (<code>as</code>).  The address space refers to the maximum amount of RAM (in kilobytes) that a process may request from the operating system.  Any requests above the configured limit are simply refused.</p>

<h3>Advantages/disadvantages</h3>

<p>The fortunate side effect of this recipe is that the majority of applications will disappear and die a horrible death if they request memory indiscriminately.  Which beats having to turn the machine off.</p>

<p>The unfortunate side effect of refused requests for more memory is that the majority of applications will disappear and die a horrible death if they request memory indiscriminately.  That&#8217;s because they don&#8217;t know how to cope with more memory.  Until software developers actually implement error handling for lack of memory, this will be a small nuisance &#8212; hey, save often and you&#8217;ll be safe ;-).</p>

<h3>Temporarily disabling memory limits for picky applications</h3>

<p>Another disadvantage: certain applications don&#8217;t run when a limit is set.  WINE is among those applications.  However, you can use a terminal window to disable this limit temporarily (within any applications started from the terminal):</p>

<p><pre>[rudd-o@andrea /media/windows/UnrealTournament]$ <span style="color: #e22">ulimit -v unlimited</span>
[rudd-o@andrea /media/windows/UnrealTournament]$ wine System/UnrealTournament.exe</pre></p>

<h2>That&#8217;s it for this tutorial</h2>

<p>So, the infrequent dead application, SAKing your computer, or powering it off&#8230;  what do you prefer?  Me&#8230; well, once I upgraded my new &#8220;desktop&#8221; machine (1U Dell PowerEdge SC1425) to 2 GB, I haven&#8217;t looked back.</p>

<p>But my old machine did thank me a lot for keeping it off memory crunches :-).  It&#8217;s now safe in PVR heaven, <del datetime="2007-08-01T13:38:31+00:00">pirating</del>time-shifting TV shows for my pleasure.</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/08/01/controlling-runaway-processes-on-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Picture-perfect MythTV: how to improve video quality</title>
		<link>http://rudd-o.com/archives/2007/07/16/picture-perfect-mythtv-how-to-improve-video-quality/</link>
		<comments>http://rudd-o.com/archives/2007/07/16/picture-perfect-mythtv-how-to-improve-video-quality/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 06:05:12 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Free software]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Television]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/07/16/picture-perfect-mythtv-how-to-improve-video-quality/</guid>
		<description><![CDATA[Envious of how good TVTime looks compared to MythTV?  Envy no more.



Excellent picture quality is important if you use MythTV a lot.  Unfortunately, if you’re using a standard Brooktree (bt848 or bt878) video capture card, the default settings of your card work against you.  You might have noticed light colors washed out, [...]]]></description>
			<content:encoded><![CDATA[<p>Envious of how good <a href="http://tvtime.sourceforge.net/">TVTime</a> looks compared to <a href="http://www.mythtv.org/">MythTV</a>?  Envy no more.</p>

<p><span id="more-1599"></span></p>

<p>Excellent picture quality is important if you use MythTV a lot.  Unfortunately, if you&#8217;re using a standard Brooktree (bt848 or bt878) video capture card, the default settings of your card work against you.  You might have noticed light colors washed out, color ringing on sharp vertical lines, brightly lit areas of the video flashing rapidly, and a general picture darkness that doesn&#8217;t make MythTV justice when comparing it to a TV set or TVTime.</p>

<p>We&#8217;re about to fix that for ya.</p>

<h2>Step 1: install the adjust filter on each channel</h2>

<p>First, we fix recording.  Brooktree-based cards have a bug that causes it not to capture colors correctly.  Using a MythTV filter, we can beat the color space delivered by the card into the standard.</p>

<p>Use the MySQL client to execute this command on the MythTV database (usually named <code>mythconverg</code>):</p>

<p><pre>update channel set videofilters='adjust=0:255:1.0:2:253:1.0';</pre></p>

<p>That <em>adjust</em> filter will map the incorrectly captured colors to the standard TV color space.  Now recorded videos will contain the right color balance and brightness/darkness mix.</p>

<p>Note that, if you add any new channels, you will need to re-run this command.</p>

<h2>Step 2: adjust gamma correction on your monitor and enable deinterlacing</h2>

<p>Now it&#8217;s time to adjust the gamma correction and interlacing adjustments.</p>

<p>What gamma correction does is lighten or darken the picture up.  Think of gamma as a way to make the picture brighter or darker in average, without making the light parts lighter or the dark parts darker.  Brightness controls are inferior to gamma, because gamma, unlike brightness, doesn&#8217;t make light colors look &#8220;burnt&#8221;.</p>

<p>Unfortunately, the standard X Window System gamma control usually has no effect on video (Xv) windows (though NVIDIA card users can use the <code>nvidia-settings</code> gamma correction control which will work properly).  Fortunately, the same adjust filter has a gamma correction argument, and we&#8217;ll leverage it.  This time around, the adjust filter won&#8217;t change the color map.</p>

<p>Now open MythTV and go to the Playback options screen:</p>

<ul>
<li>Enable kernel deinterlacing (unfortunately, there isn&#8217;t a better deinterlacing algorithm in MythTV &#8212; TVTime still beats the competition in this department).</li>
<li>If you could not alter the gamma of Xv video windows, do this: just below that option, set this playback filter on the playback: <code>adjust=16:235:0.7:16:240:1.0</code>.  Change the <code>0.7</code> in there to suit your tastes: the lower the number, the &#8220;brighter&#8221; the picture will look.  I use that number because my monitor is fairly old &#8212; in theory the ideal number would get your monitor from the standard PC gamma of 1.5 to the TV gamma of 2.2, but I have no idea what the right number is &#8212; I just set it up so my old monitor looks good.</li>
</ul>

<p>The second step will cause loss of some color information on playback.  However, the recorded video preserves the full color range.</p>

<h2>Step 3: eliminate dot crawl (color ringing around sharp lines)</h2>

<p>A frequent problem with Brooktree-based cards is <em>dot crawl</em>: vertical and diagonal lines on the picture display rapidly alternating patterns of colors in a vertical or staircase fashion.  Besides being unnerving, it costs you picture quality, because the video encoder will spend many bits to encode these rapidly changing artifacts instead of spending them on the detailed portions in the real picture.</p>

<p>Install these commands on a file named <code>/usr/local/bin/fixbttv</code>.  These commands will enable certain types of processing in your video capture card that will eliminate dot crawl:</p>

<p><pre>#!/bin/bash</pre></p>

<p>v4lctl -c /dev/video0 setattr 'combfilter' on
v4lctl -c /dev/video0 setattr 'agc crush' off
v4lctl -c /dev/video0 setattr 'whitecrush upper' 255
v4lctl -c /dev/video0 setattr 'whitecrush lower' 0
v4lctl -c /dev/video0 setattr 'full luma range' on</p>

<p>Full luma range ensures that your capture card captures the entire color range.</p>

<p>Oh, forgot to mention it: the AGC crush control we&#8217;re turning off here basically stabilizes the picture produced by my card.  If you see a light &#8220;blinking&#8221; of the picture, this will help.</p>

<p>Don&#8217;t forget to make it executable with <code>chmod +x /usr/local/bin/fixbttv</code>.</p>

<p>Then create the file <code>/etc/modprobe.d/bttv</code>with these contents:</p>

<p><pre>install bttv modprobe --ignore-install bttv &amp;&amp; /usr/local/bin/fixbttv</pre></p>

<p>Finally add the command <code>/usr/local/bin/fixbttv</code> to the file <code>/etc/rc.local</code>.</p>

<h2>Step 4: restart your machine</h2>

<p>That&#8217;s it.  I hope the good six hours I spent figuring this out helps you pimp your MythTV in ten minutes.  Just to be sure, take a &#8220;before&#8221; and an &#8220;after&#8221; videoclip so you can compare the results.</p>

<p>Now, for a question: why on Earth does <code>xvattr -a XV_GAMMA -v 1300</code> work for only a hundredth of a second, then stops working?  I&#8217;m using an ATI Mobility Radeon if it&#8217;s relevant.</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/07/16/picture-perfect-mythtv-how-to-improve-video-quality/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Learn Python in 10 minutes</title>
		<link>http://rudd-o.com/archives/2007/07/12/learn-python-in-10-minutes/</link>
		<comments>http://rudd-o.com/archives/2007/07/12/learn-python-in-10-minutes/#comments</comments>
		<pubDate>Thu, 12 Jul 2007 23:09:40 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/07/12/learn-python-in-10-minutes/</guid>
		<description><![CDATA[Yes, you too can learn Python in ten minutes.  Well, at least the language.  The Python standard library is… what’s the term?  Ah, “batteries included”.
]]></description>
			<content:encoded><![CDATA[<p>Yes, <a href="http://www.poromenos.org/tutorials/python?">you too can learn Python in ten minutes</a>.  Well, at least the language.  <a href="http://docs.python.org/lib/lib.html">The Python standard library</a> is… what’s the term?  Ah, “batteries included”.</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/07/12/learn-python-in-10-minutes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Auto-repair flaky network connections with netrepaird</title>
		<link>http://rudd-o.com/archives/2007/06/30/auto-repair-flaky-network-connections-with-netrepaird/</link>
		<comments>http://rudd-o.com/archives/2007/06/30/auto-repair-flaky-network-connections-with-netrepaird/#comments</comments>
		<pubDate>Sat, 30 Jun 2007 12:37:54 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[The month of Linux answers]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/06/30/auto-repair-flaky-network-connections-with-netrepaird/</guid>
		<description><![CDATA[Use Linux?  Have a flaky cable modem or DSL hookup?  If you do, and you leave your computer unattended, you’ll return to find zillions of network error dialogs.  Here’s a quick solution.



The netrepaird script

First off, here’s the netrepaird script.  It’s a simple script that attempts to ping network addresses (that you [...]]]></description>
			<content:encoded><![CDATA[<p>Use Linux?  Have a flaky cable modem or DSL hookup?  If you do, and you leave your computer unattended, you&#8217;ll return to find zillions of network error dialogs.  Here&#8217;s a quick solution.</p>

<p><span id="more-1571"></span></p>

<h2>The <code>netrepaird</code> script</h2>

<p>First off, here&#8217;s the <code>netrepaird</code> script.  It&#8217;s a simple script that attempts to ping network addresses (that you can define yourself), and if all pings fail, it&#8217;ll attempt progressively agressive measures to repair your network connection.  It&#8217;s really low-tech, but it works.</p>

<p><a href="post:netrepaird">There&#8217;s an updated, more featureful script here.</a></p>

<p><pre>#!/bin/bash</pre></p>

<p><span style="color: #161"># edit these variables to suit your needs
HOSTS="rudd-o.com gplhost.com mozilla.org" # define hosts to ping here
INTERFACE="eth1" # define the name of your network interface
DRIVER="cdc_ether" # define the driver (kernel module) of your network interface</span></p>

<h1>SUDO="sudo" # define to use sudo</h1>

<p>netconnected() {</p>

<p>for host in $HOSTS; do
    NETCONNECTED=no
    $SUDO ping -c 4 $host &gt; /dev/null
    [ "$?" == "0" ] &amp;&amp; { NETCONNECTED=yes ; return ; }
done</p>

<p>}</p>

<p>ifdownifup() {</p>

<p>$SUDO /sbin/ifdown $INTERFACE
$SUDO /sbin/ifup $INTERFACE</p>

<p>}</p>

<p>reloaddriver() {</p>

<p>$SUDO /sbin/ifdown $INTERFACE
$SUDO /sbin/modprobe -r $DRIVER
$SUDO /sbin/modprobe $DRIVER
$SUDO /sbin/ifup $INTERFACE</p>

<p>}</p>

<p>netconnected
[ "$NETCONNECTED" == "yes" ] &amp;&amp; { exit ; } # network is OK</p>

<p>echo "Network problem, toggling network interface $INTERFACE"
ifdownifup ; netconnected
[ "$NETCONNECTED" == "yes" ] &amp;&amp; { echo "Network OK after interface toggle" ; exit ; }</p>

<p>echo "Network problem, reloading driver"
reloaddriver ; netconnected
[ "$NETCONNECTED" == "yes" ] &amp;&amp; { echo "Network OK after driver reload" ; exit ; }</p>

<p>echo "Network is definitely down"
logger -t netrepaird -p local0.warn "Network is down, could not repair connection"
exit 1</p>

<h2>Installing this script</h2>

<p>Put this in the file named <code>/usr/local/bin/netrepaird</code> and make it executable (<code>chmod +x /usr/local/bin/netrepaird</code>).</p>

<h3>Making it run every minute</h3>

<p>That&#8217;s right, it&#8217;d make no sense to just chuck the script on your hard disk.  For this, we&#8217;re going to make it run periodically, every minute.  Edit your administrator&#8217;s <code>crontab</code> file:</p>

<ul>
<li>Ubuntu users: <code>sudo crontab -e</code></li>
<li>Fedora users: <code>su -c 'crontab -e'</code></li>
</ul>

<p>and place this line on the <code>crontab</code> file:</p>

<p><pre>* * * * * /usr/local/bin/netrepaird</pre></p>

<p><em>Small gotcha: make sure you put a carriage return at the end of the file, otherwise <code>cron</code> doesn&#8217;t execute the command.</em></p>

<h2>That&#8217;s it</h2>

<p>That&#8217;s it.  Now, every minute, the script will run and check for an available Internet connection.  If the connection flakes out for whatever reason, it&#8217;ll attempt to take it down and up, and if that fails, it&#8217;ll attempt to remove and reload the device driver and restart the connection.</p>

<p>And if those measures fail, your <code>root</code> user will get an e-mail with the warning, and a message will be duly noted in the system log file.</p>

<h3>Packagers?</h3>

<p>If any of my readers is interested in packaging this for a distribution (which would entail separating the configuration from the script), please <a href="post:contacting-me">contact me</a> to get help.</p>

<p>Happy hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/06/30/auto-repair-flaky-network-connections-with-netrepaird/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MoLa: The poor man&#8217;s anonymizing VPN tunnel using SSH and pppd</title>
		<link>http://rudd-o.com/archives/2007/05/14/mola-the-poor-mans-anonymizing-vpn-tunnel-using-ssh-and-pppd/</link>
		<comments>http://rudd-o.com/archives/2007/05/14/mola-the-poor-mans-anonymizing-vpn-tunnel-using-ssh-and-pppd/#comments</comments>
		<pubDate>Tue, 15 May 2007 02:37:55 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[The month of Linux answers]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/05/14/mola-the-poor-mans-anonymizing-vpn-tunnel-using-ssh-and-pppd/</guid>
		<description><![CDATA[Want to create a quick ‘n dirty secure tunnel between your computer and a remote SSH server?  Now you can.



/usr/sbin/pppd pty "ssh myinternetserver.com -t -e none -o 'Batchmode yes' \
/usr/sbin/pppd" 192.168.16.1:192.168.16.254 local nodetach silent \

This is all you need to create a secure tunnel between your computer and a computer that has the SSH [...]]]></description>
			<content:encoded><![CDATA[<p>Want to create a quick ‘n dirty secure tunnel between your computer and a remote SSH server?  Now you can.</p>

<p><span id="more-1530"/></p>

<p><pre style="clear:both">/usr/sbin/pppd pty "ssh myinternetserver.com -t -e none -o 'Batchmode yes' \
/usr/sbin/pppd" 192.168.16.1:192.168.16.254 local nodetach silent \</pre></p>

<p>This is all you need to create a secure tunnel between your computer and a computer that has the SSH running (in the example, <code>myinternetserver.com</code>) on the Internet.</p>

<p>Once you run this command, both your local and your remote computers will have new PPP network interfaces:</p>

<ul>
<li>Local: interface <code>ppp0</code>, IP address <code>192.168.16.1</code></li>
<li>Remote: interface <code>ppp0</code>, IP address <code>192.168.16.254</code></li>
</ul>

<p>But a few quick and easy preparations are needed in order to run and take advantage of this kind of tunnel.</p>

<h2>The SSH server installed on the server, <code>pppd</code> on both machines</h2>

<p>This should be self-explanatory.  Use your Linux distribution’s package management tools to install them — should take less than 1 minute.</p>

<h2>The right <code>pppd</code> configuration</h2>

<p>You use the <code>/etc/ppp/options</code> file to configure it.  Most options, once set in the configuration file, cannot be overriden in the command line.</p>

<h2>On the server’s <code>/etc/ppp/options</code> file</h2>

<p><pre>lock
noauth
ipcp-accept-local
ipcp-accept-remote
noproxyarp</pre></p>

<h2>On the client’s <code>/etc/ppp/options</code> file</h2>

<p><pre>lock
noauth
noproxyarp</pre></p>

<h2>The right security configuration</h2>

<p><pre>[root@mycompanyserver.com #] /usr/sbin/groupadd -r ppp
...(add your SSH login user name to the ppp group in /etc/group)...
chown root.ppp /usr/sbin/pppd
chmod 750 /usr/sbin/pppd
chmod +s /usr/sbin/pppd</pre></p>

<p>Now only members of the <code>ppp</code> group (namely, you) can join the fun.</p>

<h2>SSH public key authentication enabled</h2>

<ul>
<li>Put <code>PubkeyAuthentication yes</code> in the server’s <code>/etc/ssh/sshd_options</code>.</li>
<li>Generate an SSH key pair in your computer.</li>
<li>Upload the public key of the generated pair to your server’s <code>~/.ssh/authorized_keys2</code> file.  Don’t forget to <code>chmod 600</code> that file, or else SSH won’t even look at it.</li>
</ul>

<h2>That’s it!</h2>

<p>Now run the following command on your computer:</p>

<p><pre>/usr/sbin/pppd pty "ssh myinternetserver.com -t -e none -o 'Batchmode yes' \
/usr/sbin/pppd" 192.168.16.1:192.168.16.254 local nodetach silent \</pre></p>

<p>What this command basically does is start <code>pppd</code> locally, tell it to connect via SSH in batch mode (using the public key, so it doesn’t ask for your password), start <code>pppd</code> on the remote server, and use the SSH connection as their conversation path.</p>

<p>Wait a few seconds.  <code>pppd</code> will utter a few things:</p>

<p><pre>Using interface ppp0
Connect: ppp0 &lt;--&gt; /dev/pts/7</pre></p>

<p>You will have to confirm that the PPP interface is up:</p>

<p><pre>[youruser@yourcomputer $] /sbin/ifconfig ppp0
ppp0      Link encap:Point-to-Point Protocol
          inet addr:192.168.16.1  P-t-P:192.168.16.254  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:5 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:75 (75.0 b)  TX bytes:69 (69.0 b)</pre></p>

<p>Now you can ping <code>192.168.16.254</code>.  If pinging fails, check the firewall rules on both the server and your computer.</p>

<p>To interrupt the tunnel, hit <em>Ctrl+C</em> on the terminal that holds the running <code>pppd</code> command.</p>

<h2>What next?</h2>

<p>Bringing the tunnel up is actually one part of the deal.  If you’re like me, perhaps you’ll want to actually carry all of your network traffic across the tunnel.</p>

<h3>Set up the remote server to route traffic for you</h3>

<p>This is easy.  On the server, either:</p>

<ul>
<li>set firewall rules that will do NAT between the PPP interface and the Internet; or</li>
<li>replace <code>noproxyarp</code> with <code>proxyarp</code> in the (server’s) <code>/etc/ppp/options</code> file; then set aside an extra IP address in the (server’s) local network; then use it as the remote endpoint in the <code>pppd</code> command.  If your server has IP address <code>2.3.4.5</code>, then provision <code>2.3.4.6</code> and use it instead of <code>192.168.16.254</code>.</li>
</ul>

<h3>Set the default route to be the tunnel’s remote endpoint</h3>

<p>If you want to route all of your network traffic through your newly created PPP link, you need to do two steps in this order:</p>

<ol>
<li>Manually add a route to your server, so the SSH traffic knows the physical route it should follow.  If the IP address of your current default route is <code>4.5.6.7</code>, then run <code>route add mycompanyserver.com gw 4.5.6.7</code></li>
<li>Replace the default route.  Run <code>route add default gw 192.168.16.254 dev ppp0</code></li>
</ol>

<p>Before you suggest the <code>pppd</code>’s <code>defaultroute</code> option: no, it won’t work, because it’ll disrupt the only communication route between your computer and the remote SSH server.</p>

<p>Perhaps you’d like to add manual, shorter routes to your DNS servers — otherwise Web browsing may get a little slow.  You know, due to the latency of the tunnel and stuff…</p>

<p>After doing this:</p>

<ul>
<li>your computer will send all (SSH) traffic to <code>mycompanyserver.com</code> through your regular default route, so the tunnel keeps working fine;</li>
<li>the rest of the traffic will go through the PPP interface (notice we named the remote IP address in the default <code>route</code> command?)</li>
</ul>

<p>Combine this with the <!--more-->proxyarp option on the server, and you have a recipe to make your computer appear as a completely different computer on the Internet.  Perfect for anonymizing your real computer!</p>

<h2>More Linux questions?</h2>

<p><em>Have a Linux question?  Why don’t you drop by <a href="http://rudd-o.com/archives/2007/04/25/introducing-the-month-of-linux-answers/#respond" title="Private: Introducing: The Month of Linux Answers">our Month of Linux Answers</a> and leave your question as a comment?  I’ll get to it right away :-).</em></p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/05/14/mola-the-poor-mans-anonymizing-vpn-tunnel-using-ssh-and-pppd/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tutorial on handling heavy traffic with WordPress</title>
		<link>http://rudd-o.com/archives/2007/04/28/tutorial-on-handling-heavy-traffic-with-wordpress/</link>
		<comments>http://rudd-o.com/archives/2007/04/28/tutorial-on-handling-heavy-traffic-with-wordpress/#comments</comments>
		<pubDate>Sat, 28 Apr 2007 23:30:39 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Turbocharged]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/04/28/tutorial-on-handling-heavy-traffic-with-wordpress/</guid>
		<description><![CDATA[I wrote a tutorial to help you handle heavy traffic with WordPress.
]]></description>
			<content:encoded><![CDATA[<p>I wrote a tutorial to help you <a href="http://turbochargedcms.com/2007/04/weathering-heavy-traffic-with-wordpress-and-turbocharged/#more-72">handle heavy traffic with WordPress</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/04/28/tutorial-on-handling-heavy-traffic-with-wordpress/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Wrote a tutorial on validation and WordPress</title>
		<link>http://rudd-o.com/archives/2007/04/15/wrote-a-tutorial-on-validation-and-wordpress/</link>
		<comments>http://rudd-o.com/archives/2007/04/15/wrote-a-tutorial-on-validation-and-wordpress/#comments</comments>
		<pubDate>Mon, 16 Apr 2007 04:54:43 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Blogging]]></category>

		<category><![CDATA[Turbocharged]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[WordPress XHTML validator]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2007/04/15/wrote-a-tutorial-on-validation-and-wordpress/</guid>
		<description><![CDATA[WordPress user?  Then check this tutorial out!
]]></description>
			<content:encoded><![CDATA[<p>WordPress user?  <a href="http://turbochargedcms.com/2007/04/guaranteeing-validity-with-the-xhtml-validator-plugin/">Then check this tutorial out</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2007/04/15/wrote-a-tutorial-on-validation-and-wordpress/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Automating Web site and WordPress upgrades with Subversion, mirrorlinks and bash</title>
		<link>http://rudd-o.com/archives/2006/11/11/automating-wordpress-upgrades-with-the-linux-toolset/</link>
		<comments>http://rudd-o.com/archives/2006/11/11/automating-wordpress-upgrades-with-the-linux-toolset/#comments</comments>
		<pubDate>Sat, 11 Nov 2006 07:38:28 +0000</pubDate>
		<dc:creator>Rudd-O</dc:creator>
		
		<category><![CDATA[Free software]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[My journey towards Web consolidation]]></category>

		<category><![CDATA[Software bacán]]></category>

		<category><![CDATA[Turbocharged]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[Yo]]></category>

		<guid isPermaLink="false">http://rudd-o.com/archives/2006/11/11/automating-wordpress-upgrades-with-the-linux-toolset/</guid>
		<description><![CDATA[Hello, and welcome back to another installment of my journey through Web consolidation!  Today, I’ll show you how I automated my Web sites’ WordPress upgrades using assorted and powerful Linux software.  You’ll also enjoy an exclusive look at the release process of one of my software products.



Why automation?

If you’re running a single Web [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, and welcome back to another installment of my journey through Web consolidation!  Today, I’ll show you how I automated my Web sites’ WordPress upgrades using assorted and powerful Linux software.  You’ll also enjoy an exclusive look at the release process of one of my software products.</p>

<p><span id="more-1222"/></p>

<h2>Why automation?</h2>

<p>If you’re running a single Web site or blog, it makes little sense to automate tasks, since 99% of your maintenance tasks will be <em>ad-hoc</em>.  But that’s not my case.</p>

<p>I run three Web sites, two of them WordPress-based.  In my scenario, WordPress upgrades and enhancements come in pairs.  My sites demand an assortment of more than 100 plugins and themes, so those need to be upgraded as well.</p>

<p>I also sell a customized WordPress package, called <a href="http://turbochargedcms.com/">Turbocharged</a>.  Remember the 100 plugins and themes?  Well, every so often I do a new release of Turbocharged, which is almost exactly what powers my Web sites.</p>

<p>As you may have guessed, releasing such a huge package is is a time-consuming process!  Combined with upgrading my own sites to the latest edition of Turbocharged, it often takes the better part of a day.  And doing it manually is not an option, <a href="http://rudd-o.com/archives/2006/10/23/mind-mapping-your-projects-and-ideas-frees-your-brain-eliminates-the-stress-and-lets-you-think-clearly/" title="Mind mapping your projects and ideas: frees your brain, eliminates the stress, and lets you think clearly">especially since my Web assets are expected to grow in the future</a>.</p>

<p>Ideally, I’d like upgrades and enhancements to:</p>

<ul>
<li>be a 10-second process I can run on my Web server: saving a day, even if it’s just to squander it in drinks and clubbing with my buddies, is worthwhile.  Less time spent in operations, more time for creativity and long-term progress.</li>
<li>take advantage of my already-existing Subversion repositories: that way, I can make quick fixes on my Web server, and have the changes transparently imported into my development computer, and the other way around.  <a href="http://turbochargedcms.com/">Turbocharged</a> customers also benefit from this, because I run a bleeding edge Turbocharged copy on each of my sites.</li>
<li>be error-proof: if something fails, I want to know why it failed.  If a file changes, I’d like to know when, in what way and why.  I simply can’t take any downtime.</li>
</ul>

<p>Can this be done?  The answer is yes.  I know it because I just invested six hours to make it happen.</p>

<p>And you can do it too.  Be forewarned: this guide requires learning about new software.</p>
]]></content:encoded>
			<wfw:commentRss>http://rudd-o.com/archives/2006/11/11/automating-wordpress-upgrades-with-the-linux-toolset/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
