How to SCP Linux

SCP (Secure Copy) is a command-line tool used in Linux to securely copy files and directories between remote and local systems. The syntax for using SCP is:

SCP Command Syntax

ShellScript
scp [options] [source] [destination]

Copy from local machine to remote machine (push)

Here are the basic steps to use Secure Copy:

  1. Open a terminal on your local machine.
  2. Type the following command to copy a file from your local machine to a remote machine
ShellScript
scp /path/to/local/file username@remote:/path/to/destination

Replace /path/to/local/file with the path of the file you want to copy, username with your username on the remote machine, remote with the IP address or hostname of the remote machine, and /path/to/destination with the destination path on the remote machine.

Copy from a remote machine to a local machine (pull)

Type the following command to copy a file from a remote machine to your local machine:

ShellScript
scp username@remote:/path/to/remote/file /path/to/destination

Replace username with your username on the remote machine, remote with the IP address or hostname of the remote machine, /path/to/remote/file with the path of the file you want to copy, and /path/to/destination with the destination path on your local machine.

Copy recursively from the local machine to a remote machine

Type the following command to copy a directory from your local machine to a remote machine:

ShellScript
scp -r /path/to/local/directory username@remote:/path/to/destination

Replace /path/to/local/directory with the path of the directory you want to copy, username with your username on the remote machine, remote with the IP address or hostname of the remote machine, and /path/to/destination with the destination path on the remote machine.

Copy recursively from the remote machine to a local machine

Type the following command to copy a directory from a remote machine to your local machine:

ShellScript
cp -r username@remote:/path/to/remote/directory /path/to/destination 

Replace username with your username on the remote machine, remote with the IP address or hostname of the remote machine, /path/to/remote/directory with the path of the directory you want to copy, and /path/to/destination with the destination path on your local machine.

These are the basic steps to use SCP in Linux. There are many other options and configurations available for SCP, so you may want to consult the man page (man scp) or the SCP documentation for more information.

Want to learn more Linux facts? Check out the rest of our Tech Quicky content!!
Elsewhere On TurboGeek:  How to SSH to GCP Linux Instance

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate ยป