Using FTP as a Client

The FTP service has a long history, with commands that predate shells such as bash. You should learn how to use FTP as a client, at least because key Red Hat RPMs are updated on FTP servers. As with other Linux clients, GUI FTP clients such as gFTP (GNOME FTP) are simply front ends for the commands that you can run at the text console.

The following sections describe a connection from an FTP client to Red Hat s main FTP site, ftp.redhat.com . This site is often quite busy, especially during the workday in the United States. Red Hat has a list of a large number of FTP mirror sites ( www.redhat.com/download/mirror.html ) that should include files that are nearly as up-to-date as those you ll find at ftp.redhat.com . If you have problems accessing ftp.redhat.com , try one of the mirror sites.

Basic Commands

As you can see in Figure 27.1, a substantial number of commands are associated with the FTP client. Only an essential few FTP commands are covered here; data on even rarely used FTP commands is available through the FTP manual you can find with the man ftp command. You can view a simple description of a command from the ftp > prompt by entering help command .

click to expand
Figure 27.1: FTP client commands

Table 27.1 describes some important FTP commands. You may note similarities between a number of these commands and those you know in the bash shell.

Table 27.1: Basic FTP Client Commands

Command

Description

! command

Runs a shell command on the local computer, in the local directory.

ascii

Sets file transfer to ASCII mode; best for text files.

binary

Sets file transfer to Binary mode; best for executables and compressed files.

bye

Exits from the current FTP session; synonym for exit .

cd

Changes the directory; similar to the Linux version of this command.

dir

Equivalent to the ls -l shell command.

get ftpfile localfile

Copies the ftpfile from the FTP server to localfile on the local computer; mget allows you to use wildcards, which is also known as globbing .

ls

See dir .

put localfile ftpfile

Copies the localfile from the local computer to ftpfile on the FTP server; mput allows you to use wildcards/globbing.

pwd

Lists the present working directory on the FTP server; if you ve configured FTP securely, the root directory that you see on the FTP server will be the main directory for FTP files, usually /var/ftp .

user

Allows you to enter a username; prompts for a password.

Connecting to ftp.redhat.com

Now let s get some practice with using the command-line FTP client. Assuming your Linux computer is connected to the Internet, run the ftp ftp.redhat.com command. The Red Hat FTP site allows only anonymous connections. While the commands shown in Figure 27.2 seem to require a password, no special password is needed. By custom, when you connect to an FTP server anonymously, you re supposed to enter your e-mail address when prompted for a password.

click to expand
Figure 27.2: Connecting to an FTP server
Note  

You can set up an FTP connection on your own network. Read ahead and create one of the servers discussed in the section Creating an Anonymous FTP Server later in this chapter. Once the server is active, you can connect to it from the local computer with the ftp localhost command.

At the ftp > prompt, enter the commands you need. Try out some of the commands shown in the previous section. You may note that commands such as put do not work; anonymous users aren t allowed to write to standard Red Hat FTP servers.

Note  

By default, the root user is not allowed to access any FTP server. If you try to log in through FTP as root, even a correct password will be rejected.

As an example, navigate to the directory with i386 Rawhide RPMs. As of this writing, they are located in the /pub/redhat/linux/rawhide/i386/RedHat/RPMS directory. You should find a long list of RPMs here.

Note  

While there are RPMs for other CPUs, those created for the i386 are most common. Although i386 RPMs are not optimized for other Intel CPUs, they do work. We discuss this topic in greater detail in Chapter 10 .

Rawhide is the Red Hat storage area for the latest RPM packages. If up2date (discussed in Chapter 10 ) is not your style, you can update RPM packages directly. Download the packages from the current Rawhide database, using commands similar to those shown in Figure 27.3. You can then install or upgrade these packages at your leisure.

click to expand
Figure 27.3: Downloading a Rawhide RPM

Alternatively, you don t have to bother with this process. As described in Chapter 10 , you can use a one-line rpm command to directly connect and install the latest RPM package on the FTP server of your choice.

The GUI FTP Client

Of course, there are graphical versions of the FTP client. One common graphical FTP client is gFTP, which you can start by entering gftp in a command-line interface in your favorite GUI. This opens the gFTP client, shown in Figure 27.4.

click to expand
Figure 27.4: The gFTP Client
Note  

You can run gftp from a regular virtual console; it s part of the gFTP package and opens a text-mode FTP client similar to ftp .

The gFTP client is convenient ; it has several common sites preconfigured in the Bookmarks menu. However, the sites, such as what you might open when you select Bookmarks ˜ RedHat Sites ˜ RH Rawhide, aren t always kept up-to-date. Nevertheless, it is a convenient way to make an FTP connection. For example, try Bookmarks ˜ RedHat Sites ˜ RH Main. If the Red Hat FTP server is not overloaded, it should bring you to the base Red Hat FTP directory shown in Figure 27.5.

click to expand
Figure 27.5: gFTP in action

Compare the differences between Figure 27.4 and Figure 27.5. When you select a gFTP bookmark, it fills in a number of entries (described in Table 27.2) in various text boxes.

Table 27.2: Entries for Connecting a gFTP Client

Entry

Function

Host

The FQDN of the FTP server.

Port

The TCP/IP port for the connection; by default, it s 21.

User

The username for the connection; anonymous is common for an anonymous FTP server.

Pass

The password associated with the username. By convention, it s supposed to be your e-mail address.

You may want to go to a subdirectory on an FTP server. To navigate to the desired directory, double-click it. Remember, the double-dot ( .. ) is associated with the next higher-level directory. Once you ve found the folder or file that you want to copy, highlight it and click the arrow button.

You can observe the commands and messages that are transmitted in the bottom part of the gFTP window.

 


Mastering Red Hat Linux 9
Building Tablet PC Applications (Pro-Developer)
ISBN: 078214179X
EAN: 2147483647
Year: 2005
Pages: 220

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net