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 - 303 results
ssh USER@HOST cat REMOTE_FILE.mp4 | tee LOCAL_FILE.mp4 | mplayer -
2013-11-28 11:25:26
User: flatcap
Functions: cat ssh tee

Securely stream a file from a remote server (and save it locally).

Useful if you're impatient and want to watch a movie immediately and download it at the same time without using extra bandwidth.

This is an extension of snipertyler's idea.

Note: This command uses an encrypted connection, unlike the original.

for k in `seq -w 1 50` ; do ssh 192.168.100.$k uptime ; done
complete -o default -o nospace -W "$(grep -i -e '^host ' ~/.ssh/config | awk '{print substr($0, index($0,$2))}' ORS=' ')" ssh scp sftp
2013-11-19 14:44:41
User: Wamith
Functions: scp ssh

I sue this in my .bashrc file

This will also do auto-completion for scp and sftp

ssh remoteUser@remoteHost "tail -f /var/log/scs/remoteLogName" | tee localLogName
ssh -o ProxyCommand='nc -x ProxyHost:8080 %h %p' TargetHost
2013-08-19 13:08:19
User: UnixSage
Functions: ssh

If you are blocked or need to use a Socks proxy

colordiff <(ssh user@host cat /etc/ssh/sshd_config) /etc/ssh/sshd_config
ssh user@remotehost "find basedir -type d" | xargs -I {} -t mkdir -p {}
2013-07-17 07:14:32
User: neomefistox
Functions: mkdir ssh xargs

The directories are created in the local host with the same structure below of a remote base directory, including the 'basedir' in case that it does not exists.

You must replace user and remotehost (or IP address) with your proper values

ssh will ask for the password of the user in remotehost, unless you had included properly your hostname in the remote .ssh/known_hosts file.

ssh() { [ $TERM == screen ] && (screen -X title "${1##*@}"; command ssh "$@"; screen -X title '';exit;) || command ssh "$@"; }
2013-06-03 12:31:05
User: djkadu
Functions: command screen ssh

By adding this to your bashrc, when SSH'ing to a server while screen is active it will change the window tittle to the name of the server you going to.

SSHPASS='your_password' sshpass -e ssh [email protected]
2013-06-03 12:26:40
User: djkadu
Functions: ssh

The above is OK if you not worried about security, as per sshpass man pages:

" The -p option should be considered the least secure of all of sshpass's options. All system users can see the password in the command line with a simple "ps" command."

So, instead what I do is use the -e option:

" -e The password is taken from the environment variable "SSHPASS"."

wmr - | pv -s $SIZEOFMEM | ssh -p 40004 -c arcfour,blowfish-cbc -C [email protected] "cat - > /forensics/T430-8gb-RAM1.dd"
2013-05-31 00:04:19
User: bhbmaster
Functions: ssh

wmr - | pv -s $SIZEOFMEM | ssh -p 40004 -c arcfour,blowfish-cbc -C [email protected] "cat - > /forensics/T430-8gb-RAM1.dd"

Run above command from Windows Cygwin:

On Windows: Install Cygwin, and copy WMR (windows memory reader 1.0) memory diagnostic into cygwin\bin folder, also install cygwins netcat and ssh (openssh). I recommend installing apt-cyg and running "

On Linux: Have an SSH Server


WINDOWS: # wmr - | ssh [email protected] "cat - > /tmp/FileToSave.dd"

For more details on how to extract information from memory dump:

apt-get install foremost

foremost -t all -T -i /forensics/T430-8gb-RAM1.dd

For more information:


tcpdump -i eth0 -w - | ssh forge.remotehost.com -c arcfour,blowfish-cbc -C -p 50005 "cat - | gzip > /tmp/eth0.pcap.gz"
2013-05-30 07:41:22
User: bhbmaster
Functions: ssh tcpdump
Tags: ssh tcpdump gzip

NOTE: When opening the files you might need to strip the very top line with notepad++ as its a mistake header

This is useful when the local machine where you need to do the packet capture with tcpdump doesn?t have enough room to save the file, where as your remote host does

tcpdump -i eth0 -w - | ssh forge.remotehost.com -c arcfour,blowfish-cbc -C -p 50005 "cat - | gzip > /tmp/eth0.pcap.gz"

Your @ PC1 doing a tcpdump of PC1s eth0 interface and its going to save the output @ PC2 who is called save.location.com to a file /tmp/eth0-to-me.pcap.gz again on PC2

More info @: http://www.kossboss.com/linuxtcpdump1

tcpdump -i eth0 -w - | ssh savelocation.com -c arcfour,blowfish-cbc -C -p 50005 "cat - > /tmp/eth0.pcap"
2013-05-30 07:33:48
User: bhbmaster
Functions: ssh tcpdump
Tags: ssh tcpdump

This is useful when the local machine where you need to do the packet capture with tcpdump doesn?t have enough room to save the file, where as your remote host does

tcpdump -i eth0 -w - | ssh savelocation.com -c arcfour,blowfish-cbc -C -p 50005 "cat - > /tmp/eth0.pcap"

Your @ PC1 doing a tcpdump of PC1s eth0 interface and its going to save the output @ PC2 who is called save.location.com to a file /tmp/ppp1-to-me.pcap.gz again on PC2

More info @: http://www.kossboss.com/linuxtcpdump1

cd /srcfolder; tar -czf - . | pv -s `du -sb . | awk '{print $1}'` | ssh -c arcfour,blowfish-cbc -p 50005 [email protected] "tar -xzvf - -C /dstfolder"
2013-05-30 07:21:06
User: bhbmaster
Functions: awk cd ssh tar
Tags: ssh tar pv

NOTE: When doing these commands when asked for questions there might be flowing text from the pv doing the progress bar just continue typing as if its not there, close your eyes if it helps, there might be a yes or no question, type "yes" and ENTER to it, and also it will ask for a password, just put in your password and ENTER

I talk alot more about this and alot of other variations of this command on my site:


cat filein | ssh destination.com -c arcfour,blowfish-cbc -C -p 50005 "cat - > /tmp/fileout"
2013-05-30 07:18:46
User: bhbmaster
Functions: cat ssh
Tags: cat ssh

Where filein is the source file, destination.com is the ssh server im copying the file to, -c arcfour,blowfish-cbc is selecting the fastest encryption engines, -C is for online compressions and decompression when it comes off the line - supposed to speed up tx in some cases, then the /tmp/fileout is how the file is saved...

I talk more about it on my site, where there is more room to talk about this:




sshpass -p "YOUR_PASSWORD" ssh -o StrictHostKeyChecking=no YOUR_USERNAME@SOME_SITE.COM
2013-05-24 14:33:38
User: o0110o
Functions: ssh

You need to install "sshpass" for this to work.

apt-get install sshpass

diff /path/to/localfile <(ssh user@host cat /path/to/remotefile)
2013-05-24 09:24:31
User: mc0e
Functions: cat diff ssh

Or, if you have restricted access for sftp only, I think you can still do this:

diff /path/to/localfile <(scp user@host:/path/to/remotefile >(cat))
ssh -q ${SRC_HOST} "mysqldump --add-drop-database --create-options --databases wordpress | sed -r \"s/${OLD_URL}/${NEW_URL}/g\" | gzip -9" | ssh ${DST_HOST} "gunzip | mysql"
ssh -X -l user
2013-04-30 13:48:28
User: xmuda
Functions: ssh

One time you logged in, you can prove these method just writing "firefox".

ssh user@remote "tar cfp - /path/to/log/* | gzip" > local.tar.gz
ssh [email protected] "DISPLAY=:0.0 import -window root png:-" | open -a /Applications/Preview.app -f
2013-04-14 23:52:53
User: yuumei
Functions: ssh

Takes a screenshot of x11 and pipes it over ssh to the preview application on a mac. Requires imagemagick on the server side.

parallel -j 50 ssh {} "ls" ::: host1 host2 hostn | sort | uniq -c
2013-04-12 11:56:41
User: macoda
Functions: sort ssh uniq

parallel can be installed on your central node and can be used to run a command multiple times.

In this example, multiple ssh connections are used to run commands. (-j is the number of jobs to run at the same time). The result can then be piped to commands to perform the "reduce" stage. (sort then uniq in this example).

This example assumes "keyless ssh login" has been set up between the central node and all machines in the cluster.

bashreduce may also do what you want.

sxh () { for i in "${@:2}"; do ssh "$i" "$1"; done ; }
2013-04-12 11:34:02
User: zlemini
Functions: ssh

Oneliner to run commands on multiple servers over ssh.

- First parameter "$1" is the command you want to execute remotely.

( It can be multiple commands e.g. "hostname;uptime")

- Second parameter "${@:2}" represents the remote host/s you want to run the command/s on.

ssh -t myserver.org 'sudo ls /etc'
2013-04-09 04:23:37
User: patko
Functions: ls ssh
Tags: ssh sudo

This command will ask for remote sudo password before executing a remote command.

ssh [email protected] -i my_openssh_key.ssh -p 9999
2013-03-10 12:37:19
User: motopig
Functions: ssh

use .ssh file to login the server

ssh <remoteuser>@<remoteserver> \ 'mysqldump -u <user> -p<password> <database>' \ | mysql -u <user> -p<password> <database>
2013-03-05 19:20:52
User: kvcrawford
Functions: ssh
Tags: mysql ssh sync

There must be no space between -p and the password