The Terminal on your Mac can do a lot more than what you think it can. It allows you to get a lot of tasks done on your Mac using simple commands like it lets you reveal the path of a file on your Mac.
If you don’t already know, Terminal can also act as an FTP client for you. With its ability to help you connect and work with an FTP server, you can download and upload files to your server, create and delete directories, and so on, all from within the Terminal window. Here’s how you can go about using the FTP ability of the Terminal app on a Mac:
Note: The following command will work on a Linux terminal as well.
- How to Use Terminal as an FTP Client on a Mac
- Connecting and Logging Into the FTP Server
- Downloading and Uploading Files to the FTP Server
- Create a New Directory on the FTP Server
- Changing Names of the Files
- Moving Files on the FTP Server
- Deleting Files on the FTP Server
- Seeing the Last Modified Date of a File
- Changing File Permissions
- Creating a New File on the Server
- Getting Help with the Commands
How to Use Terminal as an FTP Client on a Mac
Keep your FTP server login details ready as you’re going to need them in the following steps to connect to the server.
Connecting and Logging Into the FTP Server
The first thing you need to do is connect to your FTP server and then log-in using your FTP account. It can be done using the following command in Terminal:
Replace ip-address with the IP address of the FTP server you want to connect to.
Once it’s connected to the specified FTP server, it will ask you to input your username. Do so and press Enter.
You will then be asked to enter your password. Do so and press Enter.
You should then see yourself connected to the server and all set to interact with the server.
Downloading and Uploading Files to the FTP Server
In order to upload a new file to the server, you need to use the following command in Terminal:
put path-to-file.ext remote-file-name.ext
In the above command:
- put is used to put the file onto the remote server.
- path-to-file – this is the local path to the file on your Mac
- remote-file-name.ext – this is the name that should be used for the file on the remote server along with the file extension
So, if I want to upload a file called MyFile.pdf from my Mac’s desktop over to the FTP server with the name MyNewFile.pdf, then I will use the following command:
put /Users/Mahesh/Desktop/MyFile.pdf MyNewFile.pdf
Your file will then be uploaded to the server.
Now, to download a file from the server, you can use the following command:
get path-to-remote-file.ext local-file.ext
- get – the command used to retrieve a file from the remote server.
- path-to-remote-file.ext – this is the path to the file on the remote server.
- local-file.ext – this is the file name that will be downloaded on your Mac.
The following command should retrieve MyNewFile.pdf from the remote server over to the desktop on my Mac with the name Downloaded.pdf.
get MyNewFile.pdf /Users/Mahesh/Desktop/Downloaded.pdf
Create a New Directory on the FTP Server
You can also create a new directory (folder) on the FTP server with Terminal’s FTP feature.
To create a directory called omghowto on the FTP server, you would use the following command:
Changing Names of the Files
You can rename files on the FTP server by using the following command in Terminal:
rename old-name.ext new-name.ext
where old-name.ext is the current name of the file and new-name.ext is the new name that you would like to give to the file.
Moving Files on the FTP Server
If you would like to move a file to another directory, then you can use the following command to do that:
rename file-name.ext destination-path/file-name.ext
Besides the destination directory, you also need to specify the name of the file that should be saved there.
Deleting Files on the FTP Server
If you want to delete a file that is located on the server, then the following command should help you do that:
It will delete a file called MyFile.pdf on the FTP server.
Seeing the Last Modified Date of a File
If you wish to see when a file was last modified, then you can use the following command to do that:
ls -l MyFile.txt
You should see the date and time when the file was last modified. Also, it should let you see the permissions that the file has.
Changing File Permissions
If you would like to change the permissions that a file has, then you can use the following command:
chmod 777 MyFile.pdf
Where chmod is the command, 777 is the file permission value, and MyFile.pdf is the name of the file on the server.
Creating a New File on the Server
Not only can you upload or download files from the server, but you can also create a new file on the server using the following command:
put MyFile.txt MyFile.txt
The first command creates a new file and the second command places the file on the server.
Getting Help with the Commands
If you would like to know what all the commands are that you can use with Terminal to do your FTP tasks, then you can run the following command and it will list out all the available Terminal FTP commands on your screen:
You should see that there are a number of commands that you can use.
Now that you know that even the Terminal on your Mac can be used as an FTP client, you won’t run to a third-party app for transferring files to your FTP server. Let us know if this helped you!
This amazing tool that helps with analyzing Linux logs for inclusion.
Read more like this
- How to Password Protect a File or Folder on a Mac
- 7 of the Commands for Siri on macOS Sierra
- 7 of the Useful Mac Terminal Commands