Gutsy Applications Menu

Posting this in the hopes that it’ll be useful to someone else, because it certainly took me a long time and caused a lot of frustration.

There’s a bizarre bug that a few people, myself including, have run into when upgrading to Ubuntu’s Gutsy Gibbon release: the applications menu is blank.

Some recommended deleting ~/.config/menus/applications.menu, but, in my case, this didn’t recreate it.

Here’s a tip, though: there’s an /etc/xdg/menus/applications.menu. Copying it to ~/.config/menus/ fixed my problem. And now, I have an applications menu. Hurrah!

Today’s Deals

Going through the circulars, here are some more incredible deals:

  • Office Depot has a 17″ widescreen LCD (1440×900), $139.99 after rebate. Brand-name is Hanns.
  • If you don’t mind an eMachine, Office Depot also has a desktop with a dual-core AMD “4000+,” 1 GB RAM, 320GB disk, Vista Home Premium, dual-layer DVD/CD drive, and a 17″ CRT + an all-in-one printer. $399.97 after rebates, but you’ll pay $725 in store.
  • Movin’ on up, dual-core notebook (TK-55 processor… What’s with new processor names that no one understands?), 1 GB RAM, 120 GB disk, dual-layer DVD/CD burner, Vista Home Premium, 15.4″ widescreen display (with Brightview), and integrated 802.11b/g WiFi. Just $449.99 after rebates, or $629.99 before rebate at Office Depot.
  •  Still in the Office Depot circular, an HP desktop with a dual-core AMD 4800+, 3 GB RAM, 320 GB disk, dual-layer CD/DVD burner, Vista Home Premium, and 22″ widescreen monitor (with Brightview). Seems like a steal at $749.99 after rebate ($919.99 before).
  • Or move up to quad-core with a Gateway system with Intel’s Q6600 processor, 2 GB RAM, 400 GB disk, dual-layer DVD/CD, and Vista Home Premium. Oh, and a 19″ LCD. $879.98 after rebate, $1029.98 in store.
  • Or move up to 58-core system for just $2,249.99 on eBay. (Discounted $250 since I last mentioned it.) 58 processors and 55 GB RAM. It’s at the bottom of the pack of the systems I’ve mentioned for storage, though. I’m not sure on shipping, but it’s worth considering on this refrigerator-sized computer.
  • Back to Office Depot, you can pick up an Acer 19″ widescreen LCD (1440×900) for just $189.99 after rebate. It’s also got a 2000:1 contrast ratio, which seems pretty enormous. Slap this on your 58-core system and you’ll have one hell of a desktop. (I’m not sure that the E10000 even has a VGA port?

The GIMP

I went out to get some more shots today. I decided to try shooting in raw mode instead of JPEG. The images were 7 MB instead of 2 MB, but I have a lot more control afterwards. It’s much slower when you shoot in burst mode, though, so I switched back to JPEG.

Afterwards, though, I wondered if I could open it. It turns out that Ubuntu handles it natively. (I can’t say the same for Windows.) So I uploaded the files to Flickr, but it turns out that Flickr doesn’t display .crw files. So I had to export it with the GIMP.

In addition to letting you export to JPEG, it lets you export to ASCII. And an HTML table. So, for grins, I exported one of my six-megapixel pictures to an HTML table. It popped up a warning that it would almost certainly crash my browser. I did it anyway. Several minutes later, it finished writing to disk. It was a little shy of 300MB. It didn’t really crash Firefox per se, but I didn’t see anything but gray table cells. I’m not sure what went wrong, really, but I can forgive it for not accurately displaying a 300MB table.

title=”Photo Sharing”>Bentley Falcon

That’s a JPEG. Although that was a native JPEG, not one saved from a CRW.

Bans for Fun & Profit

The way I use this server gives me a luxury that bigger sites don’t: my visitors come from a select range, and I don’t have to worry much about blocking people erroneously. Therefore I can be quite aggressive in blocking IPs. /etc/hosts.deny is my new favorite file.

When I moderate comments here, I have a few choices… I can approve it, delete it, or mark it as spam. I never got what marking it as spam did… Apparently it doesn’t do much but set a ‘spam’ bit. (I’d hoped it trained Bayesian filters or something, but no such luck.) But what it does do is make it super-simple to construct an SQL query to pull out all the IPs that have posted spam. Add a little more and you get just the IPs this month that had posts flagged as spam. And you drop them in /etc/hosts.deny.

But then I was watching the system log file, and noticed lots of spam coming in. I’m not running much of a mailserver, so most addresses are bouncing. (Especially since they’re spamming addresses that have never existed?)

This is good news, though, for the IP-banhappy out there. Here’s my latest concoction:

grep NOQUEUE /var/log/messages | awk '{print $10}' | \
sed "s/[/ /g" | sed "s/]/ /g" | awk '{print "ALL", $2}' | \
sort | uniq -c | sort | tail

In a nutshell, we look for “NOQUEUE” in the log files, pull out the 10th column (IP), split out the junk so it’s just a numeric IP, sort it, weed out the dupes with uniq and pass it the -c flag, which has it count the number of times each line occurs, and then we sort that, so that the list is now sorted by the number of bounces. It defaults to ascending order, so that the top of the file is all people who’ve only e-mailed one invalid address. So the ‘juicy’ part is the end of the file. So we pipe it to tail, which, by default, shows the last ten lines. So the output looks like:

      5 ALL 219.140.194.117
      5 ALL 85.130.84.9
      6 ALL 86.152.15.119
      7 ALL 83.182.186.224
      8 ALL 125.181.70.135
      8 ALL 207.144.11.87
     10 ALL 125.212.188.156
     15 ALL 88.238.145.22
     17 ALL 217.26.169.66
     17 ALL 62.149.197.247

You could use a little more magic to automatically add the second and third columns to /etc/hosts.deny, but I prefer to do it this way… The reason is that sometimes (not in this example) you’ll see posts from a range of similar IPs. It’s more of a judgment call where you draw the line, so I like to give it the once-over.

Sealegs

You know how they say that people who live on ships come onto land and sway back and forth?

I bought an XBox 360 for the school. (I’m being reimbursed, of course.) While I was there, I couldn’t help but pick up the VGA adapter for XBox, since I have a spare 17″ LCD monitor and a spare XBox here with me. I can now play at 1280×1024 (nice!) Still no match to the 1920-ish that we’ve got on the ridiculous LCD TV that Kyle bought, but still…  It sure beats trying to play on, say, a 17″ CRT TV.

So I spent the past half hour or so playing a demo of Blazing Angels. It’s kind of fun, but it takes a long time to get used to. When you keep the camera focused on your target, you can easily lose perspective of whether you’re flying up or down or what. So I died one too many times and got sick of it, so I moved over to the computer.

As I moved the mouse, I was rocking back and forth, and even more disoriented when the whole world didn’t sway with my mouse movements. It’s way more disorienting than I’d expect. Remind me to never become a sailor.

Grand Central

I signed up for an account with Grand Central. It’s a limited beta, but they eventually had a slot for me.

Essentially, I give out my GrandCentral number, which rings in multiple locations. (Currently, my cell phone and my school desk phone.) But it treats calls more like e-mail: I can set up ‘rules’ on what calls get through and what calls don’t. There’s voicemail which I can listen to via the Web.

I have a few invites, if anyone is interested.

Getting Familiar with the CLI

As long as you’re doing lots of work in Linux, there are some more things you’ll want to get used to. I spent a lot of time in the command line. (It’s kind of hard to avoid when you’re working on a headless server.) These tips are useless if you don’t have a basic familiarity, but for people with a relatively basic knowledge, here are tips that might come in handy:

Very often in less, I want to jump to the end of a file and work my way up. I can hit space over and over. One day I thought I was clever, when I realized it would tell you how many lines were in the file, and I began telling it jump to line 123 by typing :123 within less. But it turns out it’s even easier. G takes you to the last line. g takes you to the first line. There are many more handy tips here.

Of course, I spent even more time in vi. Search and replace is handy. But keep in mind that the :s/old/new command will only work on one occurrence. You can append a g, ending up with :s/old/new/g, but it’s only going to work on one line. This is usually not desirable. You can specify a line range. Generally, though, you want the whole file. $ denotes the end of the file, so you can do it as “1,$,” denoting “From line 1 to the end of the file.” But it’s even easier: % means “the whole file.” So I end up with…. :%s/old/new/g to replace all “old” with “new”. And if this isn’t what you want, press u to undo. The “G” trick to jump to the end works in vi, too. Turns out you can replace :wq with ZZ, which is essentially the same.

I’ve known about the uniq command for quite some time: its goal is to weed out duplicate lines. This is handy far more often than you might imagine: say you strung a ton of commands together to pull out a list of all e-mail addresses that your mailserver has rejected. There are bound to be many, many duplicates, because apparently bumttwagnerfor@domain is commonly-spammed (?!).

But uniq has a peculiar quirk that I missed. They call it a feature, although I’m not sure I agree. It’s for filtering out sequential duplicate lines. If the duplicate lines aren’t in order, it will merrily pass them on. I suppose there may be scenarios when this is desirable, although I’m at a loss to think of any. In a nutshell, whenever you want uniq, you probably want to run it through sort first. grep something /var/log/messages | sort | uniq, for example, will pull out all lines with “something” in them, but omit all duplicates.

And note that use of grep. For some reason people seem to think that echo filename | grep search_pattern is the way to do it… There’s no reason for echo. Just do grep search_pattern filename.

Fun with Shell Commands

I’m now running a mailserver, and I was trying to set up Mailman to handle a mailing list. I was having some odd behavior causing Mailman to barf up a fatal error, so I used a trailing monitor on the log file with tail -f.

In the course of doing that, I noticed several hosts connect attempting to deliver mail (presumably spam) to “bumttwagnerfor@domain…”, a bizarre address that definitely doesn’t exist.

It’s not a big deal, because the mail’s just bouncing. But it got irritating watching them all in the log file.

I wanted to ban them. It turns out that Linux makes this easy: there’s a hosts.deny file, and anyone in it is banned from connecting. I already have a script that watches for repeat failed login attempts on ssh and bans them. (And I have something like 200 IPs banned, although I suspect that it’s not purging them appropriately.)

All the log entries are in a common format, and look like this:

Oct 8 05:41:31 oxygen postfix/smtpd[23212]: NOQUEUE: reject: RCPT from unknown[62.233.163.250]: 550 5.1.1 : Recipient address rejected: User unknown in local recipient table; from= to= proto=ESMTP helo=<250.248/30.163.233.62.in-addr.arpa>

We can see (actually, guess, in my case) that the IP is the 10th ‘column’ (using a ‘space’ as a delimiter). So we can begin a rudimentary script to print out just that:

# grep bumttwagnerfor /var/log/messages  | awk '{ print $10}' | head
unknown[211.49.17.175]:
81.202.185.36.dyn.user.ono.com[81.202.185.36]:
host-89-228-234-224.kalisz.mm.pl[89.228.234.224]:
LSt-Amand-152-32-14-78.w82-127.abo.wanadoo.fr[82.127.29.78]:

But there’s an obvious problem: the hostname is rammed up against the IP. I want to just ban the IP, and strip out the hostname. The correct way is to write a lengthy regular expression to match just whatever’s between the [ and ]. (Note that you can’t just write a regular expression to match IPs: the very first one has an IP in its hostname, for example, which would throw you off.)

The quick and easy solution is to replace the [ with a space and the ] with a space, which gives you “hostname IP “. And then you use awk again to print it:

grep bumttwagnerfor /var/log/messages | awk '{ print $10}' | sed "s/[/ /g" | sed "s/]/ /g" | awk '{print $2}'

This is a pretty ugly command. Just the way I like it. 😉

But we’re not quite done! The format for hosts.deny is “Service: Address.” We’re just getting addresses here. I want the output to be something like ALL: 1.2.3.4 for each entry. (If they’re spamming me, I don’t want to allow them access to any other services.)

When it’s all said and done, here’s the command:

grep bumttwagnerfor /var/log/messages | awk '{ print $10}' | sed "s/[/ /g" | sed "s/]/ /g" | awk '{print "ALL", $2}'

You can just append a >> hosts.deny to deny them right away, or parse it through head or less to review first.

And viola. 440 IPs banned.

Seriously, though. wtf is going on? 440 different people have tried spamming this address that has definitely never existed.

Software or Hardware?

For a long time I collected Motorola radios. I soon realized a “trick” — a lot of them had the same ‘guts’ and just had different software controlling them. If you cut the little “stopper” off of the channel knob on the channel knob and changed 2 bytes in the firmware, you had a 16-channel radio.

The higher-end radios were even more seriously software-dependent. The price of a radio could go up hundreds of dollars (thousands when new) depending on the features it has. But it turns out that the whole series had the same hardware, and various features were loaded via software. (This was actually publicly-known.) Soon, people realized how to suck the software out of one radio and drop it into another radio, and suddenly most hobbyist-owned radios had just about every feature possible.

I’m getting out of the radio trade, though. I began by getting a lot of two Canon digital SLRs off of eBay. The two cameras were very similar: both, in fact, had the same sensor. I kept the 10D, which was bigger and had a solid-metal casing, and sold the 300D, which was smaller and had a silly silver plastic case. Mine has a bunch of features that the 300D didn’t: ISO3200, the ability to control flash brightness, and a whole mess of “Custom Functions” that let you fine-tune things, to name a few.

It turns out that I was more right than I realized about them being closely related, though. There’s a firmware hack that brings a lot of the 10D functionality to the 300D. (All the ones I mentioned and then some!) Of course some features are missing: you can’t select autofocus points, for example.

But it’s interesting to learn that model differentiation via ‘crippling’ features in software is more prevalent than I’d once believed.