June 16, 2011
Well, not *that* interactive

I always alias rm to rm -i to prevent fat-fingered mishaps. This is usually too chatty if you try to recursively delete even a moderately big directory, so you have to go all out with rm -rf.

I get chills every time I type that little f in there and it turns out the new version of rm from GNU coreutils allows an alternate interactive mode -I that will prompt you once for all arguments. It also skips prompting altogether if you specify less than 4 files for deletion.

From the man page for rm:

If the -I or --interactive=once option is given, and there are more than three files or the -r, -R, or --recursive are given, then rm prompts the user for whether to proceed with the entire operation. If the response is not affirmative, the entire command is aborted.

11:23am  |   URL: http://tumblr.com/Zn_4by68jQ-r
Filed under: rm shell linux 
June 13, 2011
One Instruction Set Computer VM and Assembler on GitHub

I wrote this with a friend for a Computer Architecture course final project back in 2005. It is one of the first significant chunks of Java I’ve written, which shows. The concept is still interesting though.

June 11, 2011
HELO EHLO

Why is it that ubiquitous internet protocols can’t spell? HTTP’s got “referer”. SMTP has not one but two misspellings of hello.

March 4, 2011
My ideal reader is a second version of me.

The whole series is wonderful and candid snapshot of Merlin and John’s talk.

My ideal reader is a second version of me.

The whole series is wonderful and candid snapshot of Merlin and John’s talk.

February 2, 2011
"When you’re young, you look at television and think, There’s a conspiracy. The networks have conspired to dumb us down. But when you get a little older, you realize that’s not true. The networks are in business to give people exactly what they want. That’s a far more depressing thought. Conspiracy is optimistic! You can shoot the bastards! We can have a revolution! But the networks are really in business to give people what they want. It’s the truth."

— Steve Jobs in WIRED magazine, February 1996

January 26, 2011
The origin of Unix file delete permissions

Unix file permissions fall into three basic categories, read, write and execute. Which one do you think controls file deletion? It’s probably write, right? Well, let’s test it:

$ touch foo; chmod -w foo
$ ls -l foo
-r-------- 1 user group 0 2011-01-24 12:16 foo
$ rm foo
$ ls foo
ls: cannot access foo: No such file or directory

That’s weird, it looks like I successfully deleted that file. Maybe it’s governed by user/group ownership.

$ touch foo; sudo chown root:root foo
$ ls -l foo
-rw------- 1 root root 0 2011-01-24 12:18 foo
$ rm foo
$ ls foo
ls: cannot access foo: No such file or directory

I just deleted a file owned by root. WTF?

It turns out, Unix file deletion (and creation) is controlled by write access to the parent directory. Let’s demonstrate quickly:

$ mkdir test; touch test/foo
$ chmod -w test
$ rm test/foo
rm: test/foo: Permission denied

You see, each Unix file has a dedicated datastructure that stores metadata called an inode. While inodes store permissions, access/modification timestamps and other useful info, they do not track file location or name. Instead, directories map file names to inodes. The name of an inode is derived from its location. When we delete a file with the rm command, we are merely removing a directory entry. Hence, we only need write permissions to the directory in question.

You can even link to an inode from multiple directory locations with the ln command. These references are called hard links and are counted by the inode. The inode is reclaimed and the disk storage freed only when the reference count reaches zero. So not all rm operations will result in the underlying file being destroyed, which is yet another reason for file deletion being controlled by the parent directory.

12:24pm  |   URL: http://tumblr.com/Zn_4by2lOCTj
  
Filed under: unix files security 
January 5, 2011
Apparently the iPhone also has a universal orientation lock like the iPad. Here’s how to use it:

Doube-tap the home button to view the recent apps selector.
Swipe right on the selector to reveal the iPod controls and, lo and behold, the orientation lock.
Lie in bed all morning browsing the web.
(Step 3 is optional.)

Apparently the iPhone also has a universal orientation lock like the iPad. Here’s how to use it:

  1. Doube-tap the home button to view the recent apps selector.
  2. Swipe right on the selector to reveal the iPod controls and, lo and behold, the orientation lock.
  3. Lie in bed all morning browsing the web.

(Step 3 is optional.)

Liked posts on Tumblr: More liked posts »