Commandlinefu is a very interesting website,it collects Command-line gems.You can join in and share yours!

Here are the most popular 10 commands from this site:

sudo !!

Run the last command as root!
it’s very useful,when you execute a command and it tells you that permission denied or don’t have privilege.You can just type this to run again as root.

python -m SimpleHTTPServer

Quickly share current directory tree as HTTPServer,and other can access by type http://$HOSTNAME:8000/ in browser.Remember to replace the “$HOSTNAME”.

:w !sudo tee %

Save a file you edited in vim without the needed permissions!
When you forgot to edit a file with enough permission,you can still save the changes by this command in Vim.

cd -

change to the previous working directory


Runs previous command but replacing
Really useful for when you have a typo in a previous command. Also, arguments default to empty so if you accidentally run:
echo "no typozs"
you can correct it with

cp filename{,.bak}

Quickly backup a file to filename.bak.And mv filename{,.bak} quickly move a file to filename.bak.


mtr combines the functionality of the traceroute and ping programs in a single.


Check command history, but avoid running it
!whatever will search your command history and execute the first command that matches ‘whatever’. If you don’t feel safe doing this put :p on the end to print without executing. Recommended when running as superuser.

ssh-copy-id user@host

Copy ssh keys to user@host to enable password-less ssh logins.
To generate the keys use the command ssh-keygen

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

Capture video of a linux desktop.
it doesn’t work in my ubuntu machine,and finally I found this:

ffmpeg -f x11grab -s sxga -r 24 -i :0.0 /tmp/out.mpg