Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown    



FTP on the COMMANDLINE



There are multiple tools to do your FTP jobs in a GUI, but the Tips for Linux Explorers would not be complete if there was not a hint about how to use FTP on the command line.

The basics of FTP on the command line are simple, you type the address, login, cd to the directory where the file is you want, and you type "get <file_name>" and when the file is downloaded you type "bye" to close the connection.
To show you that the FTP program is running your prompt will change to a special FTP prompt:

ftp>

Okay, let me show in an example how to download the D Small Linux ISO: "dsl-1.3.1.iso" using the commandline:

We start with making a connection to ftp.nluug.nl, in the quote you will see in GREEN the text I typed and in GRAY the answer received:

QUOTE
[bruno:~]$ ftp -v ftp.nluug.nl
Connected to ftp.nluug.nl.
220-There are currently 183 users logged in (max 850).
220-There are 50 extra sessions available for IPv6 clients
220-This is an IPv4 session
220-
220-Welcome to the FTP archive of SURFnet BV and
220-The Netherlands Unix Users Group (NLUUG).
220-
220-This server is located in The Netherlands, Europe.
220-If you are abroad, please find an ftp site near you.
220-Most information on this site is mirrored.
220-
220-Information about your login and any transfers you do are logged.
220-If you don't like this, disconnect now.
220-
220-For statistics, see
http://ftp.surfnet.nl/.statistics/
220-Problems?  Mail ftpmirror-beheer @ surfnet.nl
220-
220-You may login as "ftp" or "anonymous".
220-
220
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type


Now we are asked to login and we will use the name "anonymous":

QUOTE
Name (ftp.nluug.nl:bruno): anonymous
331 Please specify the password.


And give a password ( in most cases your email address ):

QUOTE
Password: ********
230-
230-================================================================
230-Want to know where to find what data?  See the file
230-                                        /pub/WhereToFindWhat.txt
230-
230-================================================================
230-
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.


Now we get the FTP prompt and we can cd to the directory where the file is located: ( Note, next to the cd command also ls and pwd are commands known by FTP, but more about that later )

QUOTE
ftp> cd /pub/os/Linux/distr/damnsmall/current/
250 Directory successfully changed.


Next we are going to download the file:

QUOTE
ftp> get dsl-1.3.1.iso
local: dsl-1.3.1.iso remote: dsl-1.3.1.iso
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for dsl-1.3.1.iso (50745344 bytes).
226 File send OK.
50745344 bytes received in 1.5e+02 seconds (3.3e+02 Kbytes/s)


And after seeing "File send OK" you can close the connection and get your usual prompt back:

QUOTE
ftp> bye
221 Goodbye.
[bruno:~]$ 


See ? That was simple . . . . but sure you will want to know a bit more about FTP on the command line, like the command "put" to upload files, the command "bell" to have a signal when the file is finished downloading, or "hash" that prints # marks, one for each block of 1024 bytes recieved.

If you want to see a full list of commands that your FTP program can handle just type a ? at the FTP prompt:

QUOTE
ftp> ?


For more elaboration on FTP check out: http://www.faqs.org/docs/Linux-mini/FTP.html



Bruno


-- Nov 8 2005 ( Revised Dec 10 2005 ) --


Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown