What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





Commands using ssh from sorted by
Terminal - Commands using ssh - 302 results
mysqldump -uUserName -pPassword tudb | ssh root@rootsvr.com "mysql -uUserName -pPassword -h mysql.rootsvr.com YourDBName"
2009-02-17 22:36:06
User: elecboy
Functions: ssh

This option makes a copy of your current db and via ssh it transfer to the server you specify and upload the database to the specific User & Password you specify (Note the db User & Pass, can be different from the one you use in the other server)

If you are going to use "localhost" as your main db remove (-h) and youst add "localhost"

mysqldump --add-drop-table --extended-insert --force --log-error=error.log -uUSER -pPASS OLD_DB_NAME | ssh -C user@newhost "mysql -uUSER -pPASS NEW_DB_NAME"
2009-02-17 17:57:53
User: Tscherno
Functions: ssh

Dumps a MySQL database over a compressed SSH tunnel and uses it as input to mysql - i think that is the fastest and best way to migrate a DB to a new server!

ssh -CNL 3306:localhost:3306 user@site.com
ssh -D 8888 user@site.com
2009-02-17 15:34:27
User: wesrog
Functions: ssh

Simply change your web browser's proxy settings to point to a SOCKS proxy at port 8888 and you're good to go.

ssh-copy-id username@hostname
cat ~/.ssh/*.pub | ssh user@remote-system 'umask 077; cat >>.ssh/authorized_keys'
ssh -L 5900:localhost:5900 user@exampleserver.com
2009-02-13 04:53:27
User: Jackie
Functions: ssh

Foward vnc securely from exampleserver.com

cat .ssh/id_rsa.pub | ssh hostname 'cat >> .ssh/authorized_keys'
2009-02-11 17:40:12
User: bendavis78
Functions: cat hostname ssh

Just run the command, type your password, and that's the last time you need to enter your password for that server.

This assumes that the server supports publickey authentication. Also, the permissions on your home dir are 755, and the permissions on your .ssh dir are 700 (local and remote).

dd if=/dev/zero bs=1M | ssh somesite dd of=/dev/null
while [ ! -f /tmp/stop ]; do ssh -o ExitOnForwardFailure=yes -R 2222:localhost:22 target "while nc -zv localhost 2222; do sleep 5; done"; sleep 5;done
diff <(ssh nx915000 "rpm -qa") <(ssh nx915001 "rpm -qa")
echo -n m{1..5}.cluster.net | xargs -d' ' -n1 -P5 -I{} ssh {} 'uptime'
dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp
2009-02-08 10:10:00
User: morpheus
Functions: dd ssh

This will output the sound from your microphone port to the ssh target computer's speaker port. The sound quality is very bad, so you will hear a lot of hissing.

tar -cvzf - /source/path | ssh <targethostname> -l <username> dd of=/destination/path/backupfile.tgz
2009-02-06 15:52:09
User: smm
Functions: dd ssh tar

Creates a quick backup with tar to a remote host over ssh.

ssh -N -L2001:localhost:80 -o "ProxyCommand ssh someuser@hubmachine nc -w 5 %h %p" someuser@destinationmachine
2009-02-06 09:58:08
Functions: ssh

this is handy when the hubmachine is the only machine that can connect to the destination machine (allowed on ip by firewall) and you want to access it from your laptop.

cat ~/.ssh/id_rsa.pub | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
2009-02-05 19:37:56
User: DEinspanjer
Functions: cat ssh

If you use Mac OS X or some other *nix variant that doesn't come with ssh-copy-id, this one-liner will allow you to add your public key to a remote machine so you can subsequently ssh to that machine without a password.

ssh-keygen -l -f [pubkey] | awk '{print $2}' | tr -ds ':' '' | egrep -ie "[a-f0-9]{32}"
ssh-keygen -i -f $sshkeysfile >> authorized_keys
dump 0f - / | bzip -c9 | ssh user@host "cat > /home/user/root.dump.bz2"
2009-02-05 17:22:32
User: wwest4
Functions: dump ssh

...can do similar w/ tar, dd, xfsdump, e2fsdump, etc.

vimdiff tera.py <(ssh -A testserver "cat tera.py")
ssh-keygen -R \[localhost\]:8022
2009-02-05 11:48:09
User: Sekenre
Functions: ssh ssh-keygen

Useful if you have to tunnel ssh through a local port and it complains of the host key being different. Much easier than manually editing the file.

ping localip -c 1 -W 1 &> /dev/null && ssh localip || ssh globalip
2009-02-05 10:40:26
User: trey
Functions: ping ssh

Ping machine once, waiting 1 second for response until failing. Upon fail, ssh globally, otherwise ssh locally.

ssh -N -L2001:localhost:80 somemachine
ssh somemachine "cd some dir; tar zcpf - somedirname" |tar zxpf -
ssh user@host cat /path/to/remotefile | diff /path/to/localfile -
2009-02-04 11:33:19
User: root
Functions: cat diff ssh

Useful for checking if there are differences between local and remote files.