Crmgo Blog

Using an FTP client from the console

Using an FTP client from the console

Use one of the following options to connect to the server: 1 2 3 ftp ftp .example .com ftp 1.2.3.4 ftp user @ ftp .example .com You must know the username and password for authentication with user privileges; otherwise, you can…

Using an FTP client from the console

Use one of the following options to connect to the server:

You must know the username and password to authenticate with user privileges; otherwise, you can log in as an anonymous user. Let's try to log in to ftp.freebsd.org as anonymous. Open a terminal and execute the following command:

The session proceeds as follows:

When you enter your username and password for the ftp.example.com server, you will see the following prompt:

After that, you can use the ftp server by issuing commands.

Task: View files in a directory

Task: Change directory

Task: Download or copy a file

To copy a single file from a remote ftp server to your local computer, use the get command.

To copy the file README.TXT from ftp.freebsd.org, you need to be in the directory containing this file and execute the command

Here is the output of this command:

 

You can find out the current directory using the command:

 

The lpwd command displays the current directory on the local computer. To find out the directory on the remote FTP server, use the pwd command:

Download multiple files

To download multiple files from a remote FTP server to your local computer at once, use the mget command. Before downloading each file, you will be prompted to confirm the copy operation with Yes/No (Y/N). To avoid this, use the mget command with the -i flag. To download all files, enter:

To download all files with the .php extension:

Task: Delete a file

To delete a file on a remote FTP server, use the delete command.

Task: Upload a single file

To upload only one file to the FTP server, use the put command.

For example, let's upload a logo to the FTP server.

Task: Upload multiple files

To upload multiple files from your local computer to a remote FTP server at once, use the mput command. You will also need to answer Yes/No (Y/N) to the prompt for each file before uploading. The example below shows uploading all files from the local computer (from the current directory).

Task: Creating a directory

To create a new directory, use the mkdir command.

Task: Deleting a directory

To delete a directory, use the rmdir command.

Task: Choosing the Data Transfer Mode

To transfer files in ASCII mode, enter:

Note that ASCII mode is the default; it is recommended for transferring text files.
To transfer files in binary mode, enter:

The binary mode is more suitable for images, archives, and so on. In this mode, there is a lower chance of encountering errors during transfer.

Task: Connecting to Another FTP Server

To connect to another FTP server, use the open command:

Thus, we will connect to the FTP server ftp.yandex.ru. You should also know the username and password, but you can also use anonymous login if the server supports it.

Task: Closing an FTP session

Simply enter quit or bye

or

 

How can I learn more about FTP server commands?

Type ? or help to learn more about FTP commands.

You can get a brief description of each command:

Output:

That's basically it. We have covered the main commands. Now you will be able to handle FTP from the command line without any problems.

Note: This post may be AI-assisted and then human-edited. Editorial responsibility: Dmytro Lomaka, Kaltenkirchen.

Categories: FTP