1337: Part 1
Tip | |
---|---|
If you want to transfer just one file (or a directory compressed into a tarball[37]), and you know the exact path of the source and destination, you can use scp (a secure version of cp[35]) instead of SFTP. You can upload a file (which we'll call
To download a file (say, a file called
Note that you must specify the file name twice: on the local end (your machine) and on the remote end (the server). If you're not sure what the path to your home directory on the server is, try typing pwd (mentioned in Table 3.1, “Commands for navigating the file system”) when you're connected to the server via SSH[2] and in your home directory (typing cd to get to your home directory if necessary, as shown in Example 3.1, “Using cd”). Be careful, though: you can easily overwrite files (without notification from scp that you're doing so, of course) if you specify the wrong path -- the author managed to do this with his home page! |
You can use SFTP to transfer files to or from a Linux server.
Start SFTP by typing sftp username@server_name
at the prompt, filling in the appropriate values for your username and the server's name. The commands that you'll most likely need are listed in Table 4.1, “SSH file transfer (SFTP) commands”.
Note | |
---|---|
SFTP commands look a lot like those discussed in Section 3.2, “Navigating the file system” and Section 3.3, “Manipulating the file system”, but commands to be run on the local machine (the one in front of you) have an |
As far as I can tell, command history and command completion (discussed in Section 3.1, “Features of the shell”) are not available in SFTP. In addition, you cannot transfer entire directories through SFTP; you must compress them first into a tarball[37] and then transfer the tarball.
Example 4.1. Using SSH file transfer (SFTP)
sftp jg18@grid.cec.wustl.edu
[Note that not even asterisks will be displayed on the screen as you type your password.]
You'll then have a prompt like sftp>
at which you can type commands.
Table 4.1. SSH file transfer (SFTP) commands
Category | Command | Action |
---|---|---|
Basic SFTP Commands | --- | |
~ |
| View list of SFTP commands |
~ |
| Exit SFTP |
Working with File Systems | --- | |
~ |
| Change directory on remote (local) machine |
~ |
| List remote (local) directory contents |
~ |
| Create remote (local) directory |
~ |
| Print name of working remote (local) directory |
~ |
lrm ") | Remove remote file |
~ |
lrmdir ") | Remove remote empty directory |
Downloading and Uploading | --- | |
~ |
| Download from remote_path to working local directory [to local_path instead] |
~ |
| Upload from local_path to working remote directory [to remote_path instead] |
Other Commands | --- | |
~ |
| Execute some_command on local machine |
[35] The command cp (copy) is discussed in Section 3.3, “Manipulating the file system”.
[36] The symbol ~
indicates your home directory, as noted in Table 3.2, “Common symbols from the file system”.
[37] Tarballs are discussed in Section 3.4, “Handling compressed files (tarballs)”.