Caution | |
---|---|
SCP is a powerful command: it allows you to easily and quickly send a file, directory, or set of files, but it doesn't prevent you from making such mistakes as sending files to (or receiving files from) the wrong location on the remote machine. It also does nothing to stop you from overwriting files (without notification that you're doing so, of course) if you specify the wrong path on the destination machine - the author managed to do this with his home page! If you use SCP with the |
If you want to transfer a single file (such as a tarball),[36] a directory in its entirety, or all of the files (but not subdirectories) in a given directory, and if you know the exact path of the source and destination, you can use SCP (a secure version of cp[34]) to transfer that file/directory or those files.
To upload a file from the current directory on your machine (say, a file called my_file
) to your home directory[12] on the server, type:
scp ./my_file your_username@server_name:
To download a file from the server (say, a file called my_file
from the path ~/classes/cse332
[35]) to the current directory on your machine, type:
scp your_username@server_name:classes/cse332/my_file .
To upload a directory (including all of its subdirectories), type:
scp -r /path_to_source_directory/ your_username@server_name:path_to_destination
To download a directory (including all of its subdirectories), type:
scp -r your_username@server_name:path_to_source_directory /path_to_destination/
To upload a single directory's files (but not its subdirectories), type:
scp /path_to_source_directory/* your_username@server_name:path_to_destination
To download a single directory's files (but not its subdirectories), type:
scp your_username@server_name:path_to_source_directory/* /path_to_destination/
[34] The command cp (copy) is discussed in Section 3.3, “Manipulating the file system”.
[35] The symbol ~
indicates your home directory, as noted in Table 3.2, “Common symbols from the file system”.