David M Williams
Sunday, 08 March 2009 08:59
Opinion and Analysis
Page 2 of 3
cd –
It’s pure simplicity. It’s astounding. cd (“change directory”) is possibly one of the most well-known, one of the first-learned, maybe even the most-typed Linux command ever.
It’s pretty well known you can jump back to your home directory no matter where you are in the file system using cd ~. That saves a lot of typing.
Yet, what if you were in the bowels of, say, /var/spool or ~/Projects/chromium/src or some complex path. You cd out, but then need to return. What do you do, soldier? What do you do?
You could type the whole path again. Or, if you had looked on Command-line-fu you could type the
masterfully simple cd -
This four character instruction (five, counting the enter key) will return you right to your previous working directory.
I’m humbled to say I had never ever known this before. I’d worry this may lower my estimation in many of your eyes but I doubt I’m alone, as evidenced by the number of up-votes.
Not all commands are as simple as the two above. Others are clever, and complex, command lines which perform useful and intriguing functions.
history | awk ‘{a[$2]++}END{for(i in a){print a[i] “ “ i}}’ | sort –rn | head
may look like a keyboard explosion, but this will search through your history and list the commands you use most often. This isn’t something you’d do regularly but now you see it in print it’s one you’ll probably be keen to try out just for interest’s sake.
Nicely, the site goes out of its way to be useful in unobtrusive ways.