•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Infrastructure
      • iColocation
    • Compute
      • cMetal
      • cVirtual
    • Storage
      • sObject
      • sBlock
    • Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • Protection
      • pBackup
      • pDDoS
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • new-colocation-header-img
      Infrastructure
      • iColocation
    • new-compute-header-img
      Compute
      • cMetal
      • cVirtual
    • new-storage-header-img
      Storage
      • sObject
      • sBlock
    • new-networking-header-img
      Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • new-protection-header-img
      Protection
      • pBackup
      • pDDoS
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

SCP Command Syntax Examples in Linux

  • Home
  • Client
  • Knowledgebase
  • Linux
  • SCP Command Syntax Examples in Linux

Table Of Content

Related Articles

  • How to generate SSH Keys on Linux?
  • Linux File Permissions Cheat Sheet
  • The ELK Stack: Elasticsearch, Logstash, Kibana.
  • How to install Node.js on AlmaLinux 8
  • Firewalld commands for CentOS 7 and CentOS 8
  • Managing systemd services and units using systemctl commands
  • How to check RAM for error using Ubuntu Live CD?
  • How to remotely connect to a Linux machine using a smartphone?
  • Unable to Access The Server Via SSH
  • How to clone and migrate a Linux hard drive to another server?
  • Whitelisting Edge Server IPs
  • traceroute in Linux
  • Ubuntu remove mysql
  • ssh host key verification failed error
  • logrotate
  • How to rsync two directories
  • setup hourly crontab
  • Views: (1676)
  • Votes: (0)
Was this article helpful?
VOTE

SCP Command Syntax Examples in Linux

Publisher: Psychz Networks,  December 09,2018

scp stands for secure cp (copy), which means you can copy files across ssh connection. It is a very secure way to copy files between computers as SSH (Secure Shell) is a cryptographic network protocol for operating network services securely over an unsecured network.
scp uses by default the port 22, and connect via an encrypted connection or secure shell connection. You can also copy files directly from one remote server to another remote server. scp is very versatile and can be used on Linux, Mac and Windows (using WinSCP).

  • Copy from Source to Destination
  • Copy from Remote Location
  • Copy from user 1 to user2 in same location
  • Copy Multiple Files
  • Copy any file with specific extension
  • WINSCP
  • PSCP

We are going to start with the some basic commands and examples here.


The following syntax is used to copy a file from source to a destination.

$ scp source_file_path destination_file_path

Depending on the type of host, the above syntax will also need a file path with full host address, port number, username and password along with the directory path.
So if you want to send file from your local machine to a remote machine the syntax would look like this

$ scp /local_machine_file.txt user@172.212.xxx.xxx:/some/remote/directory

This will be reverse when copying file from remote host to local host.

$ scp user@172.212.xxx.xxx:/some/remote/directory /local_machine_file.txt

If you simply want to download the file to your local machine the simple form of syntax would be

$ scp user@172.212.xxx.xxx:/some/path/file.txt

NOTE: By default scp will always overwrite files (if already exists) on the destination.

The following syntax will guide you to copy the same file from user1 home folder to user2 home folder in another remote machine.

scp user1@152.144.xxx.xxx:/home/file.txt user2@172.168.xxx.xxx:/home/


Now, with the following syntax we will see how to Copy one single file from a remote host to the same remote host in another location

scp user1@152.144.xxx.xxx:/home/file.txt user2@152.144.xxx.xxx:/home/

Now we will see how to Copy a directory ("demo_dir" in this e.g.) from the local host to a remote host's directory ("location" in this e.g.)

$ scp -r demo_dir user1@152.144.xxx.xxx:/remote/directory/location

We will see now how to copy multiple files using scp command

Note: You can copy multiple files at once without having to copy all the files in a folder, or copy multiple files from different folders putting them in a space separated list.

scp file1.txt file2.txt file3.txt user1@172.165.xxx.xxx:/home/user1/

If you want to copy multiple files that are located in different folders you need to specify the complete path.

scp /path/to/file1.txt /path/to/file2.txt /path/to/file3.txt user1@172.165.xxx.xxx:/home/user1/

The following syntax will copy all files of a given extension to the remote server. For instance, you want to copy all your text files (txt extension) to a new folder. Here we will use a wildcard asterisk (*) to simplify the task.

scp /home/user/*.txt user1@172.165.xxx.xxx:/home/user1/

Copy all files in a folder with any extension to a remote server. This will copy all files inside local folder to the remote folder.

Here's an example.

scp /home/user/html/* jane@host.example.com:/home/jane/backup/

Other available options of SCP


WinSCP

If you are working on a Windows powered computer, you can still enjoy scp in various ways. Winscp is a powerful GUI tool available used by a large number of user base that use windows platform.

pscp

pscp is a shell command that works almost on Windows Shell the same way that scp works on Linux or Mac OS X

Related Articles

  • How to generate SSH Keys on Linux?
  • Linux File Permissions Cheat Sheet
  • The ELK Stack: Elasticsearch, Logstash, Kibana.
  • How to install Node.js on AlmaLinux 8
  • Firewalld commands for CentOS 7 and CentOS 8
  • Managing systemd services and units using systemctl commands
  • How to check RAM for error using Ubuntu Live CD?
  • How to remotely connect to a Linux machine using a smartphone?
  • Unable to Access The Server Via SSH
  • How to clone and migrate a Linux hard drive to another server?
  • Whitelisting Edge Server IPs
  • traceroute in Linux
  • Ubuntu remove mysql
  • ssh host key verification failed error
  • logrotate
  • How to rsync two directories
  • setup hourly crontab
  • Views: (1676)
  • Votes: (0)
Was this article helpful?
VOTE
Copyright © 2025 Psychz Networks,
A Profuse Solutions Inc Company
Hosting Services
Infrastructure
  • iColocation
Compute
  • cMetal
  • cVirtual
Storage
  • sObject
  • sBlock
Networking
  • nCDN
  • nIP Transit
  • nWavelength
Protection
  • pBackup
  • pDDoS
Company
  • About Us
  • Blog
  • Careers
  • Contact Us
  • Data Centers
  • Looking Glass
  • Network
  • Reseller
Policies
  • Acceptable Usage Policy
  • Privacy Policy
  • Service Level Agreement
  • Terms and Conditions
Support
  • Community
  • Knowledge Base
  • Open A Ticket
Get In Touch
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801