Use Terminal on Mac as FTP or SFTP Client

File Transfer Protocol (FTP) and Secure File Transfer Protocol (SFTP) are two commonly used protocols for moving files and data between local devices and remote servers. These protocols are frequently used by web developers to change their servers, and there are many FTP clients available.

File Transfer Protocol (FTP) and Secure File Transfer Protocol (SFTP) are two commonly used protocols for moving files and data between local devices and remote servers. These protocols are frequently used by web developers to change their servers, and there are many FTP clients available.

However, the Mac also has a tool that allows users to use the FTP and SFTP protocols to communicate with remote servers that few people know, which is Terminal.

In the following article, Network Administrator will guide you how to use the Mac Terminal to make FTP or SFTP Client on Mac.

Note:

To use SFTP you must access SSH and activate the server. If you don't have SSH access, you can contact your provider or use FTP.

However, remember that FTP is often unsafe.

Login Server

Logging in to the remote server is quite simple. You need an FTP / SFTP username and password to log in to the server. FTP allows users to log in anonymously, but it is best to log in with your username and password.

- Use FTP:

Use the following command to log in to the remote server using FTP:

ftp server_ip

You will now be asked to enter your username (username). Your task is to enter the username into it and press Enter. Next Terminal will ask you to enter a password, just enter the password and then press Enter to log in.

- Using SFTP:

Enter the following command to log in to the remote server using SFTP;

sftp username @ server_ip

You will be asked to enter your password, your task is to enter the password and then press Enter to login.

1. Upload and download files

One of the basic functions of FTP / SFTP clients is the ability to upload files from local host to a remote server, and download files on the remote server.

Use FTP or SFTP:

- Upload file:

Use the following command to upload files to the remote server:

put path_to_local_file remote_file

For example, if you want to upload a file named index.txt, use the following command:

put /Users/akshaygangwar/index.txt index.txt

Picture 1 of Use Terminal on Mac as FTP or SFTP Client

This command will put the file named "index.html" from the main directory into the active directory on the remote server.

Note:

To find the active directories, you can use the "pwd" command .

- Download files:

The command to download files on the remote server is:

get path_to_remote_file local_file

For example, if you want to download a file named newfile.txt , use the following command:

get newfile.txt newfile.txt

Picture 2 of Use Terminal on Mac as FTP or SFTP Client

This command will download the files named 'newfile.txt' on the active folders on the remote server to the active directory on the Mac.

2. Create a new folder

Creating a new directory on the remote server is an important step, done by the FTP Client.

- Use FTP or SFTP:

Creating a new folder using Terminal is quite simple. You can use this command for both FTP and SFTP:

mkdir directory_name

In the above command, directory_name is the name of the directory you want to create.

Suppose if you want to create a folder called Beebom , you use the following command:

mkdir Beebom

Picture 3 of Use Terminal on Mac as FTP or SFTP Client

3. Rename the files on the Server

- Use FTP or SFTP:

To rename the files on the remote server using Terminal as FTP / SFTP Client, use the following command:

rename old_name new_name

For example if you want to change the name 'newfile.txt' to 'mainlog.txt' , you use the command:

rename newfile.txt mainlog.txt

Picture 4 of Use Terminal on Mac as FTP or SFTP Client

And the file 'newfile.txt' will be renamed to 'mainlog.txt'.

4. Delete files

The terminal also allows you to delete files on the remote server. However, this command on FTP and SFTP will vary slightly.

- Use FTP:

The command to delete files on the remote server using FTP is:

delete file_name

In the above statement file_name is the file name you want to delete.

For example, if you want to delete a file named 'beebomold.txt' , you use the command:

delete beebomold.txt

And the file 'beebomold.txt' will be deleted from the remote server.

5. Move files in the remote server

Using the Terminal as an FTP client also allows you to move files in the remote server the way you use the third-party FTP client.

Use FTP or SFTP:

The command to move files in the server on both FTP and SFTP is:

rename file_name path_to_new_file / file_name

For example, if you want to move a file named 'testresults.txt' from the "test" folder to the "results" directory, use the following command:

rename testresults.txt results / testresults.txt

Picture 5 of Use Terminal on Mac as FTP or SFTP Client

6. Check the last update date (Last Modified)

To check the last update date of a file or a folder, you can also use Terminal.

Use FTP or SFTP:

The command to check the last update of a file is:

ls -l file_name

This command displays some information in tabular form. The columns have the date and time values ​​corresponding to the "Last Modified" value.

For example, if you want to check the last update date of the file named 'testresults.txt', you use the command:

ls -l testresults.txt

Picture 6 of Use Terminal on Mac as FTP or SFTP Client

7. Check and edit permissions

Setting permissions to files is quite important. In some cases if the wrong permissions can lead to an error that cannot load the application.

Use FTP or SFTP:

- Check permission:

Checking and modifying permissions by using Terminal as a client is quite simple, using the command:

ls -l file_name

In the above command file_name is your file name.

This command displays some information in tabular form. The first column will display permissions for files.

For example, if you want to check the permissions of the file 'testresults.txt' , you use the command:

ls -l testresults.txt

Picture 7 of Use Terminal on Mac as FTP or SFTP Client

- Edit permissions:

If a file is incorrectly granted permissions, or if you only want to see permission, you can use Terminal to modify the permission of the file. Use the command:

chmod permissions_value file_name

Suppose if you want to set read, write and execute permissions on file 'testresults.txt', you use the command:

chmod 777 testresults.txt

Picture 8 of Use Terminal on Mac as FTP or SFTP Client

8. Create new files

Creating new files on the Server has never been simpler. But does not mean impossible.

Use FTP or SFTP:

Use the following commands to place a new file on the remote server:

! touch file_name

put file_name file_name

For example, if you want to create a file named 'newtest.txt' on the server, use the following command:

! touch newtest.txt

put newtest.txt newtest.txt

Picture 9 of Use Terminal on Mac as FTP or SFTP Client

Now the file 'newtest.txt' will be created and uploaded to the server.

9. Edit existing files

Use FTP or SFTP:

The commands to edit existing files on the remote server are:

get file_name file_name

nano file_name

put file_name file_name

For example, if you want to edit the file 'newtest.txt' , use the following commands:

get newtest.txt newtest.txt

! nano newtest.txt

put newtest.txt newtest.txt

Picture 10 of Use Terminal on Mac as FTP or SFTP Client

The above commands will edit the file 'newtest.txt' and upload the file to the server.

10. Create duplicate files

When editing files on a remote server, it is best to copy the original files to avoid bad situations.

Use FTP or SFTP:

To make copies of a file on the remote server, use the commands:

get file_name file_name

! mv file_name new_file_name

put new_file_name new_file_name

For example if you want to create a copy of 'newtest_copy.txt' of file 'newtest.txt', use the commands:

get newtest.txt newtest.txt

! mv newtest.txt newtest_copy.txt

put newtest_copy.txt newtest_copy.txt

Picture 11 of Use Terminal on Mac as FTP or SFTP Client

Refer to some of the following articles:

  1. Steps to install Windows 7 on Mac using Boot Camp
  1. How to check if your computer is running Windows 10 Hyper-V?
  1. Instructions from AZ how to install Windows 10 on Mac

Good luck!

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile