Essential ftp Commands
|
How to Open an ftp Connection to a Remote System
You must have ftp authentication.
bash-3.2# vi /etc/ftpd/ftpusers
Comment or remove required user to connect through ftp...
Eg:
#
# List of users denied access to the FTP server, see ftpusers(4).
#
#root
daemon
bin
sys
adm
lp
uucp
nuucp
smmsp
#
#ftp remote-system
Eg:#ftp 172.16.0.1
If the connection succeeds, a confirmation message and prompt are displayed.
Name (remote-system:user-name): user-name
331 Password required for user-name:
Password: password
(If the system giving access to anonymous ftp account, then it’s prompt for an email address for the password. If the ftp interface accepts your password, it displays a confirmation message and the (ftp>) prompt.)
Example: Opening an ftp Connection to a Remote System
Connected to 172.16.0.4.
220 NTU-DR-GLOBAL FTP server ready.
Name (172.16.0.4:slt): slt
331 Password required for slt.
Password:
230 User slt logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
How to Close an ftp Connection
221-You have transferred 0 bytes in 0 files.
221-Total traffic for this session was 255 bytes in 0 transfers.
221-Thank you for using the FTP service on NTU-DR-GLOBAL.
221 Goodbye.
.
1. Change to a directory on the local system where you want the files from the remote system to be copied.
#cd target-directory
. #ftp remote-system
# 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.
# ls -l
You must use binary mode when transmitting all file other than ASCII files.
ftp> binary
or
ftp> bin
(Binary mode transmits all 8 bits/byte and it’s provide less error ftp transition)
ftp> get filename
#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.
ftp> bye
Example : Copying Files From a Remote System (ftp)
In this example, the user SLT opens an ftp connection to the system SLT_DR, and uses the get command to copy a single file from the /tmp directory.
# cd $HOME
ftp SLT_DR
Connected to SLT_DR.
220 SLT_DR FTP server (SunOS 5.8) ready.
Name (SLT_DR:SLT): SLT
331 Password required for SLT.
Password: xxx
230 User SLT logged in.
ftp> cd /tmp
250 CWD command successful.
ftp> binary
ftp> ls
200 PORT command successful.
150 BINARY data connection for /bin/ls (172.16.0.1,34344)
(0 bytes).
file_a
files
ps_data
226 BINARY Transfer complete.
53 bytes received in 0.022 seconds (2.39 Kbytes/s)
ftp> get file_a
200 PORT command successful.
150 BINARY data connection for file_a (172.16.0.1,34331)
(0 bytes).
221 Goodbye.
In this example, the same user SLT uses the mget command to copy a set of files from the /tmp directory to his home directory. Note that SLT 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 (172.16.0.1,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> binary
ftp> mget file*
mget fileb? y
200 PORT command successful.
150 BINARY data connection for fileb (172.16.0.1,34347)
(0 bytes).
226 BINARY Transfer complete.
mget filec? y
200 PORT command successful.
150 ASCII data connection for filec (172.16.0.1,34348)
(0 bytes).
226 BINARY Transfer complete.
mget filed? y
200 PORT command successful.
150 ASCII data connection for filed (172.16.0.1,34351)
(0 bytes).
226 BINARY Transfer complete.200 PORT command successful.
ftp> bye
221 Goodbye.
The directory from which you type the ftp command is the local working directory.
#ftp remote-system
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.
ftp> ls -l target-directory
ftp> binary
ftp> put filename
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.
ftp> bye
Example : Copying Files to a Remote System (ftp)
In this example, the user SLT opens an ftp connection to the system SLT_DR, and uses put command to copy a file from their system to the /tmp directory on system SLT_DR.
$ cd /tmp
ftp SLT_DR
Connected to SLT_DR.
220 SLT_DR FTP server (SunOS 5.8) ready.
Name (SLT_DR:SLT): SLT
331 Password required for SLT.
Password: xxx
230 User SLT logged in.
ftp> cd /tmp
250 CWD command successful.
ftp> binary
ftp> put filef
200 PORT command successful.
150 BINARY data connection for filef (172.16.0.1,34356).
226 Transfer complete.
ftp> ls
200 PORT command successful.
150 BINARY data connection for /bin/ls (172.16.0.1,34357) (0 bytes).
file_a
filef
files
ps_data
226 BINARY Transfer complete.
60 bytes received in 0.058 seconds (1.01 Kbytes/s)
ftp> bye
221 Goodbye.
In this example, the same user SLT uses the mput command to copy a set of files from their home directory to SLT_DR's /tmp directory. Note that SLT can accept or reject individual files in the set.
$ cd $HOME/testdir
$ ls
test1 test2 test3
$ ftp SLT_DR
Connected to SLT_DR.
220 SLT_DR FTP server (SunOS 5.8) ready.
Name (SLT_DR:SLT): SLT
331 Password required for SLT.
Password: xxx
230 User SLT logged in.
ftp> cd /tmp
250 CWD command successful.
ftp> binary
ftp> mput test*
mput test1? y
200 PORT command successful.
150 BINARY data connection for test1 (172.16.0.1,34365).
226 Transfer complete.
mput test2? y
200 PORT command successful.
150 BINARY data connection for test2 (172.16.0.1,34366).
226 Transfer complete.
mput test3? y
200 PORT command successful.
150 BINARY data connection for filef (172.16.0.1,34356).
226 Transfer complete.
ftp> bye
221 Goodbye.
0 comments:
Post a Comment