More Linux tricks

OK, I gotta tell this joke.
Osama bin Laden gets taken out by a daisy cutter. He’s standing up there at the pearly gates, where he’s met by George Washington. “You tried to harm the country I birthed!” he said. And he sucker-punched him.

“You tried to take Americans’ liberty, so they gave you death!” screamed Patrick Henry, who popped out of nowhere. Then he threw an anvil at him.

Thomas Jefferson and James Madison came out and started tag-teaming him, followed by 68 more freedom-loving Americans wielding assorted large and heavy objects.

Finally, John Randolph decided he’d had enough, so he picked up this bloody pulp that used to be bin Laden, and threw him over to the gate for his fiery judgment.

Bin Laden looks up at an angel standing there. “This isn’t the least bit like what I was promised!” he cried.

“I told you there’d be 72 Virginians waiting for you when you got here!” the angel said. “What’d you think I said, genius?”

Let’s talk about some Unix/Linux tricks. Since yesterday’s mention of top drew some positive response, I might as well talk briefly about a few more tricks.

First, the shell itself. If you can’t remember a command, type the first letter or two and hit the tab key twice. You’ll see all the possible combinations. Tab completion also saves you keystrokes and works on filenames too. Let’s say I’m editing /etc/apache/httpd.conf, here’s the key sequence I’ll probably end up using:

na[tab]/e[tab]apa[tab]h[tab]

It saves me more than half the keystrokes. It also lets me be lazy–as long as I remember roughly where the file is and what letter it starts with, I’ll find it quickly.

Steve DeLassus asked me once a couple of years ago why I didn’t use that trick. I said because I’d get addicted to it and hate not having it in Windows. Out of necessity I started using it. I hate Windows command prompts now.

If you want to see your disk usage, or how much space you have free, use the du and df commands. (I never have problems remembering that last one for some reason.)

If you need to see what’s inside your computer, remember the /proc subdirectory. This is Linux-specific, because each Unix variant has its own nuances about /proc. By viewing the file /proc/pci, you’ll get detailed information on the PCI devices in your computer. By viewing /proc/interrupts, you’ll find out what IRQs are in use and what’s sharing what. The /proc/scsi and /proc/ide trees will give you information on the disk subsystems. By poking around inside /proc, you can find out more about a PC than the old standby Norton Diagnostics for DOS used to tell you. Your Linux installation CD can be a valuable diagnostic tool–just boot a troublesome PC with it and hit ALT-F2 (or CTRL-ALT-F2 if it’s a distribution that uses a GUI-based installer) to switch to a console. Or use a single-floppy Linux distribution.

And as for learning this stuff, the only thing I can recommend is total immersion. I asked Charlie, our Unix sysadmin at work, how he learned Emacs. “I just set my edit variables to emacs and lived with it,” he said. “And after about a month I liked it.”

I think I’ll stick with nano or pico or joe or ee, personally. I know enough vi to be able to use it in an emergency. But his approach works for all things Unix. Either dual-boot the PC you have or pick up a cheap second PC. It’s not difficult to find an old Pentium, complete, for under $100 and a price pressure from cheap LCDs has had the nice side-effect of pushing the price of conventional CRT monitors way down. There’s enough good free Linux software out there now that you can live in Linux for long periods of time and still get the same things done in Linux that you would in Windows while you gain valuable and marketable skills.

While you’re at it, eat lots of salmon and blueberries (not necessarily together). They’re supposed to be good brain food, and that can’t hurt.

Once you’re starting to feel like you know something, pay IBM developerWorks a visit. They’ve got a certification prep series up there. You may not wish to spend the time and money to get certification, but by reading the series, you’ll get a good idea of what you know and don’t know, and you’ll learn some more good stuff in the process.

5 thoughts on “More Linux tricks

  • February 16, 2002 at 1:09 pm
    Permalink

    I’ve rarely seen a joke on a blog and that’s probably for the best…

    But that one was funny!

  • February 16, 2002 at 2:03 pm
    Permalink

    Cool tips, I knew the tab trick, but the ones for disk usage I didn’t.

  • February 17, 2002 at 8:21 am
    Permalink

    I liked the joke, and having just spent a few hours in Linux "immersion", needed some comic relief.

    I’ll have to play with the tab tip. As you indicate, you just have to use stuff a lot to really learn it. I like the output of "df"–easy to read and useful. I’ve used something like it at work to check on critical systems, but I think that one’s probably a custom script as it doesn’t work on my Linux box, unlike df.

    As for the immersion, well I finally got my cheap Epson to print, although I’ve only tried simple text so far. Text looks good, although one of my printouts lost part by going past the RH margin.

    What I did to be able to print was first to install ghostscript a day or two back, with no success at printing. Tonight (I work nights but am off tonight) it was visiting websites, google searches, downloading rpms, and at least one unsuccessful attempt to install an rpm (failed due to lack of some libraries).

    What seems to have now worked was to download, unzip, untar, configure, make, and install CUPs, then do the same thing with Gimp-Print. The final trick–on my second attempt to configure Gimp-Print use "./configure –with-gimp –with-cups", thanks to a tip I found on one of my Google searches.

    On the one hand it shows me that despite its power, desktop Linux has a ways to go before being ready for "Aunt Minnie", as Jerry Pournelle puts it. On the other hand, if Linux continues to grow in power and usefulness while Microsoft grows more obnoxious, there will be a job market for people who can deal with the difficulties of configuration as long as things work well once set up properly.

  • February 17, 2002 at 8:41 am
    Permalink

    And a little more playing with the "du" command shows that "du" piped thru "sort -n -r" piped through "more" gives a pretty nifty sorted list of which directories are using up a lot of space. Sorry, had to say "piped through" as I can’t seem to get the pipe symbol to show up when I preview my comment.

  • February 18, 2002 at 8:33 pm
    Permalink

    The tab-completion stuff *does* work on Windows; or rather, on NT and Win2000.

    On NT it is a registry hack: change the value of the CompletionChar value to 9 in HKEY_CURRENT_USERSoftwareMicrosoftCommand Processor

    The same registry key will work on Win2000, but there is also a non-registry place to configure it. (I can’t find it right now, of course). It works on both directories and files, but not with executable names like on Linux.

Comments are closed.

%d bloggers like this:
WordPress Appliance - Powered by TurnKey Linux