Top Ten One-Liners from CommandLineFu
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
1.
$
sudo
!!
#2. Serve the current directory at http://localhost:8000/
1.
$ python -m SimpleHTTPServer
#3. Save a file you edited in vim without the needed permissions
1.
:w !
sudo
tee
%
#4. Change to the previous working directory
1.
$
cd
-
#5. Run the previous shell command but replace string “foo” with “bar”
1.
$ ^foo^bar^
#6. Quickly backup or copy a file
1.
$
cp
filename{,.bak}
#7. mtr – traceroute and ping combined
1.
$ mtr google.com
#8. Find the last command that begins with “whatever,” but avoid running it
1.
$ !whatever:p
#9. Copy your public-key to remote-machine for public-key authentication
1.
$
ssh
-copy-
id
remote-machine
#10. Capture video of a linux desktop
1.
$ ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg
That’s it.