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.


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.
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

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!
Hide

Top Tags

Hide

Functions

Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Commands using scp from sorted by
Terminal - Commands using scp - 26 results
scp -r `ls | grep -vE "(Pattern1|Pattern2)"` [email protected]_host:/location
scp [email protected]:"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
1

I sue this in my .bashrc file

This will also do auto-completion for scp and sftp

scp [email protected]:/remotedir/file.name /localdir
scp [email protected]|ipaddress:/directory/path .
2013-10-23 12:35:18
User: Dhinesh
Functions: scp
Tags: scp
0

scp [email protected]:/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 [email protected]:`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 [email protected]:/$final/$location
2011-04-14 02:08:06
User: mancipar
Functions: scp
-10
scp

(port 2202)

scp ~/.ssh/id_rsa.pub [email protected]:.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 [email protected] 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 [email protected]:/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
10

-C is for compression.

scp /home/svnlabs.txt [email protected]:/home/
scp -P 22 /home/svnlabs.txt [email protected]:/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 [email protected]:/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 [email protected]$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
10

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 [email protected]:/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 [email protected]:file [email protected]:
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 {} [email protected]:/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.