Top Ten One-Liners from CommandLineFu

Mar 18 2010

Peteris Krumins has done a great job on “Top Ten One-Liners from CommandLineFu Explained”. Here’s my short summary for quick reference:

#1. Run the last command as root

$ sudo !!

#2. Serve the current directory at http://localhost:8000/

$ python -m SimpleHTTPServer

#3. Save a file you edited in vim without the needed permissions

:w !sudo tee %

#4. Change to the previous working directory

$ cd -

#5. Run the previous shell command but replace string “foo” with “bar”

$ ^foo^bar^

#6. Quickly backup or copy a file

$ cp filename{,.bak}

#7. mtr – traceroute and ping combined

$ mtr

#8. Find the last command that begins with “whatever,” but avoid running it

$ !whatever:p

#9. Copy your public-key to remote-machine for public-key authentication

$ ssh-copy-id remote-machine

#10. Capture video of a linux desktop

$ ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg

That’s it.

No responses yet

Leave a Reply