Firefox did not have to prevent this site from opening a pop-up window.

<< Previous Page :: Next Page >>

How To Move Linux to a New Hard Drive

Date/Time Permalink: 07/26/08 05:49:59 pm
Category: HOWTOs and Guides

It's been a busy week for me. It's been one of those weeks where all the machines in the house gang up on me and demand attention at once. Like the Twilight Zone episode "A Thing About Machines", I've had to carefully negotiate with them, bargaining to keep them patched so I don't have to repair them for just a bit longer.

While I'm at it, let me just mention that I also switched over my ISP. And a big, whooping shout goes out to Iowa Telecom, our new DSL provider, for unflinchingly providing comprehensive tech support to set up my network with their service even after I admitted to openly running Linux! We're set up with their DSL now, which has had no problems at all.

Back to the point of this post, one of the computers ran out of hard drive space. So I had a bigger hard drive with four times the disk space handy, and swapped them. The steps:

1. You'll need to connect the new drive onto the IDE cable. Most IDE cables have two plugs for hard drives. The headache comes with determining which drive is a master and which a slave, so the computer knows which one to boot to. No two hard drive manufacturers have the same standard for setting those tiny little jumper pins on the unit, so you'll have to read whatever diagram they have and fiddle with tweezers moving them around and such.

Also, most PCs allow you to select boot order from the BIOS, or with what order you go by on the cables. Our troubles begin when we have a drive with the pins in the wrong place and a BIOS that disagrees with it. You'll know that you have it all straightened out when you have your original drive as "/dev/hda" and your new drive as "/dev/hdb". Start it up and test for this, then shut it back down.

2. Disconnect the original drive (so you don't accidentally mess it up!) and boot the machine from your choice of any live CD distro or "Tom's root-boot floppy". Tomsrtbt has the benefit of being fast, having all the tools you need for disk maintenance, and virtually guaranteed to run on any old toaster you have. It's saved my bacon dozens of times, so another big, whooping shout out to Tom.

3. If it's a used drive, use "fdisk /dev/hdb" to delete partitions. fdisk is really simple. The commands are all one-letter.

  • m - The "manual", it will print all the commands available.
  • p - Prints the partition table.
  • d - Deletes a partition. It will prompt you for a number, if there's more than one.
  • w - Will write the changes to the drive permanently.
  • q - Quits fdisk.

After this, I always use "dd if=/dev/zero of=/dev/hdb" to wipe the new hard drive completely. If it's factory-new, you can skip these steps. Using "dd" will take a while for a large drive. Figure roughly one hour per ten Gigabytes. Leave it run while you go play Sudoku.

4. Now you will want to set up the new drive's partitions with fdisk. Once again, use "fdisk /dev/hdb" and type your letters; Linux distros will usually need partition #1 to be the boot section, #2 to be swap, and #3 to be the "/" root directory. But these differ. Some distos want to split up the root partition into multiple sub-partitions, with "/usr/" or "/home/" going on a separate partition.

  • n - New partition. You will be prompted to answer whether it's to be a primary or extended partition, enter a partition number, and specify the beginning and ending blocks. For anything less than four partitions per disk, make them all primary.
  • a - make a partition "bootAble". Usually only the first partition - boot, naturally!
  • t - Change a partition's system Type. By default, fdisk on Linux will make every partition type #83 - native Linux. The only one you will have to change is the swap one, to #82.

Here is a typical Linux setup from a different machine:

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1           9       72261   83  Linux
/dev/hda2              10         140     1052257+  82  Linux swap
/dev/hda3             141        1550    11325825   83  Linux
/dev/hda4            1551        9729    65697817+  83  Linux

Check the start and end cylinders for each partition. The boot partition (#1) only needs to go from 1 to about 9, since the boot section only needs a few MBs. The swap partition... is the subject of controversy. Nobody ever knows exactly what to make it. Just take a guess close to what most systems seem to install by default and go from there. The rule of thumb is "twice your RAM size", but in real life I've found that the minimum you need should be about 256MB (1/4th of a Gig) and the most about a Gig. For a home system, anyway.

Because I have to have huge amounts of disk space for home (backing up the website, archiving my graphics art and writing work, emulating systems), I have 62 Gigabytes here for /home/ and only 11 Gigs for the "/" partition, which is extremely generous for most Linux installs even with more stuff on it than anybody would need.

5. Anyway. Now that you have the disk partitioned, make a file system on all partitions with type #83. "mke2fs /dev/hda1" and do the same for /dev/hda3... etc.

6. Now you're ready to shut down, reconnect the main hard drive, and boot back to your main drive. Mount each partition from both disks in tandem - "mount -t ext2 /dev/hda1 /mnt/hda1" and "mount -t ext2 /dev/hdb1 /mnt/hdb1" for instance. Then copy everything from one disk to the other, one set of partitions at a time, repeating for hda3, hda4, etc. If you use "cp -pR /mnt/hda1 /mnt/hdb1", that will copy everything Recursively (R) (all folders, subfolders, and files for the whole file tree), and preserving permissions (p). Do not copy the swap partition, of course!

7. And... one last step. You need to use either Grub or Lilo to write to the Master Boot Record of the new hard drive. I use Grub, since... well, I dunno, I like it! And it's flexible. The only problem with grub is that its syntax is so alien. Here's a good tutorial on Grub. My only habit is to mount the old boot partition and make a copy of the menu.lst file to somewhere else, then after I use Grub to create the bootable record on the new disk, I copy over the menu.lst file to it. Providing, that is, that the old system also used Grub and I'm not changing anything.

8. Finally, shut down yet again, remove the old hard drive, change the new hard drive so it will be the master disk instead of the slave, checking jumper pin arrangement on the drive, cable position on the IDE cable, and BIOS boot order. Congratulations, you did it! But do check to make sure the system is stable and no file data has been lost before you go wiping the old hard drive... this is why we copied files instead of moving them!

This was just a quick overview of the process. There's a lot of details for each of the steps. Consult documentation for specifics, and if you're not at least competent with the tools involved, try practicing on a scratch monkey computer until you get the hang of it without risking your valuable data.

And be sure to check the comments for all of the corrections left by visitors pointing out where I goofed this up!

Another Linux shield

corrections: Commenter andrew scored one point. It's "menu.lst" not "menu.1st". I was thinking "this menu gets shown first" instead of "this is the menu list", I guess?

And I might add... Seeing some of the other comments, *yes*, I am an ancient caveman using stone knives and rock hammers to chip computers out of wood. Of course, wonderful new programs, hard drive platforms, and space-age file systems are out there now. This is just one way to do it. Ogg go back to bang rocks together now.

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

Yet Another Random String Generator

Date/Time Permalink: 03/28/08 09:36:26 am
Category: HOWTOs and Guides

I was browsing through the excellent Shell-Fu site and I ran across this simple random password generator. Handy, but a good candidate for aliasing since it's relatively long. Then, I figured why not make it a multi-function script?

So, here's what I call '':


USAGESTRING="USAGE l(letter),L(LETTER),n(number),a(all) N(length)\n \
             example: ' n 8' returns random 8-digit number"

if [ "$1" ]; then
  echo -e $USAGESTRING
  exit 1
if [ "$2" ]; then
  echo -e $USAGESTRING
  exit 1

case $ATRIB in
  l) ATRIBSTRING="a-z" ;;
  n) ATRIBSTRING="0-9" ;;
  a) ATRIBSTRING="A-Za-z0-9" ;;
  *) echo -e $USAGESTRING
     exit 1 ;;

case $LENGTH in
  [0-9]*) LENGTHARG=$LENGTH ;;
  *) echo -e $USAGESTRING
     exit 1 ;;

echo $(cat /dev/urandom | tr -dc $ATRIBSTRING | head -c$LENGTHARG)

exit 0

I'm using a lot of argument-checking here. I might as well make something idiot-proof for a change - especially if I'm the idiot in question!

Anyway, calling it with...

  • " L 8" will give you 8 UPPERCASE letters,
  • " a 12" will give you 12 characters including Upper/lower letters and numbers,
  • " n 16" will give a 16-digit random number,

and so on. Keep in mind with the numbers, there's no guarantee against having zeros at the beginning, so it might evaluate to a shorter number if you do anything mathy with it.

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

Obscure Linux Commands: Some of My Favorite Incantations

Date/Time Permalink: 03/13/08 07:11:09 am
Category: HOWTOs and Guides

A little random grimoire of my spiciest magic spells, which don't fit well anywhere else:

emacs -batch -l myLispProgram.el

What it does: It runs Emacs in batch mode to run whatever Lisp code you might have in "myLispProgram.el". Just like Python or CLisp, it will process the code, write its output, and quit - without starting up the editor. The output that would normally print in the minibuffer in Emacs will just dump to screen instead.

True Lisp programmers will scoff, "So just run CLisp programs", but I've never had much use for getting deep into Lisp - I find that it's mainly handy to use the eLisp dialect for those few jobs that are too clumsy for Bash scripting. The most common situation is when I'm coding in another language and have to make a whole bunch of lines with small differences, such as processing frame files (numbered frame_00.png, frame_10.png, etc.) into an animation.

convert image.jpg -resize XX% image.jpg

What it does: It's the fastest way to resize an image, that's all. Useful for generating thumbnails of an image gallery. The 'convert' command is part of the Image Magick suite. A script example:


for FILE in $(ls *.png)
  convert $FILE -resize 160x120 ./thumbs/$(echo $FILE | sed 's/png/jpg/')

exit 0

Which generates JPG thumbnails from PNGs and saves them to a separate 'thumbs' folder. So the -resize option to 'convert' will work with either a percentage (50%) or a specified size in XxY format. It beats firing up the Gimp, especially for one screenshot.

WORDLINE=$((($RANDOM * $RANDOM) % $(wc -w /usr/share/dict/words | awk '{print $1}')))"p" && sed -n $WORDLINE /usr/share/dict/words

What it does: It gets a random word from the dictionary. Of course, once you get this line down, you'll want to call it from a script named something like ''. Useful in generating word games or puzzles, starting a Markov chain, or getting a random word for a CAPTCHA program. The same method can also be used to get a random line from any file, with the substitution 'wc -l' to word-count lines instead of words. Since each word gets in own line in the Unix dictionary file, the difference is indistinguishable in this case.

Simply calling 'sed -n 100p $FILE' would print the 100th line of that file, see, so our only remaining job is to get a random number that has a range up to the number of words in the dictionary, but not higher. Then it's easier to compose it into a variable with a 'p' appended onto the end, since sed chokes parsing "$WORDLINE p".

Anybody who has a shorter line is welcome to post in the comments. I sense a Perl ninja about to strike...

echo -e '\E[7m'

What it does: It turns on reverse video mode for the console session. Turn it back off with:

echo -e '\E[27m'

This is useful for highlighting your next command (chained on with the handy '&&' conjunction) so the output is visible in reverse coloring. If you have long terminal sessions where you have to scroll back to see some output and don't want it lost, this comes in handy. Of course, if you already have scads of escape-sequence hacks in your Bash $PS1 prompt string as I do, turning off inverse won't be an issue. It's also easily aliased in your .bash_profile - for example

alias invon="echo -e '\E[7m'"

will make 'invon' the command to use to do this.

for X in $(seq 2 12); do for Y in $(seq 2 12); do echo -ne $(($X * $Y))"\t"; done && echo; done

What it does: Prints out a multiplication table. Learn your math, junior!

COOKIE="16i"$(mcookie | tr 'a-z' 'A-Z')"p" && dc -e $COOKIE | cut -b -12

What it does: Earlier, you saw me generate a larger random number by multiplying $RANDOM times itself. Here's a way to get an even longer random number - featuring the rarely-encountered 'mcookie' command, running it through tr to make the digits uppercase so dc doesn't choke, sticking dc's whole command line into the variable, and having dc translate it from hexadecimal to base ten.

Of course, you'll overflow your buffer if you try to do any math on a raw md5 value in Bash. So that's what the 'cut -b -12' does is only preserve the first 12 digits of the number. Vary that for a longer or shorter number as needed.

Linux Punx tagged this wall with graffiti.

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

Today For Show-n-Tell, I Brought My Dot-Emacs File

Date/Time Permalink: 01/17/08 09:35:50 am
Category: HOWTOs and Guides

Somewhere along the way, I guess every Emacs fan gets around to posting their .emacs file. This is the customization file stored in your home directory if you use Emacs. They're interesting because over the years each user finds a half-dozen tricks and accumulates them in this dot-file which you can move with you from one PC to another.

I've excluded the top part, which is the standard XEmacs custom-set variables, leaving only the parts I've added:

;; Custom tweakin's...
;; -------------------
;; The font only affects X-windows, due to the line below:
 (if (eq window-system 'x)
     (set-face-font 'default 
;; The color scheme is a dark cyan-on-black, with a red cursor.
;; Combined with a simple fixed font, this is easy on the eyes
;; in both console and desktop, and reminds me a little bit
;; of old consoles, for the retro-coolness of it.
(add-to-list 'default-frame-alist 
  '(foreground-color . "medium turquoise"))
(add-to-list 'default-frame-alist 
  '(cursor-color . "red"))
(add-to-list 'default-frame-alist 
  '(background-color . "black"))
;; Do you find the beep annoying? This shuts it off.
(setq visible-bell t)
;; This stops it from making those files 
;; ending in tilde (~) everywhere.
(setq make-backup-files nil)
;; This stops the opening splash screen, making the window
;; come up blank.
(setq inhibit-startup-message t)
;; Time+Date insert hack. 
;; M-x insert-time puts a time/date stamp.
;; Like this: 2008-01-17-08:58 Explained here
(defun insert-time ()
  (insert (format-time-string "%Y-%m-%d-%R")))
;; A menu-bar is just a crutch placed there for 
;; disoriented newbies, said the grouchy geek.
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
;; Not sure if I even need to do this any more, 
;; but this is how you load a language mode. 
;; In this case, Python.
(setq auto-mode-alist 
  (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist 
  (cons '("python" . python-mode) interpreter-mode-alist))
(autoload 'python-mode "python-mode" 
  "Python editing mode." t)

;; My custom Elisp programs, from Emacs_Lisp folder
;; ------------------------------------------------
;; Word-wrap instead of fill-mode!
;; Get it here.
(autoload 'longlines-mode "~/Emacs_Lisp/longlines.el"
  "Minor mode for editing long lines." t)
;; Use the mouse scrollwheel in XEmacs!
;; I no longer know where to get this. 
;; Maybe it's part of standard base now.
;; If anybody wants it, I'll post it.
;; Note - it always says "failed to define function..."
;; but it gives me the mouse wheel anyway!
(autoload 'mouse-wheel-mode "~/Emacs_Lisp/mousewheel.el"
  "Enables scrool-wheel" t)
;; Sokoban. Get it here.
(autoload 'sokoban "~/Emacs_Lisp/Sokoban/sokoban.el"
  "Start a new game of Sokoban." t)
(autoload 'sokoban-mode "~/Emacs_Lisp/Sokoban/sokoban.el"
  "Play Sokoban in current buffer." t)
(setq sokoban-levels-dir 
;; MazeMax. It generates a quick maze, 
;; for whatever purpose.
;; Get it here.
(autoload 'mazemax "~/Emacs_Lisp/mazemax.el"
  "Generate mazes." t)

Well, commenters, it's your turn! What cool new tricks have you taught Emacs lately?

Side-note: Yes, it has been ten days since my last post. A record! What can I say, it's been a crazy month...

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

Obscure Linux Commands: Random Little Stuff

Date/Time Permalink: 12/12/07 09:13:41 pm
Category: HOWTOs and Guides

Blaugh, I'm going to be one tired, burned-out blogger for the rest of the month. My paid writing work currently is to write a ton of content about the upcoming 2008 US presidential election. happy. happy. joy. joy. It's a ghost-writing gig, so don't ask where and who - and if you saw it out there, you'd never recognize it was me. I have to maintain the utmost editorial integrity and be neutral and boring, when what I really want to do with this three-ring circus of an election is put on my gonzo hat, snack my way through the medicine cabinet, and channel the spirit of Hunter S. Thompson to write Fear and Loathing on the Campaign Trail in 2008: Pray for the Flying Saucers to Kidnap Us!

Oh well, I'll leave the political blogging to people like Wonkette, who's doing a good job in my place. Meanwhile, for FOSS blogging I have to fall back on the vault. And the vault today is half-portion scraps and left-over doodles. But hey, here's some CLI Linux commands that I bet you're never typed in!

ddate - No, not the well-known "date" command, but DDATE, the not-so-well-known-before-now Discordian date. Today, as I publish this, it is "Sweetmorn, the 54th day of The Aftermath in the YOLD 3173". If you've ever seen a Linux/Unix system cough up a line like this - Tom's root-boot floppy leaps to mind like a monkey wot sat onna tack - this is the program that it comes from.

units - The units command converts between units. Isn't that interesting? No? Well, this is an impressive command anyway, because it is the Bertie Bott's Every Flavor Beans of unit conversion programs. Check out Linux and Things for a heart-warming units story. He used it to convert between two physics things, the nature of which I haven't the fuzziest notion.

quiz - This comes with bsd-games - easy to find and install if you don't have it. It is a very simple trivia game - it gives you one half of a pair, you supply the other half. Latin/English will give you the word in one language to answer with the other, victim/killer will give you pairs of names from famous homicides to pair up, and so on. The nifty part of this is that the quiz files are in plain text in /usr/share/games/quiz/. Once you get the hang of quiz and browse the files, it's easy to write your own quizzes. A trivia buff should love it.

setleds - Really, this is only useful for hacky sysadmin types. This command sets the little green lights on your keyboard automagically. "setleds +scroll" will turn on the Scroll-Lock light, "setleds -scroll" will turn it off. Other options on the man page.

Now, you're saying to yourself, "How utterly useless!" But you haven't thought of the scripting possibilities yet. What if you leave the PC and come back - would you like a light to pop on when you have new mail, so you see it when you get back? How about setting a sequence to let you know when a compile job finishes? Maybe a secret code that will blink on to let you know that somebody tried unsuccessfully to crack root? Have the light stay steady, but flip off if a ping script detects that your website is down?

Ah, now you get it! The only downside is that it has to run from the console (NOT a desktop terminal). But that's OK, you can script from the console, too. And you finally have a use for Scroll-Lock!

rain - An ancient console program. It's an ASCII rain animation! Stop it with Control-C.


Well, that's it for that post. I promise to do better next time.

the Linux shield

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

Arcane Linux Commands - Crunching PDF Data

Date/Time Permalink: 11/29/07 06:26:01 pm
Category: HOWTOs and Guides

A Slashdot story today is a very interesting read on Google's latest malware crackdown. And there's a bonus buck: a list of the search keywords which the malware spammers were targeting, in the form of a PDF file. Which will be ze subject in today's lab-ooor-atory expeereemint.

But first, let me take a moment to plug this story better. If you've ever wondered how malware and search spamming works, you can get a lot of insight from this story, including a listing at Sunbelt blog of some Javascript the spammers were using to alter behavior depending on if you came from Google. Check the code shot. Isn't that a clever, if evil, little hack?

But now to our subject:

We're going to deal with a PDF entirely on the command line. To check out what programs that handle PDF are available on your system, simply type 'pdf' and then hit the TAB key twice. I get:

pdf2dsc     pdfcrop     pdfimages   pdflatex    pdftex      pdftops
pdf2ps      pdfetex     pdfinfo     pdfopt      pdftohtml   pdftotext
pdf2swf     pdffonts    pdfjadetex  pdfroff     pdftoppm    pdfxtex

so I picked pdftotext. So,

 pdftotext searchterms21388.pdf Search_terms.txt

is the first step in getting a command-line friendly print of the data. Note that I gave the text file an uppercase first letter. That way I can just type shift-S-TAB instead of typing the filename over and over, and it won't stop to see if I want the text one or the original.

Now, the text file is still a mess here. We have:

| microsoft excel free download | microsoft office excel accounts | customer opp
ortunities | microsoft excel software | microsoft excel | 2002 visual basic for 
applications step by | microsoft excel file | password recovery | microsoft exce
l programs | microsoft excel macro | | microsoft excel visual basic macro | intr

a blob of phrases separated by a very obvious delimiter - the pipe '|' character. To comb this into more usable data, we can go:

sed 's/|/\n/g' Search_terms.txt > temp && mv temp Search_terms.txt

replacing the pipes with newlines, so now we have each search term on its own line. Remember that many of the command line filters edit data non-destructively; we have to specifically pipe it to a file and move it back to the original. Now we have:

 microsoft excel free download 
 microsoft office excel accounts 
 customer opportunities 
 microsoft excel software 
 microsoft excel 
 2002 visual basic for applications step by 
 microsoft excel file 
 password recovery 
 microsoft excel programs 
 microsoft excel macro 
 microsoft excel visual basic macro 
 introduction of microsoft excel 

which is better, but has lots of blank lines and isn't sorted. At this point, I briefly opened it in a text editor and deleted the first two lines which are only the title of the report. Back to the command line:

sort Search_terms.txt | uniq > temp && mv temp Search_terms.txt 

which sorts the data, gets rid of duplicate lines (such as those blanks), and avoids a 'useless use of cat' award. At last, our effort is rewarded with: vpn 
 2002 visual basic for applications step by 
 2003 by robert grauer ebook download 
 2003 questions 
 2003 workbook 
 2003, sort sum formula 
 2007 for sale 
 2keyword free domain name hosting 
 327w router telnet vpn 
 678 vpn 
 937 + vpn 

Ah, what clean, neat data! So, this is the keyword list which malware authors were targeting. Now let's get some stats:

wc -l Search_terms.txt 
grep "[Mm]icrosoft" Search_terms.txt | wc -l

wc is the 'word count' program and the -l argument counts lines. In the second line, I use grep to find all lines containing 'microsoft' and 'Microsoft' ( the [Mm] is either-or). So, out of 1,396 search phrases, 318 of them targeted Microsoft. What's that percentage?

 dc -e '2k 318 1396/p'

So, 22%. With another grep, I found out "[Cc]isco" is mentioned 54 times, a paltry 3%. But what word is the most frequent of the report? Here's a little script that I have saved as '' for "word frequency":


# wf, the friend to wc
# word frequency counter
# prints unique word count, sorted by most frequent words first,
# and reverse alphabetical order.

tr -s ' ' '\012' < $1 | sort -fd | uniq -c | sort -rn | less

Handy little one-liner. Just so everybody knows I'm not posting a fork bomb (*smiles wanly at commenter Craig McLure*), the ingredients are:

  • tr : The -s "squeezes" all consecutive instances of the first match together, treating one space, two spaces, etc. as one space. It is replacing the spaces with the Octal 12, which is the 'FF' formfeed ASCII - in other words, newlines. Each word gets its own line, now. The '< $1' says "take input from the file whose name I just passed to you."
  • sort : The first sort gets argument -f for "fold" (ignore) case, and -d for "dictionary order", ignoring numbers and punctuation.
  • uniq : The -c argument will count how many duplicates of each word there were before squeezing them to one unique word, and prefix the resulting number to the line.
  • sort : The second sort use the argument -r for "reverse" and -n for "numeric" sort. Ha! We now have the words with the highest number of repetitions on top! And we only had to type a little line noise to do it! "f y cn rd ths y mst hv bn usng unx"!
  • less : since I figured I'd never use this for making a permanent file, I figured to toss the pager right in there. This is normally bad form, but I build laziness into my scripts every chance I get.

Running ' Search_terms.txt' on the file yields the following for the top ten of the list:

    401 vpn
    319 microsoft
    313 excel
    286 fetch
    118 to
     87 a
     79 go
     59 and
     56 how
     54 free

This 'VPN' seems to be Virtual Private Network - at 28%! So, if anybody out there did a lot of searching for VPN's while running an MS box, I'd check my system if I were you!

None of this was ground-breaking enlightening, but was just a little example of using quick commands to get some fast answers from a simple data set. If you had a need (like you get PDF reports every week) you could always tuck all of the translation and sorting stuff into a shell script.

Happy hacking out there in Linux-land!

the fake XKCD

Update 4/21/09: Since everybody's hitting this image with Google 'similar image' search looking for more stick-figure comics... might I suggest, if you're ready to go beyond stick figures, that you try Doomed to Obscurity?

(The Real XKCD)

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

News Flash: Many People Still Hate Work!

Date/Time Permalink: 11/26/07 11:05:06 am
Category: HOWTOs and Guides

Back in the '60's counterculture, the dreaded "F-word" was one of the mantras of the youth movement. Every time you said it in front of a microphone, the crowd went wild, because it meant you were one of the people instead of one of the suits.

I get the same glee from my own "F-word". It is a magic spell guaranteed to repel every single person who is a problem in this world, with just one syllable.


Yes! Work! I love work! Hard, hard work! Back-breaking work! Brain-wracking work! Work until I'm starving, and somebody has to push the food in my mouth so I can keep working! Work until I actually fall asleep, drolling and snoring, with my fingers still twitching on the keyboard! Work until the snow-shovel slips out of my hands and I collapse face first!

Work like a demon! A dervish! A soulless zombie! A raving, cackling madman! THE POWER OF WORK COMPELLS YOU!

That's what gets things done in the world, is work. Just recently, I have noticed how long I have been reading the Internet without seeing that word in print. Work. Not just busy-work, mind you, but work to accomplish something. Work. Just saying it out loud makes the sun rise, and then all of nature gets up and dances with joy.

Jeff Atwood and Scott Mitchell have been having a little slap-fight over the whole "Teach Yourself $Language in $X Hours" books. And I'd concede the point to Jeff, who's being way too nice about it. And I'm not just saying that because Scott is an ASP evangelist.

Jeff nailed a lot with his 80-20 rule: 20% of the programmers (and computer people in general) are the alphas, go-getters, the geeks. And 80% are the... (what's the word that will draw the least flames while still saying the truth?)... "potted plants". Go read Jeff Atwood to see everything I'm talking about.

Except, more than anything else, the 80-20 can be summed up in two categories: 20% are workers. 80% would rather not work. So they look for shortcuts.

Well, yeah, "6-Minute Abs", "Teach Yourself Programming in 20 Seconds", "Do Anything You Want To On A Computer Without Learning Anything", etc., will always sell. People will always look for it. People will also look for ways to lose all their unwanted weight without dieting and exercise, make money fast and easy, or succeed in their love life without having to become somebody besides an unattractive, mean, loveless troll.

Yeah, hello, can I get a word in, everybody? I'm Penguin Pete, and this whole damn blog is about building that bridge to those 80%. But guess what? I, unlike many out there, know that lying to people and telling them that hard work doesn't exist isn't going to make that 80% move over to our side. I do just the opposite: I tell them "Yes, it's hard, hard work. Just like anything else worth having, it takes a lot of effort. But it won't kill you. I'll help you - that's some of my work - but even if I do, you will still have to work."

You wanna switch to Linux? Learn it. You want to be a master programmer? Study it. You want success? Work. WORKWORKWORKWORKWORKWORK Work.

Call us elitist? Go to hell.

Say we're excluding you? Go to hell.

Want to find an easier way? Waste your time, then. Then, go to hell.

Or as Scott tells it: "I worry that such sentiment from the community will come across as pompousness to those very people whom we should be welcoming."

Well, go ahead and worry. Wring your hands and whimper and quiver your chin while you're at it. And everybody who listens to the Scotts of this world while they worry, may you all turn your back on MY pomposity! Then never improve your lot in life and starve to death and die from exposure and let the other army occupy your country and enslave you, because. you. would. not. work. But at least you didn't have to - God forbid! - deal with any pompousness!

It isn't about respect or my attitude or geeks in a club. I still love you; it's the universe that's telling you to go to hell. If you want to pretend that pomposity stopped you from getting what you want, when it was really that you didn't want to work, then that's your choice.

It takes hard, hard, hard, hard, hard work to get to be very good at computing, or surgery, lawyering, quarterbacking, training seals, winning battles, dealing crack. If you don't want to work, then you don't want to get the reward.

A point I'll be covering in my upcoming book series, starting with "Get Rich Slowly By Busting Your Ass". I always said, why compete with a hundred publishing companies for 1% slice of 80% of the market, when I can take this tack and corner 20%? The hell with telling people lies just because they sound good. We didn't build the Internet for that. You want a soothing fantasy to escape into, go watch TV.

If you're about to comment, and you don't like me, it's because I'm saying the word you don't want to hear. Don't feel like the Lone Ranger. 80% of the people hate that word 'work' - it bruises their insides. But it's what is keeping them from being in the 20%.

Man, it takes me right back to the Fish Cheer! What's that spell? W-O-R-K!!!

Bob Dobbs approves!

Edit: I just wanted to add: It is the position of people like me to point out the natural laws of the universe. The awful, soul-sucking, vile, wretched scum of the Earth have the reciprocal job of making us suffer as much as they can for trying. Each of us do what nature created us to do.

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

Slowly Making Friends With The New Gimp

Date/Time Permalink: 11/10/07 10:52:08 am
Category: HOWTOs and Guides

What's driving me to put Gimp 2.4 on my Slackware box (my main office) is that I can never again do a Gimp tutorial until I am set up with 2.4. The interface overhaul is just too massive; every Gimp tutorial currently published in print or the web has now become worthless.

It's things like this that held me back from mastering Blender; I was just getting pretty good with it, when they rebuilt it. At least half the tutorials out there for Blender even now make references to buttons that no longer exist and menu paths that have changed. Hopefully, the Gimp community can handle itself better. For anybody who asks, I will be putting a header on each of my own Gimp tutorials specifying that they are for 2.2.

Anyway, I'm running Slackware 11.0, having just dialed in the perfect distro setup as I reviewed here. This may come as a shock, but I don't keep current on my main work station. I apply the Debian philosophy; I want long-term stability, because there is so much that is so complicated that I do, that getting it all set up takes something like a month. I was prepared to never upgrade the main system again for at least another year.

But with my work, Gimp pretty much controls at least 33% of my paycheck (no matter if I drew something in Inkscape or POVray, I still use Gimp for post-process and such.), so oh well, upgrade Gimp. The only Slackware package for Gimp 2.4 I could find was one for i486 (over at Linux packages), so that's what I settled for. Then when I got that in, Gimp informed me that it needed GTK+2-2.10.13 or later. I "arghh!"ed and went to hunt that down, but happily my upgrades ended there where 2.10.14 for i686 installed without incident.

Unfortunately, Gimp is not running without incident. I have so far detected three operations which make it crash (!?!?). They are: using the lasso (free-select) for anything, attempting to stroke a path, and using the gfig plugin. So I go back to the site and guess what? They just released the bug-fix as 2.4.1, and the change-log mentions several stability issues including crashing when using plug-ins. Which will fix my problems nicely... just as soon as I locate the Slackware package for it! Which, as I write this, I just did... Slackware current has it, but don't bother using the site search (on the left); it's on the recent packages list (on the right).

Since everybody's going to ask: I'm not looking at the tarball because I don't think my system is ready to compile a huge package like the Gimp. There's other complications like the fact that I use Dropline for Gnome support, so this has potential problems with little library and method inconsistencies that I'd rather avoid. Dropline hasn't even released for Slackware 12.0 yet.

As a side mystery, Gimp 2.4's release candidate on my kids' Mandriva box is running tip-top, no problems at all. So now are these problems actually caused by a botched set-up on my own box? In any case, I can't go hopping back and forth between two computers and nudging my kids off their game just to use a stable Gimp. While puttering around last night, I did manage to draw a decent shield in 2.4:

A Slackware shield

I've been fascinated by shields lately. I'd like to say that I drew it all in Gimp, but I did the shield shape (just the outline) in Inkscape and exported to PNG because - duh! - Gimp's path tool crashes when I try to stroke a path. If my images look pretty busy going forward for this month, it's because I'm doing them as in-depth feature tests.

The 2.4.1 upgrade should fix things up, and my computing world will be at peace again. I just cough all this up to let people know, if anybody else out there is having these little frustrations, it's not just them.

Update: No, they didn't. Lasso, stroking a path, and gfig drawing a polygon all still make Gimp 2.4.1 vanish like a popped soap bubble. I have no idea what the problem is.

Why was I born?

Update: Well, I tried one thing and then another, but finally uninstalled Gimp, manually removed every trace of Gimp from the machine, and reinstalled the original Gimp-2.2.13 from my Slackware 11.0 diskset, plus untarred the .gimp/ configurations back to my home directory (which I'd thought to tar up and save before trying to upgrade). Happy ending: everything's back as it was.

I could piddle around all year with this, but like I said I need this for work. I have 2.4 running happy and fine on the other machine (why???) if I need it, and I'm sticking with 2.2.13 on this box until the next major upgrade. I have GTK+ upgraded as a souvenir.

I'll try again to make friends with the new Gimp when it's settled down.

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

My 'lil' FreeBSD Notebook

Date/Time Permalink: 10/06/07 01:04:59 pm
Category: HOWTOs and Guides

New to BSD from Linux? Welcome to the outback! BSD is going to feel like a TV commercial that goes: "We've secretly replaced this geek's Linux with BSD - let's see how long it takes to notice!" Herein is a random little list of notes I'm leaving along the way, as I venture into the depths of BSD:

NOTE: BEFORE YOU COMMENT The computer I installed FreeBSD to is OFFLINE. It has no Internet connection. For very, very good reasons. If you leave me a comment on this post to the effect of me being an idiot who doesn't connect to the site and use ports, I WILL make fun of you! Don't let me do that.

My 'lil' FreeBSD Notebook

Console tip: The mouse in BSD is an actual mouse pointer graphic, and you can use it to snarf and paste text. Just click and drag over the text you want to copy, which will store it in the "clipboard". Then middle-click to paste it elsewhere. Exactly like in Linux (given the right setup).

You've gotten your desktop up and hit Ctrl-Alt-F2 to get to a console. Which key do you hit to get back to the desktop? Alt-F9. This is because you get 8 tty's in BSD, as opposed to 6 in Linux.

How do you get a Bash shell? First, "cat /etc/shells" to make sure you have Bash installed. It will probably be /usr/local/bin/bash. The command to change shells is "chsh -s /usr/local/bin/bash".

GNU users: Your (and mine) precious Emacs (M-x praise-be-unto-emacs) is available in the individual package section on the disks and will work fine on FreeBSD. Once you have Bash going, set Emacs as your editor with "export EDITOR='/usr/local/bin/emacs'" and $EDITOR will be used properly.

By the way, I'm not out to discourage anybody from discovering the wonders of more BSD-like shells and editors. While a Linux user is learning BSD, it's better to have Bash and one of vi/Emacs nearby while they explore. But FreeBSD has ee (an editor), and I tried it out and it will take you only seconds to learn, since every command is printed right at the top! And sh is a shell, itself in BSD, not a softlink to another shell!

Where the heck can you get binary packages? From the ports packages collection. The command to install is "pkg_add".

I was practicing installing packages (since the BSD box has no Internet) via floppy (retarded, I know) and picked 'freebsd-games.tgz'. That installed fine, but then I tried to start Rogue and it complained about a missing library ( First, I went looking for the package on the install CDs, but didn't find it. Then I checked /usr/lib, and there's So, I go root, cd /usr/lib, and made a link: "ln -s". Did the same for " -$gt;". Rogue ran. § Oh look, look. See Rogue run. Run, Rogue, run!

Floppy disks: I'm puzzled, because the ext2 floppy that I copied a file to in Slackware seemed to be fine, but gave FreeBSD heartburn - it complained of bad superblocks and wouldn't mount. I remounted it on Slackware - no problem. Either BSD is too picky or Slackware is slacking. A different ext2 floppy worked fine, as did a DOS floppy. Perhaps BSD is not as sloppy about file system integrity as Linux?

Mounting: If you have a shell with TAB-completion, try typing "mount" and then hitting TAB twice. Wheeee, look at all the programs! BSD seems to prefer keeping binary programs specialized to mount each file system. To mount an ext2 floppy it's "mount_ext2fs /dev/fd0 /mnt". For a DOS floppy it's "mount_msdosfs /dev/fd0 /mnt". And so on...

Docs: Besides man pages, the system documentation is in /usr/share/doc/, and it comes in two flavors: articles and books. You practically have a mini-Wikipedia in here. They are divided into folders by language. The majority of them are in HTML format, so you'll want to install a web browser first. Observation: lynx looks better in BSD than it does in Linux. Observation #2: Look for /new_users/index.html in the /articles/ directory here for a great, brief tutorial on day-to-day usage; this is easy to understand even if you're new to Unix systems in general. Observation #3: The 'BSD Funnies' is waiting for you, in the FAQ book, and it's funnier than anything in /usr/share/emacs/etc/.

Q: In Linux, you can scroll back through a few pages of console history with "shift-PgUp". How do you do this in FreeBSD? A: Hit the "Scroll-Lock" key and then use the arrows to scroll up and down much as you would in vi. This is actually a lot cooler than in Linux, because buffers viewed in 'man', 'emacs', and 'lynx' will all show up, along with past command output. This makes it much easier to gather facts from several documents together, for pasting quotes into one file, for instance.


         _~             ~_
        /                 \
       ~                   ~
      /                     \
      |    XXXX     XXXX    |
      |    XXXX     XXXX    |
      |    XXX       XXX    |
       \         @         /
        --\     @@@     /--
         | |    @@@    | |
         | |           | |
         | vvVvvvvvvvVvv |
         |  ^^^^^^^^^^^  |
          \_           _/
           Penguin Pete
  Killed by a mob of FreeBSD zealots
           with 14 gold

UPDATE: Oh, and I just found the "gotchas" for Linux users at the FreeBSD Wiki.

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

<< Previous Page :: Next Page >>
suddenly the moon