Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

System Administration Guide: Network Services
Previous Next

Logging In to a Remote System (ftp)

The ftp command opens the user interface to the Internet's File Transfer Protocol. This user interface, called the command interpreter, enables you to log in to a remote system and perform a variety of operations with its file system. The principal operations are summarized in the following table.

The main benefit of ftp over rlogin and rcp is that ftp does not require the remote system to be running UNIX. The remote system does, however, need to be configured for TCP/IP communications. However, rlogin provides access to a richer set of file manipulation commands than ftp provides.

Authentication for Remote Logins (ftp)

Authentication for ftp remote login operations can be established by one of the following methods:

  • Including your password entry in the remote system's /etc/passwd file or equivalent network information service map or table

  • Establishing an anonymous ftp account on the remote system

Essential ftp Commands

Table 29-3 Essential ftp Commands

Command

Description

ftp

Accesses the ftp command interpreter.

ftp remote-system

Establishes an ftp connection to a remote system. For instructions, see How to Open an ftp Connection to a Remote System.

open

Logs in to the remote system from the command interpreter.

close

Logs out of the remote system and returns to the command interpreter.

bye

Quits the ftp command interpreter.

help

Lists all ftp commands or, if a command name is supplied, briefly describes what the command does.

reset

Re-synchronizes the command-reply sequencing with the remote ftp server.

ls

Lists the contents of the remote working directory.

pwd

Displays the name of the remote working directory.

cd

Changes the remote working directory.

lcd

Changes the local working directory.

mkdir

Creates a directory on the remote system.

rmdir

Deletes a directory on the remote system.

get, mget

Copies a file (or multiple files) from the remote working directory to the local working directory.

put, mput

Copies a file (or multiple files) from the local working directory to the remote working directory.

delete, mdelete

Deletes a file (or multiple files) from the remote working directory.

For more information, see ftp(1).

How to Open an ftp Connection to a Remote System

  1. Ensure that you have ftp authentication.

    You must have ftp authentication, as described in Authentication for Remote Logins (ftp).

  2. Open a connection to a remote system by using the ftp command.
    $ ftp remote-system

    If the connection succeeds, a confirmation message and prompt are displayed.

  3. Type your user name.
    Name (remote-system:user-name): user-name
  4. If prompted, type your password.
    331 Password required for user-name:
    Password: password

    If the system you are accessing has an established anonymous ftp account, you are prompted for an email address for the password. If the ftp interface accepts your password, it displays a confirmation message and the (ftp>) prompt.

    You can now use any of the commands that are supplied by the ftp interface, including help. The principal commands are summarized in Table 29-3.

Example 29-5 Opening an ftp Connection to a Remote System

This ftp session was established by the user smith on the remote system pluto:

$ ftp pluto
Connected to pluto.
220 pluto FTP server ready.
Name (pluto:smith): smith
331 Password required for smith:
Password: password
230 User smith logged in.
ftp>

How to Close an ftp Connection to a Remote System

Close an ftp connection to a remote system by using the bye command.

ftp> bye
221-You have  transferred 0 bytes in 0 files.
221-Total traffic for this sessions was 172 bytes in 0 transfers.
221-Thanks you for using the FTP service on spdev.
221 Goodbye.

A goodbye message appears, followed by your usual shell prompt.

How to Copy Files From a Remote System (ftp)

  1. Change to a directory on the local system where you want the files from the remote system to be copied.
    $ cd target-directory
  2. Establish an ftp connection.

    See How to Open an ftp Connection to a Remote System.

  3. Change to the source directory.
    ftp> cd source-directory

    If your system is using the automounter, the home directory of the remote system's user appears parallel to yours, under /home.

  4. Ensure that you have read permission for the source files.
    ftp> ls -l
  5. Set the transfer type to binary.
    ftp> binary
  6. To copy a single file, use the get command.
    ftp> get filename 
  7. To copy multiple files at once, use the mget command.
    ftp> mget filename [filename ...]

    You can supply a series of individual file names and you can use wildcard characters. The mget command copies each file individually, asking you for confirmation each time.

  8. Close the ftp connections.
    ftp> bye
Example 29-6 Copying Files From a Remote System (ftp)

In this example, the user kryten opens an ftp connection to the system pluto, and uses the get command to copy a single file from the /tmp directory.

$ cd $HOME
ftp pluto
Connected to pluto.
220 pluto FTP server (SunOS 5.8) ready.
Name (pluto:kryten): kryten
331 Password required for kryten.
Password: xxx
230 User kryten logged in.
ftp> cd /tmp
250 CWD command successful.
ftp> ls
200 PORT command successful.
150 ASCII data connection for /bin/ls (129.152.221.238,34344) 
(0 bytes).
dtdbcache_:0
filea
files
ps_data
speckeysd.lock
226 ASCII Transfer complete.
53 bytes received in 0.022 seconds (2.39 Kbytes/s)
ftp> get filea
200 PORT command successful.
150 ASCII data connection for filea (129.152.221.238,34331) 
(0 bytes).
221 Goodbye.

In this example, the same user kryten uses the mget command to copy a set of files from the /tmp directory to his home directory. Note that kryten can accept or reject individual files in the set.

$ ftp> cd /tmp
250 CWD command successful.
ftp> ls files
200 PORT command successful.
150 ASCII data connection for /bin/ls (129.152.221.238,34345) 
(0 bytes).
fileb
filec
filed
remote: files
21 bytes received in 0.015 seconds (1.36 Kbytes/s)
ftp> cd files
250 CWD command successful.
ftp> mget file*
mget fileb? y
200 PORT command successful.
150 ASCII data connection for fileb (129.152.221.238,34347) 
(0 bytes).
226 ASCII Transfer complete.
mget filec? y
200 PORT command successful.
150 ASCII data connection for filec (129.152.221.238,34348) 
(0 bytes).
226 ASCII Transfer complete.
mget filed? y
200 PORT command successful.
150 ASCII data connection for filed (129.152.221.238,34351) 
(0 bytes).
226 ASCII Transfer complete.200 PORT command successful.
ftp> bye
221 Goodbye.

How to Copy Files to a Remote System (ftp)

  1. Change to the source directory on the local system.

    The directory from which you type the ftp command is the local working directory, and thus the source directory for this operation.

  2. Establish an ftp connection.

    See How to Open an ftp Connection to a Remote System.

  3. Change to the target directory.
    ftp> cd target-directory

    Remember, if your system is using the automounter, the home directory of the remote system's user appears parallel to yours, under /home.

  4. Ensure that you have write permission to the target directory.
    ftp> ls -l target-directory
  5. Set the transfer type to binary.
    ftp> binary
  6. To copy a single file, use the put command.
    ftp> put filename
  7. To copy multiple files at once, use the mput command.
    ftp> mput filename [filename ...]

    You can supply a series of individual file names and you can use wildcard characters. The mput command copies each file individually, asking you for confirmation each time.

  8. To close the ftp connection, type bye.
    ftp> bye
Example 29-7 Copying Files to a Remote System (ftp)

In this example, the user kryten opens an ftp connection to the system pluto, and uses the put command to copy a file from his or her system to the /tmp directory on system pluto.

$ cd /tmp
ftp pluto
Connected to pluto.
220 pluto FTP server (SunOS 5.8) ready.
Name (pluto:kryten): kryten
331 Password required for kryten.
Password: xxx
230 User kryten logged in.
ftp> cd /tmp
250 CWD command successful.
ftp> put filef
200 PORT command successful.
150 ASCII data connection for filef (129.152.221.238,34356).
226 Transfer complete.
ftp> ls
200 PORT command successful.
150 ASCII data connection for /bin/ls (129.152.221.238,34357) (0 bytes).
dtdbcache_:0
filea
filef
files
ps_data
speckeysd.lock
226 ASCII Transfer complete.
60 bytes received in 0.058 seconds (1.01 Kbytes/s)
ftp> bye
221 Goodbye.

In this example, the same user kryten uses the mput command to copy a set of files from his or her home directory to pluto's /tmp directory. Note that kryten can accept or reject individual files in the set.

$ cd $HOME/testdir
$ ls
test1   test2   test3
$ ftp pluto
Connected to pluto.
220 pluto FTP server (SunOS 5.8) ready.
Name (pluto:kryten): kryten
331 Password required for kryten.
Password: xxx
230 User kryten logged in.
ftp> cd /tmp
250 CWD command successful.
ftp> mput test*
mput test1? y
200 PORT command successful.
150 ASCII data connection for test1 (129.152.221.238,34365).
226 Transfer complete.
mput test2? y
200 PORT command successful.
150 ASCII data connection for test2 (129.152.221.238,34366).
226 Transfer complete.
mput test3? y
200 PORT command successful.
150 ASCII data connection for filef (129.152.221.238,34356).
226 Transfer complete.
ftp> bye
221 Goodbye.
Previous Next

 
 
  Published under the terms fo the Public Documentation License Version 1.01. Design by Interspire