Monday, April 27, 2009

How To Take Your Computer Apart

How to Take Apart a Computer -- powered by

I think it's funny that this guy prefaces this video tutorial with "Don't know why you'd want to take it apart, but..." when so many final exams in beginning computer hardware classes, like mine, involve taking apart a computer and putting it back together. (Of course, I think it's the reassembly that's the real challenge.)

Tuesday, April 14, 2009

Fun with cat

When I started learning about the Bourne shell this semester in my Intro to Linux class, I discovered cat. No, you can't get a whole book out of it, though this interview (with the accompanying proposed O'Reilly cover) was my favorite April Fool's Day joke.

However, cat is actually pretty useful. Short for "concatenation," it directs standard output of a file or a command to the terminal.
The most basic use of cat is to type the command at the bash prompt, followed by a line of text. Here's what happens:
$ cat print this line of text
print this line of text
The command line is "standard input." The line that prints out to the shell is "standard output."

Use cat to quickly view files.
OK, maybe that's not incredibly useful, at least for our purposes. But, say, what if you have a really messy home directory, with a lot of practice files? Like this:














You could go into an editor like joe or pico and open each file individually--kind of the way you have to do with most GUI word processing/text editing applications. Or you could do it much more quickly with cat:
$ cat soopersekrit
ok, here's a soopersekrit file that I'm going to copy.

seems pretty intuitive.
C-x-s saves.
That's all! I think I was trying out the joe editor with this file. Nothing to see here. But this could be really important later--say, what if you're investigating an intrusion incident and you're going through a huge number of files and directories to see if there's a nasty little rootkit script hidden away there somewhere? That can speed things up tremendously, although the security engineers I know probably use scripts that automate that process. For longer files you want to use | (pipe) and the more filter.
$ cat jeoffrey | more
This will show you a page of a file at a time--like the one above, "For I will consider my cat Jeoffry," a long, affectionate paean from harmless 18th-century religious lunatic Christopher Smart to his feline companion. (I like to use it for playing with long files, because it's a charming poem, and because it seems appropriate to use with cat.) Just press the spacebar to proceed.

Use cat to redirect output from one file into another.
You could use cp or mv to do this, but you might find cat more expedient. Here you use the redirect output symbol (>):
$ cat fun_with_cat > fun_with_cat_backup
Always be very careful with this command, though, because if you try to redirect output into an existing file, it will replace any content in that file. To safeguard against this, you can enable a feature called noclobber, which displays an error message and won't permit the command to be executed.

Use cat as an editor.

Want to get something down quickly, without leaving the command line or opening up a new shell? Just use cat to start sending input to a new file:
$cat > notes_on_cat
Things I can do with cat:

1. Preview files quickly.

2. Redirect the output from one file into another. (careful!)

3. Use cat as an editor.
When you're done, control-d saves and exits the file. But as with redirecting output, be careful that if you return to the same file that you don't end up overwriting what you've previously stored there. To pick up where you left off, use the append output symbol (>>):
$ cat >> notes_on_cat

OK, what was I saying? Cat is a very useful command.
Cat does have limitations as an editor, though--you can't go back and edit text, and you can only delete the line you're working on. So while I first attempted to draft this entry entirely in cat, I found it a wee bit impractical. But for taking notes while playing around with the Linux shell, it's incredibly useful. There are lots of other things you can do with cat involving pipes and tees and filters, but these are the three I've found most helpful lately. I'm hoping to add more of the useful things I've gleaned from my classes here--it actually provides something of a review for me and keeps me in shape as a technical communicator.

Monday, April 6, 2009

the luxury of being alone...

"For my belief is that if we live another century or so...and have five hundred a year each of us and rooms of our own; if we have the habit of freedom and the courage to write exactly what we think; if we escape a little from the common sitting–room and see human beings not always in their relation to each other but in relation to reality; and the sky, too, and the trees or whatever it may be in themselves...if we face the fact, for it is a fact, that there is no arm to cling to, but that we go alone and that our relation is to the world of reality and not only to the world of men and women, then the opportunity will come..." --Virginia Woolf, A Room Of One's Own, 1929

Right: This nine-year-old girl currently shares a bed with two little brothers in a California motel. Her parents and a baby brother have the other bed. (Credit: Monica Almeida/NY Times)

Reading this article about families displaced by the economic crisis (can we call it a depression yet?) has been causing me to reflect on one of those privileges, generally afforded more to men than to women, and far less to kids from families in straitened circumstances: private space.

It's something I've taken for granted--X and I don't have children, so we rattle around in a 2100-square-foot, four-bedroom house. When I started coursework in computer science, though, I found myself working a lot more on the Windows box in the library, which I need for two of my classes (and now use for the third, with a PutTY connection). Being down there with X and the cats was pleasant...but, I have to admit, kind of distracting. So last week, with X's blessing, I moved the library computer upstairs to my study and realized how important it was to have a dedicated workspace where I could think and concentrate without interruption.

I've discovered now that I can work--really get lost in my work--for long periods of time without getting distracted....and that I'm not lonely--just knowing that X is somewhere in the house is comforting, but I don't have to be in the same room with him.

I think, though, how lucky I've been, mostly. Growing up, I had my own room on an upper floor in my family's house, which I did not have to share with my sister. I had a desk and bookshelves, and it was quiet. My mother, like most mothers, made a lot of noises about me spending so much time in my "ivory tower," but I was (and continue to be) rather introverted, and it was a sanctuary without which I would have gone nuts. This is what I would do when I came home: walk into my clothes closet (a tiny 4 x 6 space), close the door, breathe deeply in the darkness, and emerge into my room as though it were separate in space and time from all the craziness in other parts of the house.

I think now of women and girls who no longer have rooms of their own, who live in motel rooms and with relatives, with no place to put their books or do their homework or sit quietly and think, or write. Will they again, someday? What will it do to their hopes and dreams, all this overcrowding, this lack of lockable doors? That private space, so briefly a common expectation in shared Anglo-American culture less than ten years after Virginia's death, is now more important than ever.

Project Dignity in Southern California is helping the family of the young lady in the picture pay their motel bills each month while they get back on their feet...and hopefully, give her a room of her own sometime soon.