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 scp from sorted by
Terminal - Commands using scp - 26 results
scp -r `ls | grep -vE "(Pattern1|Pattern2)"` user@remote_host:/location
scp username@computer:"path/To/File1 path/To/File2" destination/
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
0

I sue this in my .bashrc file

This will also do auto-completion for scp and sftp

scp user@hostname:/remotedir/file.name /localdir
scp username@host|ipaddress:/directory/path .
2013-10-23 12:35:18
User: Dhinesh
Functions: scp
Tags: scp
0

scp username@192.168.1.22:/directory/path .

Get the file from the remote system

while :; do n=$(md5 myfile); if [ "$h" != "$n" ]; then h=$n; scp myfile myserver:mydir/myfile; fi; sleep 1; done
sudo scp <file or folder> <name of pc 1>@<IP of pc 2>:
scp -l username -pw pa33w0rd file.txt 192.168.1.2:/path/to/dir
scp filename root@remote:`pwd`
2011-10-29 07:12:17
User: shadus
Functions: scp
3

This will copy a file from your current directory to the same location on another machine. Handy for configuring ha, copying your resolv.conf, .bashrc, anything in /usr/local, etc.

scp -P 1837 <path_to_loca_file> <remote_user>@<remote_ip>:<remote_ip>
2011-08-31 13:08:16
User: tkembo
Functions: scp
-10

when ssh is running on a different port

scp -i /path/to/file.pem [local-files] root@[dest-host]:[dest-path]
scp -P 2202 /$filelocation user@host:/$final/$location
2011-04-14 02:08:06
User: mancipar
Functions: scp
-10
scp

(port 2202)

scp ~/.ssh/id_rsa.pub user@remote:.ssh/authorized_keys
2010-08-25 23:24:09
User: CharlieInCO
Functions: scp
-16

Simply copies your public key to the remote system. For the first time, this will require a password for the user@remote account. From then on, ssh will ask for your private key keyphrase occasionally but you won't need to use the password. Very handy when you're moving files for testing etc.

scp $user@$server:$path/to/file .
scp -l10 pippo@serverciccio:/home/zutaniddu/* .
2010-02-19 16:44:24
User: 0disse0
Functions: scp
Tags: ssh scp bandwidth
11

the command is obvious, I know, but maybe not everyone knows that using the parameter "-l" you can limit the use of bandwidth command scp.

In this example fetch all files from the directory zutaniddu and I copy them locally using only 10 Kbs

scp -C 10.0.0.4:/tmp/backup.sql /path/to/backup.sql
2010-02-15 12:39:46
User: OJM
Functions: scp
9

-C is for compression.

scp /home/svnlabs.txt root@92.178.0.56:/home/
scp -P 22 /home/svnlabs.txt root@92.178.0.56:/home/svnlabs.txt
2010-01-22 17:21:07
User: lalit241
Functions: scp
Tags: a2zfa file cop
-9

Upload file to remote server using SCP

scp -P 22 /home/svnlabs.txt root@92.178.0.56:/home/svnlabs.txt
2010-01-22 16:55:25
User: svnlabs
Functions: scp
-6

Upload file to remote server using SCP

for i in `seq 1 3`; do scp finku@server$i:file.txt server$i-file.txt; done
mecp () { scp "$@" ${SSH_CLIENT%% *}:Desktop/; }
2009-06-11 00:43:08
User: braino
Functions: scp
Tags: scp
9

Place in .bashrc and invoke like this: "mecp /path/to/file", and it will copy the specified file(s) back to the desktop of the host you're ssh'ing in from. To easily upload a file from the host you're ssh'ing in from use this:

ucp (){ scp ${SSH_CLIENT%% *}:Desktop/upload/* .; }

FILE="`date +%m%d%H%M%S`.png"; URL="http://YOUR_HOST/YOUR/PATH/$FILE"; TMP="/tmp/$FILE"; import -frame $TMP; scp $TMP YOUR-USER@YOUR-HOST:/YOUR/PATH/; rm $TMP; firefox "$URL"
2009-02-21 18:42:33
User: TheBunman
Functions: rm scp
2

I often need to send screenshots to other people to explain settings and whatever.

So I created this oneline which I use to create the screenshot with imagemagik, upload it via scp to my server and then the command opens an firefox tab with the screenshot.

The screenshot can be a region or a window.

You just have to replace the parts beginning with YOUR.

scp user@hostb:file user@hostc:
2009-02-16 18:33:08
User: drossman
Functions: scp
8

While at the command line of of hosta, scp a file from remote hostb to remote hostc. This saves the step of logging into hostb and then issuing the scp command to hostc.

for h in host1 host2 host3 host4 ; { scp file user@$h:/destination_path/ ; }
2009-02-16 01:02:35
Functions: file scp
7

Just a quick and simple one to demonstrate Bash For loop. Copies 'file' to multiple ssh hosts.

find <dir> -type f -mtime +<days> -exec scp -r {} user@backuphost:/data/bkup \;
2009-02-12 07:43:29
User: rbattu
Functions: find scp
-1

U have to make key exchange in order to avoid continuous password prompt.