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

<channel>
	<title>n8blog &#187; Unix</title>
	<atom:link href="http://www.n8gray.org/blog/category/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.n8gray.org</link>
	<description>distraction in action</description>
	<lastBuildDate>Thu, 01 Jul 2010 18:21:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dictionary attacks, or why log file monitoring is dumb</title>
		<link>http://www.n8gray.org/blog/2008/01/28/dictionary-attacks-or-why-log-file-monitoring-is-dumb/</link>
		<comments>http://www.n8gray.org/blog/2008/01/28/dictionary-attacks-or-why-log-file-monitoring-is-dumb/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 00:59:59 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/blog/2008/01/28/dictionary-attacks-or-why-log-file-monitoring-is-dumb/</guid>
		<description><![CDATA[Like most ssh servers on the internet, the Mojave group server gets lots of ssh dictionary attack attempts.  These attacks are carried out by scripts that try to find dumb passwords on a machine by brute force.  There are a few different tactics these scripts use for picking username/password pairs, including:



User: root, Password: [...]]]></description>
			<content:encoded><![CDATA[<p>Like most ssh servers on the internet, the Mojave group server gets lots of ssh dictionary attack attempts.  These attacks are carried out by scripts that try to find dumb passwords on a machine by brute force.  There are a few different tactics these scripts use for picking username/password pairs, including:</p>


<ul>
<li>User: root, Password: aardvark.  (Repeat with various well-known usernames and every word in the English dictionary)</li>
<li>User: abe, Password: abe.  (Repeat with all common first/last names)</li>
</ul>



<p>It&#8217;s not hard to think of simple methods to cut off these attacks without altering or otherwise restricting one&#8217;s ssh service (by, say, running sshd on a non-standard port):  </p>


<ul>
<li>Throttle login attempts on a per-host basis.  i.e. if a host tries and fails to log in N times in M seconds then start making it wait longer and longer between successive logins (or even blacklist the host entirely).</li>
<li>Throttle login attempts on a per-account basis.  i.e. if user bob gets N failed login attempts within M seconds then throttle or blacklist future login attempts on that account.</li>
<li>Auto-blacklist hosts that attempt to log in to accounts that should never be logged in to.  e.g. if somebody tries to ssh in as user &#8220;games&#8221; they&#8217;re toast.</li>
</ul>



<p>Indeed, there are any number of programs out there that aim to provide exactly these capabilities.<sup class="footnote"><a href="#fn1">1</a></sup>  What these techniques have in common is the need to measure the number of failed login attempts associated with a host and/or account over a period of time.  So how do the existing programs do it?  Sadly, a large number do it by scanning log files.  In other words, a scanner will look for a certain pattern (typically using regular expressions) in the logging output for your system and assume that it indicates a failed login attempt.  This is not a great idea.</p>

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

<p>What&#8217;s wrong with log file scanning, anyway?  The first (and least important, <span class="caps">IMHO</span>) mark against it is performance.  A typical system has dozens or hundreds of processes running at any time, each generating log output to some degree.  Well-written programs generate a trickle, but it&#8217;s not unusual for a program to accidentally ship (or be misconfigured) with debug-level logging enabled and thus generate a torrent of debug output.  By running a log file scanner you&#8217;ve now got a program that has to sift through <strong>every byte</strong> of that output looking for just one type of event!  This is certainly not the most efficient way to find out about login attempts.</p>

<p>Another bad aspect of log file scanning is that it relies on the specific formatting of log messages from specific programs.  If you replace OpenSSH with BogoSSH and BogoSSH uses a slightly different log output format then your scanner breaks.  Similarly, if the OpenSSH people ever decide to change their logging format (not that this is likely) then your scanner breaks.  If you install some new service that the scanner doesn&#8217;t know about it&#8217;s probably going to be totally unprotected unless it happens to format its log messages just like some other service the scanner understands.</p>

<p>But the worst thing about log file scanning is that sloppy implementations can actually open your system up to denial of service attacks!  I recently came across <a href="http://www.ossec.net/en/attacking-loganalysis.html">this article by Daniel B. Cid</a> that describes vulnerabilities in several popular log scanners that allow remote attackers to cause your machine to falsely blacklist any other machine of their choosing.  Even worse, one scanner allowed attackers to cut a machine off from the network entirely!  I refer you to the article for details, but the root causes of this problem are easy to describe:</p>


<ul>
<li>Regular expression matching is error-prone.  People aren&#8217;t terribly good at understanding the full class of strings that a given <span class="caps">R.E. </span>will match.  I&#8217;ve been doing complicated <span class="caps">R.E. </span>stuff for years now and I still have a terribly hard time writing bug-free regular expressions.</li>
<li>Log files are chock full of strings that come from insecure sources, like, say, random users on your machine and script kiddies all across the internet who want to crack your machine.  You do <strong>not</strong> want to be taking action automatically based on the contents of such an untrusted data source.  The article doesn&#8217;t even begin to mention what an attacker with local access could do by writing and executing a program that mimics sshd&#8217;s log output.  </li>
</ul>



<p>So how <strong>should</strong> this problem be solved?  By going straight to the horse&#8217;s mouth.  If you want to know about authentication attempts, talk to the authentication system.  Every modern *NIX system supports <span class="caps">PAM, </span><a href="http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/Linux-PAM_SAG.html">the Pluggable Authentication Module system</a>.  With a <span class="caps">PAM </span>module you can perform an action on any failed login attempt from <em>any</em> <span class="caps">PAM</span>-enabled service.  This allows you to create a concise, trustworthy authentication log file with a consistent format, which can then be monitored by a very simple (and thus secure) scanner.</p>

<p>One project that takes the <span class="caps">PAM </span>approach is <a href="http://sourceforge.net/projects/pam-abl">pam_abl</a> (auto-blacklist).  While it doesn&#8217;t use the specific strategy I described above (it builds a database rather than producing an authentication log file) it does get its info from the right source and is thus immune to these bogus log message attacks.  Unfortunately pam_abl is a bit inflexible and limited in its capabilities.  It doesn&#8217;t provide any way to blacklist a host if it tries to log in to a bogus account like &#8216;games&#8217;.  It doesn&#8217;t provide a way to throttle rather than blacklist.  And although it effectively ensures that an attacker will never have a chance to guess your account passwords it doesn&#8217;t provide a way of firewalling off a malicious host entirely.  Even worse, the maintainer of pam_abl doesn&#8217;t seem to have time to work on it any longer.  Hopefully somebody else will step up and turn this into <strong>the</strong> tool for stopping dictionary attacks dead in their tracks.</p>

<p class="footnote" id="fn1"><sup>1</sup> Here are a handful:</p>

<ul> <li> <a href="http://denyhosts.sourceforge.net/" title="sourceforge.net">denyhosts</a sourceforge.net></li> <li> <a href="http://www.fail2ban.org/wiki/index.php/Main_Page" title="fail2ban.org">fail2ban</a fail2ban.org></li> <li> <a href="http://www.aczoom.com/cms/blockhosts/" title="aczoom.com">blockhosts</a aczoom.com></li> <li> <a href="http://blocksshd.sourceforge.net/" title="sourceforge.net">blocsshd</a sourceforge.net></li> <li> <a href="http://www.zipcon.net/~sirius/crackblock.html" title="zipcon.net">crackblock</a zipcon.net></li> <li> <a href="http://shellter.sourceforge.net/" title="sourceforge.net">shellter</a sourceforge.net></li> <li> <a href="http://www.csc.liv.ac.uk/~greg/sshdfilter/" title="liv.ac.uk">sshdfilter</a liv.ac.uk></li> <li> <a href="http://anp.ath.cx/sshit/" title="anp.ath.cx">sshit</a anp.ath.cx></li>
<li> <a href="http://www.techfinesse.com/sshutout/sshutout.html" title="techfinesse.com">sshutout</a techfinesse.com></li> </ul>

<p><strong>Updated</strong>:  Removed ssh-faker from the footnote since it effectively alters the sshd service.</p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2008%2F01%2F28%2Fdictionary-attacks-or-why-log-file-monitoring-is-dumb%2F&amp;linkname=Dictionary%20attacks%2C%20or%20why%20log%20file%20monitoring%20is%20dumb"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2008/01/28/dictionary-attacks-or-why-log-file-monitoring-is-dumb/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ubuntu: Mysterious Updates</title>
		<link>http://www.n8gray.org/blog/2006/09/15/ubuntu-mysterious-updates/</link>
		<comments>http://www.n8gray.org/blog/2006/09/15/ubuntu-mysterious-updates/#comments</comments>
		<pubDate>Fri, 15 Sep 2006 18:11:41 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/blog/2006/09/15/ubuntu-mysterious-updates/</guid>
		<description><![CDATA[What&#8217;s up with Ubuntu pushing out updates without any indication of why the software is being updated?  A month or so ago I would see about 25 updates a day without a single comment on what was being changed.  This is just absurd though:



So I&#8217;m supposed to upgrade my kernel without knowing anything [...]]]></description>
			<content:encoded><![CDATA[<p>What&#8217;s up with Ubuntu pushing out updates without any indication of <em>why</em> the software is being updated?  A month or so ago I would see about <em>25 updates a day</em> without a single comment on what was being changed.  This is just absurd though:</p>

<p class="center" style="text-align:center"><img id="image127" src="http://www.n8gray.org/wp-content/uploads/2006/09/screenshot.png" alt="Upgrade your kernel, trust me!"/></p>

<p>So I&#8217;m supposed to upgrade my <strong>kernel</strong> without knowing anything about what&#8217;s changed??  Brilliant!</p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2006%2F09%2F15%2Fubuntu-mysterious-updates%2F&amp;linkname=Ubuntu%3A%20Mysterious%20Updates"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2006/09/15/ubuntu-mysterious-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stupid RAID tricks with EVMS and mdadm</title>
		<link>http://www.n8gray.org/blog/2006/09/05/stupid-raid-tricks-with-evms-and-mdadm/</link>
		<comments>http://www.n8gray.org/blog/2006/09/05/stupid-raid-tricks-with-evms-and-mdadm/#comments</comments>
		<pubDate>Tue, 05 Sep 2006 21:57:33 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/blog/2006/09/05/stupid-raid-tricks-with-evms-and-mdadm/</guid>
		<description><![CDATA[(Note: I&#8217;ve gone back and forth about posting this article.  I really am not an expert in this area and I don&#8217;t want to advise people to do something stupid.  OTOH, this is something that I&#8217;ve never seen described before.  I&#8217;ve decided to post it, but it&#8217;s probably best treated as a [...]]]></description>
			<content:encoded><![CDATA[<p>(Note: I&#8217;ve gone back and forth about posting this article.  I really am not an expert in this area and I don&#8217;t want to advise people to do something stupid.  <span class="caps">OTOH, </span>this is something that I&#8217;ve never seen described before.  I&#8217;ve decided to post it, but it&#8217;s probably best treated as a curiosity, not a data storage strategy.) </p>

<p>Let&#8217;s do a little Linux magic.  We&#8217;re going to create a <span class="caps">RAID</span> 1 (mirrored) pair, transform it to a 2-disk <span class="caps">RAID</span> 5 array (you know, the kind that &#8220;requires&#8221; 3 or more disks), then grow it to a 3-disk <span class="caps">RAID</span> 5 array.</p>

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

<p>Just so nobody gets <em>too</em> confused, I&#8217;m using a fairly fresh install of Ubuntu 6.06 Dapper Drake, which includes <span class="caps">EVMS</span> 2.5.4.  </p>

<p>First let&#8217;s make some 10MB &#8220;disks&#8221; to play with.</p>



<pre>
$ mkdir disks
$ cd disks
$ dd if=/dev/zero of=img0 bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.734714 seconds, 14.3 MB/s
$ # These produce similar output:
$ dd if=/dev/zero of=img1 bs=1M count=10    
$ dd if=/dev/zero of=img2 bs=1M count=10
</pre>



<p>And let&#8217;s mount them as loopback devices:</p>



<pre>
$ sudo su  # From here on out we'll need root privileges
# losetup /dev/loop0 img0
# losetup /dev/loop1 img1
# losetup /dev/loop2 img2
</pre>



<p>Now we&#8217;re ready to work in evms.  Launch the NCurses interface to evms with the command <code>evmsn</code>.  Our first step is to delete the &#8220;compatibility volumes&#8221; that evms automatically creates for us.  Select <code>Actions &gt; Delete &gt; Volume</code> (by typing <code>a d v</code>) and select all of the <code>/dev/evms/loopX</code> volumes listed (using the space bar and arrow keys).  <strong>Don&#8217;t select anything else that might be listed!</strong>  Hit <code>enter</code> to go ahead with the deletion.  The dialogs that you&#8217;ll see next are not important for our purposes &#8212; just chose the defaults until you get back to the evms interface and see the message &#8220;The Delete command(s) completed successfully.&#8221; at the bottom of the screen.</p>

<p>Next, we will build our first <span class="caps">RAID, </span>a level 1 mirrored pair.  Select <code>Actions &gt; Create &gt; Region</code>, select the <code>MD Raid 1 Region Manager</code>, and hit <code>enter</code>.  Now select <code>loop0</code> and <code>loop1</code> and hit <code>enter</code>.  Leave the configuration options alone, hitting <code>enter</code> once more to create the Raid region.  You&#8217;ll get a congratulatory message that informs you that the storage object <code>md/md0</code> has been produced.</p>

<p>Now if this were a real storage array we were building we would probably put an <span class="caps">LVM2 </span>container on top of <code>md0</code> and create some logical volumes, but in this tutorial we&#8217;re just going to create a volume from <code>md0</code> directly.</p>

<p>Select <code>Actions &gt; Create &gt; EVMS Volume</code>, select <code>md/md0</code> and give the volume the name RaidVol.  Hit <code>enter</code> to go through with the creation.  Now we should see <code>/dev/evms/RaidVol</code> in the list of logical volumes.</p>

<p>Let&#8217;s put a filesystem on it, so we can save some test data to the volume.  Select <code>Actions &gt; File System &gt; Make</code>, select <code>Ext2/3 File System Interface Module</code>, and hit <code>enter</code>.  Now choose <code>RaidVol</code> and hit <code>enter</code> twice to finish up with the default configuration options.  </p>

<p>At this point your logical volumes list (hit zero to show it if it&#8217;s not there already) should look something like this:</p>



<pre>
 Name                          Size Modified Active R/O  Plug-in   Mountpoint
 -----------------------------------------------------------------------------------------
 /dev/evms/RaidVol           9.9 MB    X                 Ext2/3
</pre>



<p><span class="caps">EVMS </span>is a cautious system and doesn&#8217;t actually <em>change</em> anything until you save your changes.  At this point we need to save our progress, so select <code>Actions &gt; Save</code>.  Once you&#8217;ve saved your changes you can mount your shiny new volume!  Select <code>Actions &gt; File Systems &gt; Mount</code> and mount <code>RaidVol</code> at <code>/mnt/raidvol</code>.  We&#8217;re done with <code>evmsn</code> for the moment, so select <code>Actions &gt; Quit</code>.</p>

<p>It&#8217;s easy for me to tell you this works, but if you want to have confidence in this procedure you&#8217;ll want to verify it for yourself.  Copy some files to <code>/mnt/raidvol</code> &#8212; images, text files, whatever.  Try to fill up the drive as completely as possible.  (Hint: One way to fill it up is <code>dd if=/dev/zero of=/mnt/raidvol/zeros</code>)  Once you&#8217;ve filled the disk, run <code>md5sum</code> on your files:</p>



<pre>
# ls -l /mnt/raidvol/zeros
-rw-r--r-- 1 root root 8971264 2006-06-30 00:03 /mnt/raidvol/zeros
# md5sum /mnt/raidvol/zeros
37e6cfefc792d550d54f0422c8521fea  /mnt/raidvol/zeros
</pre>



<p>You might also want to <code>cat /proc/mdstat</code> to see that the Raid is doing its thing:</p>



<pre>
$ cat /proc/mdstat
Personalities : [raid1] [raid5]
md0 : active raid1 loop1[1] loop0[0]
      10176 blocks [2/2] [UU]

unused devices: &lt;none&gt;
</pre>



<p>Now we&#8217;re ready to start making magic.  (Hint: You might want to back up <code>img0</code> and <code>img1</code> now so you can skip many of the previous steps if you want to experiment in the future.)  Launch <code>evmsn</code> once more.  Unmount the volume with <code>Actions &gt; File System &gt; Unmount</code>.  </p>

<p>We&#8217;re going to be doing some things behind the back of <code>evms</code>, so let&#8217;s convert the volume to a &#8220;compatibility volume&#8221;  with <code>Actions &gt; Convert &gt; EVMS Volume to Compatibility Volume</code>.  Save your changes and quit.</p>

<p>The next bit is somewhat voodoo.  It&#8217;s based on the semi-obscure fact that the <span class="caps">RAID</span> 5 algorithm can indeed be applied to two disks, and when you do so the disks end up mirrored!  This works because the parity of a single block is equal to the block itself, though the normal way of setting up <span class="caps">RAID</span> 5 arrays involves computing the parity of at least two blocks.  As a consequence, <strong>the only difference between a 2-disk <span class="caps">RAID</span> 1 pair and 2-disk <span class="caps">RAID</span> 5 array is the metadata!</strong>  By rewriting the <span class="caps">RAID </span>metadata, we can instantly convert our array to <span class="caps">RAID</span> 5.</p>

<p>We&#8217;re going to use <code>mdadm</code> to rewrite the <span class="caps">RAID </span>metadata.  First we&#8217;ll need to stop the array:</p>



<pre>
# mdadm --stop /dev/evms/md/md0
</pre>



<p>Now we&#8217;re going to &#8220;create&#8221; a <span class="caps">RAID</span> 5 array using our existing loopback devices.  In effect, this should just change the metadata and give us a functional array.  <code>mdadm</code> is going to get suspicious, but it&#8217;ll let us proceed:</p>



<pre>
# mdadm --create /dev/md0 --level=5 -n 2 /dev/loop0 /dev/loop1
mdadm: /dev/loop0 appears to contain an ext2fs file system
    size=10172K  mtime=Fri Jun 30 00:28:04 2006
mdadm: /dev/loop0 appears to be part of a raid array:
    level=1 devices=2 ctime=Thu Jun 29 23:20:15 2006
mdadm: /dev/loop1 appears to contain an ext2fs file system
    size=10172K  mtime=Fri Jun 30 00:28:04 2006
mdadm: /dev/loop1 appears to be part of a raid array:
    level=1 devices=2 ctime=Thu Jun 29 23:20:15 2006
Continue creating array? y
mdadm: array /dev/md0 started.
</pre>



<p>Now the moment of truth!  Let&#8217;s try mounting <code>/dev/md0</code>:</p>



<pre>
# mount /dev/md0 /mnt/raidvol
# ls /mnt/raidvol
lost+found  zeros
</pre>



<p><strong>Hooray!</strong>  Let&#8217;s make sure nothing got corrupted:</p>



<pre>
# ls -l /mnt/raidvol/zeros
-rw-r--r-- 1 root root 8971264 2006-06-30 00:03 /mnt/raidvol/zeros
# md5sum /mnt/raidvol/zeros
37e6cfefc792d550d54f0422c8521fea  /mnt/raidvol/zeros
</pre>



<p>And let&#8217;s convince ourselves that we really have a <span class="caps">RAID</span> 5 array:</p>



<pre>
# cat /proc/mdstat
Personalities : [raid1] [raid5]
md0 : active raid5 loop0[0] loop1[1]
      10176 blocks level 5, 64k chunk, algorithm 2 [2/2] [UU]

unused devices: &lt;none&gt;
</pre>





<h2>Part II: Growing the Array</h2>

<p>Hot-damn, it worked!  Now let&#8217;s add another disk to the <span class="caps">RAID</span> 5 array.  First we unmount the volume, then go back to evms:</p>



<pre>
# umount /mnt/raidvol/
# evmsn
</pre>



<p>Growing a <span class="caps">RAID</span> 5 array is actually quite easy in evms, but the documentation gives one little-to-no help understanding how it&#8217;s done.  Trial-and-error led me to the following procedure:</p>



<pre>
Actions &gt; Convert &gt; Compatibility Volume to EVMS Volume
    use the name RaidVol and select /dev/evms/md/md0
Actions &gt; Expand &gt; Volume
    choose RaidVol
    choose md/md0 as the &quot;expand point&quot;
    choose loop2 as the object
Actions &gt; Save
</pre>



<p>You should get a list of messages that the procedure has produced, and, with luck, none of them should be error messages!  Choose <code>cancel</code> to dismiss the dialog, and notice that RaidVol is now 20MB!  Mount the volume (<code>Actions &gt; File System &gt; Mount</code>), quit evmsn and let&#8217;s make sure everything is ok:</p>



<pre>
# ls /mnt/raidvol/
lost+found  zeros
# df -h /mnt/raidvol/
Filesystem            Size  Used Avail Use% Mounted on
/dev/evms/RaidVol      20M  9.7M  9.0M  52% /mnt/raidvol
# ls -l /mnt/raidvol/zeros
-rw-r--r-- 1 root root 8971264 2006-06-30 00:03 /mnt/raidvol/zeros
# md5sum /mnt/raidvol/zeros
37e6cfefc792d550d54f0422c8521fea  /mnt/raidvol/zeros
</pre>



<p>Nifty, eh?  Now before you run down to your data center and try this procedure on your client&#8217;s drives, you should be aware that I&#8217;m pretty clueless about all this stuff and there may very well be extremely good reasons not to do this.  If you do attempt it, make sure you have recent backups, and don&#8217;t say I didn&#8217;t warn you!</p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2006%2F09%2F05%2Fstupid-raid-tricks-with-evms-and-mdadm%2F&amp;linkname=Stupid%20RAID%20tricks%20with%20EVMS%20and%20mdadm"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2006/09/05/stupid-raid-tricks-with-evms-and-mdadm/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>The straight poop on BackSpace vs. Delete in Unix</title>
		<link>http://www.n8gray.org/blog/2004/04/28/the-straight-poop-on-backspace-vs-delete-in-unix/</link>
		<comments>http://www.n8gray.org/blog/2004/04/28/the-straight-poop-on-backspace-vs-delete-in-unix/#comments</comments>
		<pubDate>Wed, 28 Apr 2004 15:00:00 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://sandbox.n8gray.org/blog/2004/04/28/the-straight-poop-on-backspace-vs-delete-in-unix/</guid>
		<description><![CDATA[It&apos;s nice to see this
article, which nicely explains how to clear up the mess that you sometimes
see with backspace and delete keys on Unix sytems.  It&apos;s not perfect, however,
in that it doesn&apos;t really tell you how to figure out what keycodes the BS and
Delete keys send on your machine.  The answer is to [...]]]></description>
			<content:encoded><![CDATA[<p>It&apos;s nice to see <a href="http://www.squish.net/docs/delbs.html">this
article</a>, which nicely explains how to clear up the mess that you sometimes<br />
see with backspace and delete keys on Unix sytems.  It&apos;s not perfect, however,<br />
in that it doesn&apos;t really tell you how to figure out what keycodes the BS and<br />
Delete keys send on <i>your</i> machine.  The answer is to run the<br />
<code>xev</code> utility that is normally installed on any <span class="caps">X11 </span>system.  It pops<br />
up a window and starts spewing loads of output to the terminal you ran it from. <br />
The output is a log of every X event that the window receives.  To figure out<br />
what keycode Backspace (or any other key) sends in X, move your mouse to that<br />
window and hit the key you&apos;re interested in.</p>
<p>
When I do that with the Backspace key I get:</p>


<pre>
KeyPress event, serial 24, synthetic NO, window 0x1000001,
    root 0x57, subw 0x0, time 41167852, (177,28), root:(1136,123),
    state 0x0, keycode 59 (keysym 0xff08, BackSpace), same_screen YES,
    XLookupString gives 1 bytes:  &quot;

KeyRelease event, serial 24, synthetic NO, window 0x1000001,
    root 0x57, subw 0x0, time 41167935, (177,28), root:(1136,123),
    state 0x0, keycode 59 (keysym 0xff08, BackSpace), same_screen YES,
    XLookupString gives 1 bytes:  &quot;
</pre>


<p>By reading this output we see that the first event is the key press and the
second is the release.  Both send the keycode 59 (not keycode 22 as on James&apos;<br />
system), which is correctly mapped to the keysym BackSpace.</p>
<p>
Thankfully, this BS vs. Delete issue is one that rarely comes up these days. <br />
All of the Unix systems I&apos;ve used in the last 5 years or so have been configured<br />
correctly on delivery.</p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2004%2F04%2F28%2Fthe-straight-poop-on-backspace-vs-delete-in-unix%2F&amp;linkname=The%20straight%20poop%20on%20BackSpace%20vs.%20Delete%20in%20Unix"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2004/04/28/the-straight-poop-on-backspace-vs-delete-in-unix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

