Some commandlinefu.com favorites

There are worse things I could be doing with my time than sifting through commandlinefu.com, looking for diamonds among the diamonds. I have a few favorites, although the word “favorite” doesn’t really make sense here; it’s more like a list of commands that, after discovering them, I’ve become emotionally attached to. In other words, these are the ones I tend to re-use most often.

sudo !!

Now to be perfectly honest, I knew this one long before I saw it at the top of that stack, so maybe it doesn’t count. In the days when I was shifting from Ubuntu to Arch, this became exceptionally helpful — and it still does. To be painfully honest, I don’t use sudo much when I’m using Arch or Crux, and so any time I jump back to Ubuntu, I find myself relying on this again.

Regardless of your opinion on the whole root-vs-sudo affair, it’s good to know that you can save yourself a little time with sudo-double-bang.

cp filename{,.bak}

This is a miracle time saver. For as many times as I’ve wanted to just duplicate a file without taking the time to type the file name over again, or tell a cumbersome graphical file manager to copy and then past the same thing … this is perfect. No more keystrokes than it takes to type out the name anyway (hooray for tab completion), plus four or five extra. Genius.

!whatever:p

With or without the :p trailer, this is a useful command. I use CTRL+R a lot to search backwards through my command history, but this is actually quicker, if I’m certain I know what that last command was.

I suppose that’s where the :p trailer comes in after all: If I’m not sure I’m grabbing the right command, I can at least check first, before executing the wrong thing. Oh, and notice that there’s no space between the “whatever” and the :p. For a little while there, I thought my system was broken. …

I’m not going to bother trickling through any others, because the site itself does a better job than I can. And if you want to know the how and why, it’s worth looking at Peter Krumins’ blog, which breaks many of them apart and inspects their shiny parts. Or something like that. … :mrgreen:

1 thought on “Some commandlinefu.com favorites

Leave a comment