Connecting to a Remote Server with FTP

The command line to connect to an FTP server is: For example, if you want to connect to “www.cornell.edu”, you would use the following command line:

Log In After You Are Connected

Once you are connected to the server, you need to login. If you are using a private server, you will need to have a username and password given to you by the administrator. Without that you won’t be able to connect to it. If you are trying to connect to a public server, most will let you log in with your username as “anonymous” and your email id as password. Some public servers will let you access them if you use “ftp” as both the username and the password. Enter your username and password when prompted. If you manage to successfully log in, the following prompt will (in most cases) be displayed: The server should also inform you that you are using a remote UNIX system and that the binary mode will be used to transfer files. The binary mode is used to download all non-text files, like images, executable files and zip files. If you want to download text files, you can switch to the ASCII mode. To do that, enter the following command: To revert back to binary, use the following command:

Now that you are logged into the server, you can begin to use the FTP commands. These commands will be different for different servers. To see a list of all the commands available on the current server, enter the following command line: To view all the files and subdirectories that are currently present in the directory you have navigated to, use the following command: On public servers you will want to navigate to the pub directory. This is where the files you’re looking for are probably being kept. So how do you navigate to the pub directory? Use the cd command, like this: This will get you to the pub directory. Once here, you can use the ls command again to look at all the files present. Now suppose you wanted to download an image: waterfall.jpg. How do you do that? Use this command: The file will get downloaded to the local directory on your machine. If you have a file with the same name present on your machine, it will get overwritten. To prevent that from happening, you can rename the file you are downloading like this:

This will prevent any naming conflicts. What if you wanted to get multiple files? You can use the “mget” command for that (the names of the files should be separated with a blank ” “).

What if you want to upload a file to the remote server? Note that you’ll require write persmissions on the remote server. If you don’t already have them, you’ll have to request the system admin. Here’s how you can use the put command: What if you wanted to upload multiple files? Use the “mput” command, which is just like the “mget” command.

Directory Settings

How do you find out which directory the files are getting downloaded to? Use the “lpwd” command, as follows: This will show you the directory where the files are being copied to. To change the directory, you type the path of a directory after the lcd command: These are the most important commands you will need to know as a basic user. If you are looking for more advanced commands, you can check out the official Linux website: http://www.linux.org/ . Do let us know your experience working with FTP on Linux! Image credits: RRZEicons at Wikimedia