Skip to main content
All CollectionsDomains, Web Servers, and BeyondWeb Servers
What is the scp command in Linux with examples
What is the scp command in Linux with examples
Rapyd Team avatar
Written by Rapyd Team
Updated over a week ago

The scp command in Linux is a utility designed for the secure transfer of files either between local and remote systems or between two remote systems. Utilizing the SSH protocol, scp ensures that files are encrypted during transfer, providing both security and integrity. In this guide, we delve into the basics of scp, providing examples and additional options for more advanced use-cases.

Introduction to scp

scp, an acronym for "secure copy," is essentially an enhanced version of the standard cp (copy) command. Unlike cp, which copies files locally, scp enables you to transfer files over a network, leveraging SSH for secure communications.

Basic Syntax of scp

The basic syntax for using scp is as follows:

scp [options] [source] [destination]
  • [options]: Optional flags that alter the behavior of the scp command.

  • [source]: The file or directory you intend to copy.

  • [destination]: The location where you wish to copy the file or directory.

Common Usage Examples

Copy a Local File to a Remote System:

scp /path/to/local/file.txt username@remote_host:/path/on/remote/system/

Copy a File from a Remote System to the Local System:

scp username@remote_host:/path/on/remote/file.txt /path/to/local/directory/

Copy a Directory Recursively:

Use the -r flag to copy entire directories.

scp -r /path/to/local/directory/ username@remote_host:/path/on/remote/system/

Copy Between Two Remote Systems from a Local Machine:

scp username1@remote_host1:/path/on/first/remote/file.txt username2@remote_host2:/path/on/second/remote/

Additional Options and Tips

Specifying a Different SSH Port:

If your SSH server is running on a non-standard port, use the -P flag followed by the port number.

scp -P 2222 /local/file.txt username@remote_host:/remote/path/

Limiting Bandwidth:

Use the -l flag to limit the bandwidth consumed during the transfer, specified in Kbps.

scp -l 200 /local/file.txt username@remote_host:/remote/path/ # Limits to 200 Kbps

Verbose Output:

For troubleshooting purposes, the -v flag enables verbose output, providing detailed debugging information.

scp -v /local/file.txt username@remote_host:/remote/path/


The scp command is an invaluable tool for anyone who needs to securely transfer files between systems. With its straightforward syntax and the added security layer of SSH, scp is a preferred choice for system administrators and users alike. Whether you're migrating configuration files, distributing scripts, or sharing large data sets, scp ensures that your files arrive securely at their intended destination.

Did this answer your question?