Welcome to CodeNet, To copy a file to another machine through the terminal, you can use the scp
command. scp
(secure copy) is a command-line tool for securely transferring files between computers over a network.
Here’s how you can use scp
to copy a file from one machine to another:
- Open a terminal window on the machine where the file you want to copy is located.
- Use the
scp
command to copy the file to the destination machine. The syntax for thescp
command is:
scp [options] source_file destination_file
Replace source_file
with the file you want to copy, and destination_file
with the location where you want to copy the file. The destination_file
can be a local file path or a remote machine address in the format of [username@]host:[path]
.
For example, to copy a file named file.txt
from the local machine to a remote machine with the IP address 192.168.0.2
, you would use the following command:
scp file.txt user@192.168.0.2:/home/user/
This would copy file.txt
to the /home/user/
directory on the remote machine.
- When you run the
scp
command, you may be prompted for a password. Enter the password for the remote machine when prompted. - Wait for the file transfer to complete. Once the transfer is complete, you should see a message indicating that the file transfer was successful.
That’s it! You’ve successfully copied a file to another machine through the terminal using scp
. Note that scp
uses SSH for secure file transfers, so you need to have SSH access to the remote machine to use scp
.