Hide

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.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands using ssh from sorted by
Terminal - Commands using ssh - 286 results
ssh -T user@server < script.sh
2011-01-10 20:09:55
User: dlebauer
Functions: ssh
4

Run local scripts on remote server. "-T Disable pseudo-tty allocation"

ssh -R 5497:127.0.0.1:22 -p 62220 user@public.ip
2010-12-29 18:44:59
User: pescio
Functions: ssh
9

host B (you) redirects a modem port (62220) to his local ssh.

host A is a remote machine (the ones that issues the ssh cmd).

once connected port 5497 is in listening mode on host B.

host B just do a

ssh 127.0.0.1 -p 5497 -l user

and reaches the remote host'ssh. This can be used also for vnc and so on.

ssh -f -L 5900:localhost:5900 your.ssh.server "x11vnc -safer -localhost -nopw -once -display :0"; vinagre localhost:5900
2010-12-29 08:41:10
User: johnquail
Functions: ssh
20

This command

1. SSH into a machine

2. Tunnels VNC port to your local computer ("-L 5900:localhost:5900")

3. Runs a single use vnc server ("x11vnc -safer -localhost -nopw -once -display :0")

4. Goes into the background ("-f")

5. Runs VNC viewer on the local computer connecting to the remote machine via the newly created SSH tunnel ("vinagre localhost:5900")

infocmp rxvt-unicode | ssh 10.20.30.40 "mkdir -p .terminfo && cat >/tmp/ti && tic /tmp/ti"
2010-12-29 00:44:49
User: mhs
Functions: ssh
Tags: terminfo
3

I frequently use this trick to send my terminal settings to HPUX and older RHEL systems. This is due to the fact that terminfo support for rxvt-unicode (my preferred terminal app) does not exist on many older Linux and Unices.

dd if=mfsbsd.iso | ssh distant.server dd of=/dev/sda
2010-12-23 09:34:33
User: gormux
Functions: dd ssh
5

Install a basic FreeBSD system on a distant server. I use this to install FreeBSD on servers that can only boot a Linux rescue system. This sytem loads on ram when booted, so it is possible to install freely. You can even install on ZFS root !

tar -czvf - /src/dir | ssh remotehost "(cd /dst/dir ; tar -xzvf -)"
ssh-keygen -l -f ~/.ssh/known_hosts
2010-12-05 04:03:07
User: atoponce
Functions: ssh ssh-keygen
Tags: ssh
10

Will return the SSH server key information for each host you have in your ~/.ssh/known_hosts file, including key size, key fingerprint, key IP address or domain name, and key type.

ssh -fND localhost:PORT USER@SSH_ENABLED_SERVER
2010-12-01 14:42:13
User: 2dvisio
Functions: ssh
4

Create a persistent remote Proxy server through an SSH channel.

ssh root@host1 ?cd /somedir/tocopy/ && tar -cf ? .? | ssh root@host2 ?cd /samedir/tocopyto/ && tar -xf -?
command | ssh myHost xsel -i --display :0
2010-11-23 19:59:22
User: wincus
Functions: command ssh
Tags: ssh bash xsel
1

This command will copy command's output into your local clipboard

ssh root@HOST tcpdump -U -s0 -w - 'not port 22' | wireshark -k -i -
2010-10-28 09:02:39
User: abb
Functions: ssh tcpdump
10

When using tcpdump, specify -U option to prevent buffering.

tar cfX - exclude_opt_weblogic . | ssh tmp-esxsb044 "cd /opt/weblogic ; tar xf -"
diff <(ssh user@host1 cat /path/to/file) <(ssh user@host2 cat /path/to/file2)
ssh user@remoteserver "PGPASSWORD='passwd' pg_dump -U user bd_name | bzip2 -zv9" | bzcat | psql -U user bd_name
ssh user@host 'gunzip - > file' < file.gz
2010-09-20 14:04:47
User: putnamhill
Functions: ssh
Tags: ssh gunzip
3

This version transfers gzipped data which is unzipped as it arrives at the remote host.

gzip -cd file.gz | ssh user@host 'dd of=~/file'
2010-09-20 11:44:19
User: twfcc
Functions: gzip ssh
-3

It is an easy method unzip a file and copy it to remote machine. No unziped file on local hard drive

ssh root@192.168.0.1 "cd /;nice -n 10 tar cvpP ?exclude={"/proc/*","/sys*","/tmp/*","/home/user/*"} /">backup.tar.gz
ssh user@remote 'cat >> ~/.ssh/authorized_keys2' < ~/.ssh/id_rsa.pub
echo "uptime" | tee >(ssh host1) >(ssh host2) >(ssh host3)
ssh user@host 'tar -c --use-compress-prog=pbzip2 /<dir>/<subdir>' > <localfile>.tar.bz2
tar -cf - ./file | lzma -c | ssh user@sshserver $(cd /tmp; tar --lzma -xf -)
tar cvzf - /wwwdata | ssh root@IP "dd of=/backup/wwwdata.tar.gz"
file=ftp://ftp.gimp.org/pub/gimp/v2.6/gimp-2.6.10.tar.bz2; ssh server "wget $file -O -" > $PWD/${file##*/}
2010-08-02 15:59:45
User: michaelmior
Functions: file ssh
Tags: ssh bash download
2

This command will download $file via server. I've used this when FTP was broken at the office and I needed to download some software packages.

curl -L -s `curl -s [http://podcast.com/show.rss]` | xmlstarlet sel -t -m "//enclosure[1]" -v "@url" -n | head -n 1` | ssh -t [user]@[host] "mpg123 -"
2010-07-31 00:17:47
User: denzuko
Functions: head ssh
0

Gets the latest podcast show from from your favorite Podcast. Uses curl and xmlstarlet.

Make sure you change out the items between brackets.

curl -L -s `curl -s http://www.2600.com/oth-broadband.xml` | xmlstarlet sel -t -m "//enclosure[1]" -v "@url" -n | head -n 1` | ssh -t [user]@[host] "mpg123 -"
0

Ever wanted to stream your favorite podcast across the network, well now you can.

This command will parse the iTunes enabled podcast and stream the latest episode across the network through ssh encryption.