How To Use FTP Through the Command Line in Mac OS X

1. Connecting to an FTP Server

To establish a connection with an FTP server, you’ll need to know your username and password, in addition to the server you’re connecting to (i.e. “maclife.com”). To open a connection in Terminal (located in /Applications/Utilities), type the following command, replacing the underlined portions with your server:

ftp YourServerHere.com

After a few seconds, you’ll be prompted for your username and password by the server. Type those in, pressing enter after entering each piece of information.

2. Browsing Around

After you’ve gotten the “ftp>” line displayed, you can issue the FTP server a command. To list the files in a particular folder, type ls (that’s LS in lower-case), then press enter.

Files will have a dash (-) as the first character in the leftmost column and folders will have a d listed (the d stands for directory).

To navigate into a folder, type cd (as in “change directory”), followed by the directory name you want to change to. Then, press enter to send the command to the server.

So, if I wanted to list the files in my Documents Folder, I would first type in:

ftp> cd Documents

ftp> ls


The files and folders in the Documents folder would then be listed. I could further navigate to another folder or download/upload a file to the current directory.

3. Uploading or Downloading from the Server

Download a file is easy. First, navigate to the folder containing the file you want to download. Next, type in the following command, specifying the file you want to download in place of the underlined text:

get file_name_here.pdf


Any files you download will appear in the Home directory of the currently logged in user on your Mac.

4. List of Commands

As you can see, the command line FTP client can be great when you’re in a pinch and need to do some basic FTP server work. Just to recap, here’s a list of the basic commands that you can use with the FTP client built into Mac OS X.

put filename - Upload a file to the server

get filename - Download a file from the server

mput filename - Put multiple files on the server

mget filename - Get multiple files on the server

ls - Get a list of files in the current directory

cd - Change directory

quit - Ends your ftp session


Follow this article’s author, Cory Bohon on Twitter.

TOPICS