banner



How to Use Mac Terminal as FTP or SFTP Client

File Transfer Protocol (FTP), and Secure File Transfer Protocol (SFTP) are two of the well-nigh widely used protocols for transferring files between a local device and a remote server. They are frequently used by spider web developers to push changes to their servers, and as such, in that location are a lot of FTP clients that are available. Nevertheless, at that place is besides a rather powerful tool built into a Mac that tin allow users to use FTP, and SFTP protocols to interface with remote servers.

In this article I volition exist detailing how you lot can utilize the Terminal (Mac) every bit an FTP or SFTP customer, to do a variety of tasks on remote servers. For the purpose of analogy, I'g using a exam server with Linux, Apache, MySQL and PHP installed on it, with SSH access enabled. I will be telling y'all how you tin achieve basic FTP/SFTP tasks such every bit uploading/downloading files, renaming, moving, deleting etc. using the macOS' Terminal, instead of a 3rd party FTP customer.

Note:To employ SFTP, you lot will demand to have SSH access enabled on your server. If you don't have SSH access, y'all can contact your hosting provider, or y'all can utilise FTP. But keep in mind that FTP is generally not considered secure, and then exist careful.

Logging into the Server

Logging into the remote server is pretty straightforward. Y'all volition demand a FTP/SFTP username and password to log into the server. FTP might allow for bearding log-ins, merely it'due south better to authenticate using a username and password.

Using FTP

The command to log-in into a remote server using FTP, is:

ftp server_ip

You volition then be prompted for your username, type it in, and hit Enter. Next, the Concluding will ask you for your countersign, key it in, striking Enter, and y'all will be logged in.

Using SFTP

The command to log-in to a remote server using SFTP, is:

sftp username@server_ip

Yous will so be prompted for the password. Cardinal it in, and hit Enter to log in.

1. Uploading and Downloading Files

One of the basic functions of an FTP/SFTP client is the ability to upload files from the local host to the remote server, and to download files off of the remote server.

Using FTP or SFTP

  • Upload Files

The command to upload files to a remote server, is:

put path_to_local_file remote_file

For example, if I wanted to upload a file called index.txt, the command will become:

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

upload files

This command will put the file chosen "index.html" from my abode directory, into the working directory in the remote server.

Annotation:To find out your working directory, you tin utilize the command "pwd"

  • Download Files

The command to download files off of a remote server, is:

get path_to_remote_file local_file

For example, if I wanted to download a file chosen newfile.txt, the control will become:

get newfile.txt newfile.txt

downloading files

This command will download the file called "newfile.txt" from the working directory on the remote server into the working directory on my Mac.

2. Creating a New Folder

Creating folders (directories) on a remote server is some other important task that is accomplished by FTP clients.

Using FTP or SFTP

Creating a new folder using the Terminal is like shooting fish in a barrel. Information technology's the same command in both FTP and SFTP protocols:

mkdir directory_name

For example, if I wanted to create a binder by the proper noun of "Beebom", the control will become:

mkdir Beebom

creating folders

This will create a folder named "Beebom", in the working directory on the remote server.

3. Renaming Files on the Server

Renaming files on the remote server tin be accomplished hands by using the Last as a client.

Using FTP or SFTP

The control to rename files on a remote server using the Last as an FTP/SFTP customer tin can be washed with the following control:

rename old_name new_name

For example, if I wanted to change the proper noun of "newfile.txt" to "mainlog.txt", the command volition get:

rename newfile.txt mainlog.txt

renaming files

This will rename the file "newfile.txt" to "mainlog.txt"

4. Deleting Files

The Concluding tin can also allow you delete files off the remote server. The commands in this instance are dissimilar for both FTP and SFTP, and I am stating both of them separately.

Using FTP

The control to delete files off a remote server using FTP, is:

delete file_name

For example, if I wanted to delete the file called "beebomold.txt", the command volition become:

delete beebomold.txt

deleting files ftp

This will delete the file "beebomold.txt" off of the remote server.

Using SFTP

The command to delete files off a remote server using SFTP, is:

rm file_name

For example, if I wanted to delete the file chosen "beebomold.txt" using SFTP, the command volition be:

rm beebomold.txt

deleting files sftp

This volition delete the file "beebomold.txt" from the remote server.

5. Moving Files inside the Remote Server

Using the Terminal as an FTP client can also allow y'all to motion files within the remote server itself, exactly the way y'all would do information technology in a 3rd party FTP client.

Using FTP or SFTP

The control to move files within the server in both FTP and SFTP is:

rename file_name path_to_new_file/file_name

For case, if I wanted to move a file called "testresults.txt" from the "exam" directory to the "results" directory, the command will become:

rename testresults.txt results/testresults.txt

moving files

This will motility the file "testresults.txt" to the sub-binder "results".

half dozen. Check "Terminal Modified" Appointment

Checking the "Last Modified" date for a file or a folder is useful if you need to know what files and folders were updated when. Yous tin can attain this on the Terminal as well.

Using FTP or SFTP

The control to check the final modified date for a file is:

ls -l file_name

This control displays some data in a tabular form. The column with the date and time values corresponds to the "Terminal Modified" value.

For example, if I wanted to check the engagement that "testresults.txt" was terminal modified, the command will be:

ls -l testresults.txt

last modified time

7. Bank check and Modify Permissions

Having files gear up to the proper permissions is very important. Sometimes, incorrect permissions tin pb to your web app non fifty-fifty loading.

Using FTP or SFTP

  • Checking Permissions

Checking and modifying permissions using the Terminal every bit a client is very straightforward, the command is:

ls -l file_name

This command displays some information in a tabular class. The first cavalcade displays the permissions on the file.

For example, if I wanted to check the permissions on the file "testresults.txt", I will employ the command every bit:

ls -fifty testresults.txt

check permissions

  • Modifying Permissions

If you see a file that has incorrect permissions, or if you lot just want to play around with the permissions, you lot tin can use the Terminal to modify the permissions of the file. The command is:

chmod permissions_value file_name

For example, if I wanted to give total read, write and execution permissions to the file "testresults.txt", the command will get

chmod 777 testresults.txt

change permissions

This command volition give read, write and execute permissions to the file "testresults.txt"

8. Create New Files

Creating new files on the server is a task that is not easily done on the Last. Nevertheless, that doesn't mean it's not possible. The outcome with creating new files is that yous take to have a copy of the file on your laptop before you can upload it to the server.

Using FTP or SFTP

The commands to create a file on the remote server, are:

!touch file_name

put file_name file_name

For example, if I desire to create a file "newtest.txt" on the server, the commands volition become:

!touch newtest.txt

put newtest.txt newtest.txt

create files on server

This will create a new file chosen "newtest.txt" and upload information technology to the server.

ix. Edit Existing Files

Editing existing files is as well an important feature. You can edit a file in the Terminal itself, past using programs such every bit nano, emacs etc., which are already built-in to the Terminal. Nano is simpler to understand, and I volition be using it in this example.

Using 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 instance, if I want to edit the file "newtest.txt", the commands will become:

get newtest.txt newtest.txt

!nano newtest.txt

put newtest.txt newtest.txt

editing existing files full

These commands volition edit the file "newtest.txt" and upload it back to the server.

ten. Creating Duplicate Copies of Files

When you are editing files in the remote server, it is better to have a re-create of the original file, simply in case y'all mess something upwards.

Using FTP or SFTP

To create a duplicate re-create of a file on the remote server, the commands are:

go file_name file_name

!mv file_name new_file_name

put new_file_name new_file_name

For example, if I want to create a indistinguishable copy "newtest_copy.txt" of "newtest.txt", the commands volition go:

become newtest.txt newtest.txt

!mv newtest.txt newtest_copy.txt

put newtest_copy.txt newtest_copy.txt

creating duplicates

SEE ALSO: 8 Useful FFmpeg Commands You Should Employ on Your Mac

Harness the Ability of the Mac Terminal with FTP or SFTP

Now that you know how you can utilize the Concluding as an FTP or SFTP client, you tin utilise it for FTPing or SFTPing into your development server, without having to worry almost tertiary-party applications installing bloatware, or not securing your traffic. If you have any issues with using FTP or SFTP from your Last, or if you think we missed something out, let us know in the comments section below.

Source: https://beebom.com/how-to-use-mac-terminal-ftp-sftp-client/

Posted by: moserthiced93.blogspot.com

0 Response to "How to Use Mac Terminal as FTP or SFTP Client"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel