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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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

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

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
scp filename [email protected]:`pwd`
2011-10-29 07:12:17
User: shadus
Functions: scp

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

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

(port 2202)

scp ~/.ssh/id_rsa.pub [email protected]:.ssh/authorized_keys
2010-08-25 23:24:09
User: CharlieInCO
Functions: scp

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

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 /path/to/backup.sql
2010-02-15 12:39:46
User: OJM
Functions: scp

-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

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

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

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

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

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

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

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