Introduction: How to Use a Command-line FTP Client

Why?
Maybe you don't have any other ftp client available.
Maybe you don't want to be slowed down by windows, graphics and mice.
Maybe you want the fun of doing things old-skool.
Maybe you want to look like you know a lot more about technical computer operations than other people around you.

A command-line FTP client can usually be found on any machine: open a command prompt and type ftp.

Step 1: Syntax

Command line syntax generally works like this:
Command SPACE argument

Like:
Pushbutton
or
Eattoast

Some commands will take multiple arguments, e.g:
Pushbutton1button2
or
Eattoastcereal

Each line is stored in the keyboard buffer until you hit RETURN (ENTER), then the command is executed.

In this image I have typed ftp (the remote machine) then hit RETURN.
The client then tells me that I'm connected and to what machine, including the IP address
It's then asking me for a user login.

"Remote" means the server you are connected/connecting to.
"Local" means the computer you are sitting in front of, or otherwise logged-on to in the first instance.
I'm using a Microsoft FTP client, but since the protocol goes way back into UNIX they are all quite similar.

Step 2: Connecting

You can either type ftp (remote machine) RETURN or type ftp RETURN, then open (remote machine)

The remote machine can be specified by IP address or web address. If you are connecting on a local network you can use the computer name.
By default FTP attempts to log the user in to the FTP server.

You will of course need a login and password to connect to a remote machine as you would using any other FTP client.

Enter your username RETURN
Enter your password RETURN
(This MS FTP client does not show any characters when you type the password.)

Notice the ftp> prompt.

Step 3: Navigating

There are three main commands for navigating the remote file system:

dir which displays a list of the current remote directory's files and sub-directories (first image)

ls which displays an abbreviated list (second image)

cd - meaning change directory.
cd (directory) will move you into that directory.
cd .. will move you up the tree into the previous directory (note that in the second image .. is displayed as a directory listing, as is . (the current directory).
In image 2 I've changed directory to "www" at the top, then used ls.

Compare images 1 and 2:
dir lists the permissions on the left, e.g. BJ is a directory (d) I have readwriteexecute permission, groups have read and execute, others just execute.
Notice that for the files (e.g. jpg) only I have rw, everyone else has r only.
ls lists the same but without details.

To do the same on the local machine use the following syntax:
! dir
lcd (directory)

Step 4: Download

To download a file use:
get (filename)
You can rename the file which you are creating on the local machine by typing:
get (filename) (new local filename)

mget allows you to retrieve multiple files in one command line, e,g,:
mget (filename1) (filename2) (filename3)
Note that you can't rename these locally because of the syntax.

The downloaded files will be created in the current local directory, so make sure you know where you are locally (previous step).

Image 1 shows the retrieval of "tony.jpg"
It ends up in the root of partition 1 C:\ because that's the local directory I was in at the time (see image 2).

Step 5: Upload

Make sure you are in the local directory from which you wish to upload - using ! dir and lcd, and in the correct remote directory.

Use put (filename) to transfer a local file to the remote directory
Like get you can rename the file which you are creating on the remote machine by typing:
put (filename) (new remote filename)
Like mget mput can be used to upload multiple files:
mput (filename1) (filename2) (filename3)

In image 1 I've used ! dir to list the contents of a local directory (the path is shown at the top of the window, it contains images of "Mr Shiraz").
Then I've used put to upload the file MS1.jpg

In image 2 I've used ls to show me what's in the remote directory, and you can see MS1.jpg at the bottom of the listing.

Step 6: Create / Delete

Make sure you are in the correct local and remote directories.

mkdir (remote directory) will create a directory on the remote machine.
rmdir (remote directory) will delete that directory on the remote machine.

delete (remote filename) will delete that file on the remote machine.
(note delete * will, to the best of my knowledge and experience, delete every file in the remote directory, but I cannot motivate myself to actually test it. Be very careful using wildcards "*" in the command-line unlike windowed interfaces it doesn't ask you if you're sure - it just does it.)
Similarly mdelete (remote filename1) (remote filename2) (remote filename3) will delete multiple files on the remote machine.

In this image I've followed a remote ls with a delete command, then used ls again to show that MS1.jpg has been deleted.

Step 7: Bye!

To end the client you can type:
bye and it will say "Goodbye" to you (this is old-skool programming, probably some old academic with a beard put that in the program...)
or
close
or
Use disconnect which leaves you with the FTP client running, such that you can use open for another connection.

Step 8: Advanced

This page is one that lists all MS FTP commands.
This page is one source of the relevant Linux
man page.
This page is one source of the relevant Mac OS-X
man page.

Some of the advantages of command-line work:
You don't need a high-spec machine.
You don't need a mouse.
You are not encumbered by graphics and dialogue-boxes.
You can work much more efficiently without the above.
You have a deeper understanding of how things work.

L

Comments

author
dagenius (author)2009-05-15

You can also use 'dir' to move into a directory

author
lemonie (author)dagenius2009-05-16

How? What's the syntax? L

author
Super_Nerd (author)lemonie2011-06-24

The dir syntax can be found by typing dir /? into cmd

Cmd.jpg
author
dagenius (author)lemonie2009-05-20

ooooohhhhhhhh, now that I think rrrrreeeeaaaalll hard, dir actually lets you see what is in a directory that you are already in with cd....... doh!

author
lemonie (author)dagenius2009-05-20

Yeah, I guess it's what you think of the word "move", in this case. Do you ever use this sort of thing? L

author
dagenius (author)lemonie2009-05-24

you mean cmd prompt? Yah, if you mean to ping, message, or just to be amazed at how far computers have gone

author
lemonie (author)dagenius2009-05-24

That's pretty much the same as me... L

author
gonturan (author)2009-03-11

Wow... did people really have to use this to upload stuff?

author
lemonie (author)gonturan2009-03-11

In the past, yes. But this type of thing can be very efficient, no pointing and clicking and page-reloads etc.
For an example of how horrendous non-windowed stuff could be see these instructions for the VI text editor (predates mice)

L

author
cephalopoid (author)lemonie2010-08-18

I don't see what's horrendous about vi. I use vim everyday, and I'm not from the older generation, I'm barely 20. It's a matter of taste, really. And of efficiency and ergonomy.

author
lemonie (author)cephalopoid2010-08-18


is VIM the same as VI?

L

author
cephalopoid (author)lemonie2010-08-19

I'm not sure whether it was a fork or a rewrite, but it's a bit more modern, IMHO. It has marks, folding, syntax highlighting, macro keybindings, custom scripts and commands, counting, and many more and lots of other features you could only wish for to reach on openoffice without touching the rodent on your desk. I hope that sentence made sense. It has the hjkl navigation from vi, as well as the modal interface. Maybe there's a more extensive comparison somewhere. Let me know if you didn't understand any of the jargon I just spewed there.

author
NachoMahma (author)2009-03-11

. Flashback! . Great job.

author
lemonie (author)NachoMahma2009-03-11

I still use this sometimes.

L

author
sharlston (author)lemonie2009-04-26

u still use this oh my god u are a bit sad

About This Instructable

3,247views

10favorites

License:

Bio: I'm an experimentalist, a scientist and I have a tendency to do things just for the sake of doing them, or to find out ... More »
More by lemonie:Multiple-secret book-boxHow to make fake cat-foodSkull Candy Headphone Modification
Add instructable to: