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
scp [options] [source] [destination]
Copy from local machine to remote machine (push)
Here are the basic steps to use Secure Copy:
- Open a terminal on your local machine.
- Type the following command to copy a file from your local machine to a remote machine
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:
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:
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:
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!!
Recent Comments