How To Use FTP Through the Command Line in Mac OS X
Uploading and downloading files through a server over FTP is easy these days with modern FTP clients like Transmit, CyberDuck, or Flow. But if you happen to be in a situation where you're away from home and the Mac you're using is unequipped with a handy FTP client, you can easily retrieve and upload files using the command line. In this how-to, we’ll show you how to put the command line to good use by connecting to an FTP server.
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.

Uploading a file to the server is just as easy. Instead of “get”, you’re going to use “put” then the filename of the file on your local machine. So, if I had a file on my Desktop called Downloads.rtf that I wanted to put on the server in my Documents folder, I would type the following command:
put ~/Desktop/Download.rtf ~/Documents/Download.rtf
The first statement after the put command is the location on your local machine containing the file, in this case, ~/Desktop/Download.rtf; the second statement is the location on the server where the file should reside after upload, in this case ~/Documents/Download.rtf.
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.
Log in to Mac|Life directly or log in using Facebook
Forgot your username or password?
Click here for help.



















