• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

SCP Command in Linux with Examples

{{postValue.id}}

SCP Command

SCP stands for secure copy. This command is helpful in transferring files from remote host to the local system or from local host to remote system. It follows the SSH server for authentication and encrypted data transfer.

Files from local to remote

Here the text file file1.txt from user1 is copied remotely to user user2.

Example

[user1@linuxhelp ~]$ scp /home/user1/Desktop/file1.txt user2@192.168.7.13:/home/user2/Desktop/
user2@192.168.7.13' s password:
file1.txt                                        100%    0     0.0KB/s   00:00

This method secure to transfer the file from local to client, the output shows first they ask the password for the remote user. The entered password was wrong, then the file transfer will be terminated.

Multiple files from local to remote

SCP can be used to transfer multiple files at a time to another location either in local or remote.

Example

[user1@linuxhelp Desktop]$ scp file1.txt file2.txt file3.txt user2@192.168.7.13:/home/user2/Desktop/
user2@192.168.7.13' s password:
file1.txt                                        100%    0     0.0KB/s   00:00
file2.txt                                        100%    0     0.0KB/s   00:00
file3.txt                                        100%    0     0.0KB/s   00:00

Files from local to remote with port number

While copying the files from local to remote there may be some block in remote such as port numbers. To copy with port number -P option is used.

Example

[user1@linuxhelp ~]$ scp -P 24865 /home/user1/Desktop/file1.txt user2@192.168.7.13:/home/user2/Desktop/
user2@192.168.7.13' s password:
file1.txt                                        100%    0     0.0KB/s   00:00

If the port number is wrong or it’ s not mentioned then it returns the connection refused message.

Directories from local to remote

To copy the directory dir1 from local user1 to remote user2. Directories cannot be sent simply as files it has to be provided with -r option.

Example

[user1@linuxhelp~]$ scp -r  -P 24865 dir1 user2@192.168.7.13: /home/user2/Desktop/
user2@192.168.7.13' s password:
dir-file1                         100%   6KB  6.9KB/s   00:00    
dir-file2                          100%   3KB  3.0KB/s   00:00

Thus the directory with that of the contents is transferred to the desired location.

Copy with detailed information

While copying from local to remote or to local itself it can be done with step by step detailed information about the transferring files. For that -v option is used.

Example

[user1@linuxhelp~]$ scp -v -P 24865 file2.txt user2@192.168.7.13:/home/user2/Documents/
Executing: program /usr/bin/ssh 
host 192.168.7.13, user user3, command scp -v     -t /home/user3/Desktop/
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.7.13 [192.168.7.13] port 22.
debug1: connect to address 192.168.7.13 port 22: Connection refused
.
.
Transferred: sent 1736, received 2144 bytes, in 0.3 seconds
Bytes per second: sent 5940.0, received 7336.0
debug1: Exit status 1

Hiding the transfer details

Use -q option to hide all the status about file transfer in the terminal. It will disable all status about file transfer.

Example

[user1@linuxhelp~]$ scp -q -P 24865 file1.txt user2@192.165.7.13:/home/user2/Desktop/
user2@192.168.7.13' s password:

Displaying the transfer details

Using -p options it will display the status of the file transfer details and also it will display the file name, file transferred rate in percentage, size of file, file transfer rate and file transfer time.

Example

[user1@linuxhelp~]$ scp -p -P24865 file2.txt user2@192.165.7.13:/home/user2/Downloads/
user2@192.168.7.13' s password:
file2.txt                                        100%   16     0.0KB/s   00:00

-p option to be used to display transfer details should be in lowercase since -P is used for specifying the port numbers.

Transfer the files faster

Use option -C to speed up the transfer to save time and bandwidth. The transfer speed is depending on how many files could be compressed.

Example

[user1@linuxhelp~]$ scp -Cpv -P24865 test-dir user2@192.168.7.13:/home/user2/Desktop/

It will not works on all files, if the source file is already compressed means it will not works. File types like .zip, .rar, pictures .iso will not be affected by -C option.

Limits the bandwidth usage

One of the important option in scp is limiting the bandwidth when copying files with using option ' -l ' . The bandwidth is specified in Kbit/sec, it is nothing but file transfer speed per second.

Example

[user1@linuxhelp~]$ scp -P24865 -rl 600 new-file.txt user2@192.168.7.13:/home/user2/Documents/


e.g. If you want to transfer your file in 25 kB/sec you should mention 200 .The 200 is nothing but 25 * 8 = 200 (8 bit equal to one byte)

Here, I have used 600, so the new-file.txt file transfer rate is 75 Kb/sec.

To copy from remote to local transfer

The following command will copy the file file3.txt from remote user to local user at desktop location.

Example

[root@linuxhelp~]# scp file4.txt user2@192.168.7.13:/home/user2/Desktop/
user1@192.168.5.13' s password:


The same procedure to be followed for transferring directories from one location another location.

Multiple files from remote to local

The following command will copy the multiple files file4.txt and file5.txt from remote user to local user user2 at desktop location.

Example

[user1@linuxhelp Desktop]$ scp file4.txt file5.txt user2@192.168.7.13:/home/user2/Desktop/
user2@192.168.7.13' s password:
file4.txt                                        100%   18     0.0KB/s   00:00    
file5.txt                                        100%    0     0.0KB/s   00:00

Transfer from remote to remote

SCP helps in transferring files or directories from one remote host to another host.

Example

[root@linuxhelp Desktop]# scp user1@192.168.7.251:/home/user1/Desktop/file5.txt user2@192.165.7.13:/home/user2/Desktop/

Here, the file5.txt is transferred from 192.168.7.251 host to 192.168.7.13

Tags:
oliver
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

How to display the debug information about executing "scp" command in Linux?

A

You can use the option of "-v" with "scp" command to display the debug information about executing "scp" command in Linux. For Ex: "scp -v /src/ /dest/".

Q

How to show the estimation time and connection speed of executing the "scp" command in Linux?

A

You can use the "-p" option with "scp" command to show the estimation time and connection speed of executing the "scp" command in Linux. For Ex: "scp -p /src/ /dest/".

Q

How do I Copy files using SCP through the Proxy server in "scp" command?

A

You can use the following syntax to Copy files using SCP through the Proxy server in "scp" command. Step1: First, you need to create “~/.ssh/config” file. Step2: Second, you put this command inside it. Syntax: "ProxyCommand /src/ 0.0.0.0 8080 %h %p ~/.ssh/proxyauth" (here '8080' is port no) Step3: Then you need to create file “~/.ssh/proxyauth” which contain. "myusername:mypassword"

Q

How do I copy the file (or) directory from local system to remote system using the "scp" command?

A

You can use the following syntax to copy the file (or) directory from a local system to remote system. For Ex: "scp -v /src/ root@0.0.0.0:/dest/"

Q

Can I copy the directory in recursively from a local system to remote system using the "scp" command?

A

You can use the option of "-r" with "scp" command to copy the directory in recursively from a local system to remote system. For Ex: "scp -r /src/ user@0.0.0.0:/dest/"

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help legeek ?
Installation of the call center module

hello

I wish to install a call center in virtual with issabel, I downloaded the latest version of it , but I don' t arrive to install the call center module in issabel. please help me

thanks!

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.