Using FTP - The Internet - Linux All-in-One For Dummies, 5th Edition (2014)

Linux All-in-One For Dummies, 5th Edition (2014)

Book IV. The Internet

Chapter 3. Using FTP

In This Chapter

arrow Using an FTP client

arrow Using any web browser as an FTP client

arrow Getting to know the FTP commands

Just as the name implies, File Transfer Protocol (FTP) is used to transfer files between computers. For example, if your Internet service provider (ISP) gives you space for a personal website, you may have already used FTP to upload the files making up the website. Using an FTP client on your computer, you log in to your ISP account, provide your password, and then copy the files from your home system to the ISP’s server.

You can also use FTP to download other files anonymously, such as open source software from other computers on the Internet — in which case, you don’t need an account on the remote system to download files. You can simply log in using anonymous as the username and provide your e-mail address as the password. (In fact, your web browser can do this on your behalf, so you may not even know this process is happening.) This type of anonymous FTP is great for distributing files to anyone who wants them. For example, a hardware vendor might use anonymous FTP to provide updated device drivers to anyone who needs them.

Linux comes with several FTP clients, both command-line ones and GUI (graphical user interface) ones. This chapter introduces you to a few GUI FTP clients and a command-line FTP client. It also describes the commands you use to work with remote directories.

tip.eps Depending on your Linux distribution and version, you may need to install the FTP clients discussed in this chapter.

Using Graphical FTP Clients

lxo-102.eps You can use one of the following GUI FTP clients in Linux:

· gFTP: A graphical FTP client for GNOME at

· FileZilla: A graphical FTP client for Linux and Windows platforms at

· Web browser: A browser such as Firefox, for anonymous FTP downloads

For uploading files, you may want to use gFTP or FileZilla because typically you have to provide a username and password for such transfers. Web browsers work fine for anonymous downloads, which is how you typically download software from the Internet.

All three GUI FTP clients are discussed in the next three sections.

Using gFTP

Some versions of GNOME come with gFTP, a graphical FTP client. gFTP isn’t installed by default, but you can download it from and install it easily. In some distributions, gFTP may be included in a package already, and you just have to install that package.

technicalstuff.eps gFTP has not been updated for several years, but is still widely used and that speaks to its robustness and suitability for the job.

Start gFTP, once it is installed, in the main menu, application window, or search and the gFTP window appears, similar to that shown in Figure 3-1.

Figure 3-1: The gFTP window just after opening a connection to an FTP server.

The gFTP window has a menu bar with menus for performing various tasks. Just below the menu bar is a toolbar with a number of buttons and text fields. Here you can type the name or IP address of the remote host, and the username and password needed to log in to the remote host. Figure 3-1 shows the gFTP window after you fill in this information and establish a connection with the remote host by clicking the button with the icon showing two computers (the leftmost one on the toolbar).

To upload or download files with gFTP, follow these steps:

1. Fill in the hostname or the IP address of the remote system in the Host field.

If you’ve used that host before, you can select it from the drop-down list that appears when you click the downward-pointing arrow next to the Host field.

2. Provide the username in the User field and the password in the Pass field, and then click the button with the icon showing two computers (to the left of the Host field).

This operation causes gFTP to connect to your chosen host and to log in with the username and password you provided. The lower part of the gFTP window shows the FTP protocol messages exchanged between the two systems.

3. Observe the lower part of the screen for any indication of error messages.

The directory listing of the remote system appears in the right half of the gFTP window. The left half shows the current local directory.

4. To upload one or more files from the current system to the remote system, select the files in the list on the left and then click the right-pointing arrow button.

5. To download files from the remote system, select the filenames in the list on the right and click the left-pointing arrow button.

6. When you’ve finished transferring files, choose FTP⇒Quit.

As these steps show, transferring files with a GUI FTP client, such as gFTP, is simple.

technicalstuff.eps Believe it or not, gFTP isn’t for FTP transfers alone. It can also transfer files using the HTTP (HyperText Transfer Protocol) and do secure file transfers using the Secure Shell (SSH) protocol.

Introducing FileZilla

FileZilla is another GUI FTP client for both Windows and Linux. It’s very similar to gFTP, but its development continues (whereas development has stopped on gFTP). The two programs are similar in look and operations. You find FileZilla at shown in Figure 3-2). It works on all distributions, and in both GNOME and KDE.

Figure 3-2: Download FileZilla from the site.

When the main FileZilla window appears, it displays your home folder in a view similar to that in Windows Explorer. To connect to an FTP server, type the name or IP address of the remote host, and the username and password needed to log in to the remote host. Figure 3-3 shows the FileZilla window after you fill in this information and establish a connection with the remote host.

You can now upload or download files with FileZilla just as you would gFTP,

FTP transfers become just normal drag-and-drop file copying: Transfer files by simply dragging them from one system’s folder and dropping them on the other system’s folder.

When you finish, choose File⇒Quit.

Using a web browser as an FTP client

Any web browser can act as an FTP client, but such programs are best for anonymous FTP downloads, where the web browser can log in using the anonymous username and any password.

Figure 3-3: FileZilla window displays the local directory and the remote FTP server’s directory.

For example, you can use the Firefox web browser as an FTP client. All you have to know is how to write the URL so that the web browser can tell that you want to download a file using FTP. The syntax of the FTP URL is


The first part (ftp://) indicates that you want an FTP transfer. The hostname part is the name of the FTP server (the name often starts with ftp — for example, The pathname is the full directory path and filename of the file that you want to download.

If you simply provide the hostname for the FTP server, the web browser displays the contents of the anonymous FTP directory. If you want to access anonymous FTP on your Linux system, start Firefox (click the web browser icon on the GNOME panel), type the FTP URL in the Location text box, and press Enter.

Figure 3-4 shows a typical appearance of an FTP directory in Firefox. You can click folders to see their contents and download any files. You can access your local system by using Firefox’s FTP capabilities; for example, type ftp://localhost/pub/ to access the pub directory. (You won’t get a response from your system if you’re not running an FTP server or if you’ve set up your firewall so that no FTP connections are allowed.)

Figure 3-4: You can use a web browser to download files from FTP servers.

 width= In Debian and Fedora, log in as root and type /etc/init.d/vsftpd start (in a terminal window) to start the FTP server. In SUSE, the xinetd super server controls the FTP server vsftpd. The /etc/xinetd.d/vsftpd configuration file specifies how vsftpd is started. (See Book VII, Chapter 1 for more information about xinetd configuration files.)

The same approach of accessing anonymous FTP sites works if you type the hostname of some other anonymous FTP server. For example, try typing the following URL:

You get the directory of the server.

Using the Command-Line FTP Client

lxo-102.eps Knowing how to use FTP from the command line is a good idea. For example, if your GUI desktop isn’t working, you may need to download some files to fix the problem; you can do so if you know how to use the command-line FTP client. The command-line FTP client is available in all Linux distributions and using it isn’t difficult.

The best way to figure out the command-line FTP client is to try it out. The command is ftp, and you can try out the ftp commands from your Linux system. You don’t even need an Internet connection because you can use the ftp command to connect to your own system.

 width= Note that the output from the ftp command might be different because some distributions, such as Debian, use a text mode version of gFTP as the command-line FTP client.

In the following sample FTP session, the command-line FTP client was used to log in and browse the directories on a Linux system. Here’s the listing illustrating interaction with a typical command-line FTP client:

ftp localhost
Connected to localhost.localdomain.
220 (vsFTPd 2.0.3)
Name (localhost:jdoe): (press Enter.)
331 Please specify the password.
Password: (enter the password for the user.)
230 Login successful.
Remote system type is Unix.
Using binary mode to transfer files.
ftp> help
Commands may be abbreviated. Commands are:
! debug mdir qc send
$ dir mget sendport site
account disconnect mkdir put size
append exit mls pwd status
ascii form mode quit struct
bell get modtime quote system
binary glob mput recv sunique
bye hash newer reget tenex
case help nmap rstatus tick
cd idle nlist rhelp trace
cdup image ntrans rename type
chmod lcd open reset user
close ls prompt restart umask
cr macdef passive rmdir verbose
delete mdelete proxy runique ?
ftp> help mget (to get help on a specific command.)
mget get multiple files
ftp> cd /var (This changes directory to /var.)
250 Directory successfully changed.
ftp> ls (This command lists the contents of the directory.)
227 Entering Passive Mode (127,0,0,1,38,142)
150 Here comes the directory listing.
. . . lines deleted . . .
226 Directory send OK.
ftp> bye (This command ends the session.)

As the listing shows, you can start the command-line FTP client by typing the command ftp hostname, where hostname is the name of the system you want to access. When the FTP client establishes a connection with the FTP server at the remote system, the FTP server prompts you for a username and password. After you supply the information, the FTP client displays the ftp> prompt, and you can begin typing commands to perform specific tasks. If you can’t remember a specific FTP command, type help to view a list of them. You can get additional help for a specific command by typing help command, where command is the command for which you want help.

Many FTP commands are similar to the Linux commands for navigating the file system. For example, cd changes directory, pwd prints the name of the current working directory, and ls lists the contents of the current directory. Two other common commands are get and put: get is what downloads a file from the remote system to your system, and put uploads (sends) a file from your system to the remote host.

lxo-102.eps Table 3-1 describes some commonly used FTP commands. You don’t have to type the entire FTP command. For a long command, you have to type only the first few characters — enough to identify the command uniquely. For example, to delete a file, you can type dele, and to change the file transfer mode to binary, you can type bin.

Table 3-1 Common FTP Commands




Executes a shell command on the local system. For example, !ls lists the contents of the current directory on the local system.


Displays a list of commands (same as help).


Appends a local file to a remote file.


Sets the file transfer type to ASCII (or plain text). This command is the default file transfer type.


Sets the file transfer type to binary.


Ends the FTP session with the remote FTP server and quits the FTP client.


Changes the directory on the remote system. For example, cd /pub/Linux changes the remote directory to /pub/Linux.


Changes the permission settings of a remote file. For example, chmod 644 index.html changes the permission settings of the index.html file on the remote system.


Ends the FTP session with the FTP server and returns to the FTP client’s prompt.


Deletes a remote file. For example, delete bigimage.jpg deletes that file on the remote system.


Lists the contents of the current directory on the remote system.


Ends the FTP session and returns to the FTP client’s prompt. (This command is the same as close.)


Downloads a remote file. For example, get junk.tar.gz junk.tgz downloads the file junk.tar.gz from the remote system and saves it as the file junk.tgz on the local system.


Turns on or off the hash mark (#) printing that shows the progress of the file transfer. When this feature is turned on, a hash mark prints onscreen for every 1,024 bytes transferred from the remote system. (It’s the command-line version of a progress bar.)


Displays a list of commands.


Same as binary.


Changes the current directory on the local system. For example, lcd/var/ftp/pub changes the current local directory to /var/ftp/pub.


Lists the contents of the current remote directory.


Deletes multiple files on a remote system. For example, mdelete *.jpg deletes all remote files with names ending in .jpg in the current directory.


Lists multiple remote files and saves the listing in a specified local file. For example, mdir /usr/share/doc/w* wlist saves the listing in the local file named wlist.


Downloads multiple files. For example, mget *.jpg downloads all files with names ending in .jpg. If the prompt is turned on, the FTP client asks for confirmation before downloading each file.


Creates a directory on the remote system. mkdir images creates a directory named images in the current directory on the remote system.


Same as mdir.


Uploads multiple files. For example, mput *.jpg sends all files with names ending in .jpg to the remote system. If the prompt is turned on, the FTP client asks for confirmation before sending each file.


Opens a connection to the FTP server on the specified host. For example, open connects to the FTP server on the host


Turns the prompt on or off. When the prompt is on, the FTP client prompts you for confirmation before downloading or uploading each file during a multiple-file transfer.


Sends a file to the remote system. For example, put index.html sends the index.html file from the local system to the remote system.


Displays the full pathname of the current directory on the remote system. When you log in as a user, the initial current working directory is your home directory.


Same as bye.


Same as get.


Renames a file on the remote system. For example, rename old.html new.html renames the file old.html to new.html on the remote system.


Deletes a directory on the remote system. For example, rmdir images deletes the images directory in the current directory of the remote system.


Same as put.


Shows the size of a remote file. For example, size bigfile.tar.gz shows the size of that remote file.


Shows the current status of the FTP client.


Sends new user information to the FTP server. For example, user jdoe sends the username jdoe; the FTP server then prompts for the password for that username.

tip.eps When downloading files from the Internet, you almost always want to transfer the files in binary mode because the software is usually archived and compressed in a binary form. (Its files aren’t plain text files.) So always use the binary command to set the mode to binary. Then use the get command to download the files.

tip.eps When transferring multiple files with similar names (such as image1.jpg, image2.jpg, and so on), type prompt to turn off prompting. (Otherwise the FTP client will ask you after each file transfer whether you want to transfer the next file.) Then type mget followed by the filename with a wildcard character. For example, to download all files with names starting with image and ending with the .jpg extension, type mget image*.jpg.