Archive for February, 2007

Some Linux/Unix commands worth knowing…

Tuesday, February 27th, 2007

It seems like not a day goes by when I don’t run across someone’s blog listing “top 10 Linux commands you must know” or something like it. I get the feeling these are mostly posted by people who switched to Linux recently and want to share the experience. I switched to Linux 12 years ago, so here’s my version of “some Linux (or really Unix…) commands worth knowing”. I’m not going to be more specific than that. They are in approximate order of increasing skill/knowledge/foolhardiness.

  • ls -al
    We all know that ls is the command to list files in a directory. The -l option gives you details, and the -a option lists the “hidden” files that begin with . (period). So ls -al is the standard “power version” of ls.
  • mv/cp/rm
    Move, copy, remove files and directories. Move is also used to rename.
  • <command> –help
    Putting –help after a command usually tells you what arguments it takes. This is something I really really miss when having to use Windows. You can also try -? or -h (or simply nothing). If that fails, try man <command>.
  • find / -iname <filename>
    The equivalent of Windows’ directory search – but without the world’s worst UI. Running it with / (root directory) as the second parameter is liable to spit out some errors because (unless you are root, which you shouldn’t ordinarily be) you won’t be able to read some directories. -iname is probably the most useful option for the newbie – it means do a case-insensitive name match.
  • vi
    You should know just enough to get by, although these days any distro is likely to have nano or something friendlier than vi anyway. You can get by pretty well just knowing: i to start “editing mode” (insert), x to delete a character, dd to delete a line, ESC to stop editing and enter “command mode” again, :q! to quit without saving, ZZ to save and quit.
  • chmod
    A vital command for mucking about with files. 90% of the time you will want chmod 755 <file> and 9.9% of the time you’ll want chmod 644 <file>. The first makes a file executable, the second makes it “normal” (usually to be used if it came from a bizarre place like a Windows filesystem).
  • grep
    A bit overrated. In the sense that one doesn’t often need it as a new user. But the real reason it’s one of the standard tutorial things is that what you really need to know are regexps (regular expressions). Grep can be viewed really just as a way to get familiar with regexps. Learn them and love them.
  • less
    Forget cat and more – for reading text files, just use less. Cat and more you can learn later when you want to do other stuff besides just read files.
  • ps aux | grep <name> and kill
    Useful for when things go wrong. Find a rogue process with ps. Kill it with kill. Job done.
  • Ctrl-Z and bg
    Forgot to add the & on the end of a command and your command prompt didn’t come back? No worries – hit Ctrl-Z and type bg and Bob’s your uncle.
  • kill -HUP
    Useful for restarting a process and/or having it re-read the config files. A good example is when for whatever reason, X fails to start and you are left at a text prompt. So (using your minimal vi knowledge) you quite happily fix up your X config file, but then what? If you are a newbie, chances are you reboot (that being the only way you know to restart X). But probably all you need to do is something like ps aux | grep gdm followed by kill -HUP. And you’re back at a nice graphical login.
  • tar -zxvf <file>
    The standard way to unpack a tarred and gzipped file. The options are: z for zipped, x for extract, v for view (you can leave this out if you like) and f for you guessed it, file. You can also use -jxvf if the file is bzipped rather than gzipped.

That’s a good set of standards to get oneself up and running as a newbie. On the hairier side of things, some other useful commands to know are:

  • lsmod and modprobe
    For listing and loading kernel modules.
  • lspci and lsusb
    For inspecting your hardware.
  • dmesg
    For seeing what went wrong when you just plugged in your iPod.
  • lsof and dd
    Given that practically everything in Unix is abstracted as a file, there is almost nothing you can’t do with the combination of these two absurdly powerful tools.

it's old, but it still works!

Thursday, February 22nd, 2007

Having played around with DosBox lately, I decided to do some more digging in my archives and found some stuff from the early 90s, pre-university era. Back then I was programming in QuickBASIC, which was awesome at the time. I found a half a dozen programs: a game of Yahtzee that I wrote and my brother and sister had loads of fun with, some typeins I converted from BBC Basic, early forays into texture mapping experiments and sprite editing, and a 7500-ish-line database program for tracking salesforce performance.

I wrote this last one at a time when my dad was regional director of such an outfit. We called the program “Activity”. Version 1 (I still have it) was written in FRED, a macro language in Ashton-Tate’s Framework (which, I am amazed to discover, is apparently still alive). Framework was one of those “integrated packages” that were everywhere until MS Office obliterated the market in the mid-90s. Activity version 2 was a rewrite in QB. It was simple, but in many ways it was ahead of its time – it could handle consolidating team figures, branches, etc, all the way up to the national figures, and it also offered the ability to track progress against goals. And it was much more stable than version 1, which was lacking in error handling. Version 1 was rolled out to the sales force, and some of them even persevered with trying to make it work. Version 2 was completed, but with one thing and another (not least, the direct salesforce portion of the company being sold) it never saw battle. I’m sure that such companies have since spent literally millions of pounds on software to do essentially the same function. But we were there first, in 1992.

So anyway, I dug it out, dusted it off, figured out how to work it again, and it still works! None of your Y2K bug, either – although it does seem to be coming to the end of its original commissioned lifetime – the last year supported is 2007. I was pleased to discover the 17-year-old me had actually commented the code and left it in a pretty readable state, too!

Anyway, since 7500+ lines is too much to post here, I’ll leave you with another snippet: a program I wrote to play Scott Joplin’s The Entertainer on the beepy PC speaker.

CLS
PRINT “Press a Key for Entertainment”
start:
DO
LOOP UNTIL INKEY$ <> “”
intro$ = “O4T100L16DEC<A8BG8DEC<A8BG8DEC<A8BAA-L8GN0O3G”
a$ = “O3L16DD+E>C8<E>C8<E>L4C.”
b$ = “L16CDD+ECDE8<B>D8L4C.”
c$ = “L16N0<AGG-A>CE8DC<A>L4D.”
d$ = “L16CDECDE8CDCECDE8CDCECDE8<B>D8L4CL16N0”
e$ = “L16<EFF+G8AG8EFF+G8AG8>EC<GAB>CDEDCD<G>EFGAGEF”
f$ = “G8AG8EFF+G8AG8GAA+BL8BBL16AF+DG4N0”
g$ = “L16<EFF+L8GL16AL8GL16EFF+L8GL16AL8G>L16EC<GAB>CDEDCDC4N0”
h$ = “L16O3GF+G>” + “C8<A>C8<A>C<AG>CEG8EC<GA8>C8ED8L4C.L16N0”
i$ = “O4L16AG+A4>C8D8<<B-AB->CD8FEF4A8B-8<GF+GAB->GD8GD8GD8C4”
j$ = “L16F4EG+B>E8D<B>C<A4B-4”
k$ = “L8F.L16FA>C8<G8CDEL8FN0>FN0”
l$ = “L16O4C8<A>C8<A>C<AG>CEG8EC<GA8>C8ED8C4N0>L8CN0”
m$ = “O3L16F8EF8EF8N0A>D<A>CDC<AG8F+G8F+G8N0>CECDEDC”
n$ = “D8C+D8C+D8N0FAFGAGF>CCC4<A8G8<GGG8G8”
o$ = “O3L16AG+A>G8F8CED+EA8>C<GEC8C8ED8C4N0>L8CN0”
enter1$ = intro$ + a$ + b$ + a$ + c$ + a$ + b$ + d$ + e$ + f$ + g$ + h$
enter2$ = a$ + b$ + a$ + c$ + a$ + b$ + LEFT$(d$, LEN(d$) – 2) + “O5L8CN0”
enter3$ = i$ + j$ + i$ + k$ + l$
enter4$ = m$ + n$ + m$ + o$
PLAY enter1$ + enter2$ + enter3$ + enter4$
GOTO start

more linux fiddlings

Sunday, February 18th, 2007

Some things I’ve tried over the past week or so:

Getting Second Life to work on Linux (compiling from source). Well, it worked in a very limited way, after a fashion. I didn’t get any sound (had to compile without FMod because v3.75 isn’t downloadable for 64-bit Linux). And there were some graphics artifacts too. Linden Labs says that the Linux client is alpha. I don’t think it’s even there yet. Anyway, since I don’t really play Second Life (if you don’t fancy gambling or cybersex, there’s nothing to do) I’m not bothered.

VMWare Player. It’s nice. I like the concept a lot. And although it doesn’t give you any tools to create virtual machines, I soon discovered QEMU (for creating the disks with qemu-img) and EasyVMX. But VMWare doesn’t work that well with FreeDOS. Perhaps I’ll try breaking out the old MS-DOS 6.22 disks.

After some fiddling around with that, I gave up and went for DosBOX. Which plays things (old games) very nicely. With sound, even! I have now set up Eye of the Beholder 1 & 2 and also Sam & Max Hit the Road and Day of the Tentacle. It’s all good. Now I just need to figure out a way to host those slightly younger games from the Win95/98 period, some of which use early forms of 3D acceleration. Roll on VMWare supporting 3D stuff.

97X… Bam! The future of Rock and Roll

Thursday, February 8th, 2007

Over 70% of radio listeners listen while in the car. What are your stations set to? Mine are:

1. KCBS 93.1 “Jack FM”. Used to be Arrow, a classic rock station. Now seems to be some sort of chain (I've heard one in the SF area called “Bob”) which makes a big deal of not taking requests and “playing what we want”. It's hanging on to a preset by the skin of its teeth, actually.

2. KYSR “Star” 98.7. Home of the “wacky/outrageous” morning show and otherwise peddler of whatever-the-RIAA-want-to-promote-this-week. The American (and way-inferior) version of The Eagle which was my old morning show staple (PG & Bev). Sadly, new UK laws last year mean that UK music radio can no longer be offered over the web. Boo. Still, there's always Nick Ferrari on LBC. If I want to listen to the radio at 10pm PST.

I just found out that Jamie White was let go from KYSR recently and the morning show has been cancelled! Too late, moving on…

3. KRTH “K-Earth” 101.1. For the oldies. This is one that Mrs Elbeno likes, to fill in when everything else is adverts.

TBH, 1, 2, and 3 are relics from when Mrs Elbeno used to drive the car. I hardly listen to those stations these days. Now with 4, 5 and 6 we're getting to the better stuff.

4. KMZT 105.1 “K-Mozart”. Great station. For days when I feel like a change from…

5. KKJZ “K-Jazz” 88.1. NPR from Cal State Long Beach. This one is a bit ropey on the reception, and Mrs Elbeno complains about that, but I figure a bit of static over music of this quality beats clear reception of any amount of stations 1 & 2. Wikipedia says: “The station is one of the highest rated jazz stations in the United States”. And that's fine by me. It's part of my daily commute. And one of the few stations I've ever bothered to listen to online.

6. KCRW 89.9. Local NPR station out of Santa Monica. They have “Morning becomes eclectic” (which usually loses out to Jazz, for me) and in the evenings they have “All things considered” which is a pretty good news/talk segment, lately often examining issues relating to the Iraq war.

That's it. Anyone have any suggestions for replacements for 1, 2, 3?

getting stuff working on Linux

Friday, February 2nd, 2007

Inspired by ‘s recent wibblings on Linux, I decided it was time to iron out my own wrinkles. So after a very little googling, I was able to get a bunch of stuff working that for one reason or another had broken when I upgraded from Dapper to Edgy.

  • Sound works on the desktop again (a simple matter of an outdated .asoundrc).
  • Eclipse works (an x86_64 bug was mitigated).
  • My webcam works (after a quick compile of the latest module) which means I can use Ekiga to talk the family.
  • Flash 9 works through nspluginwrapper (Adobe are apparently incapable of releasing a 64-bit version).
  • And I downloaded some games: Neverball and the Neverwinter Nights Linux client binary.

The only time I have to boot Windows now is if I want to VPN to work.