What is ftp command in linux

FTP Client Linux Command-Line Tutorial

FTP (File Transfer Protocol) is a protocol for transferring files over a network. In the past, FTP was the preferred method for transferring the data between computers. However, this is no longer the case. The main problems that FTP used to have are solved by the newer protocols and programs.

What Will We See Here?

In this article, we will explore how to use the ftp command for remote system connection, file transfer, and managing the remote and local files and directories.

What Will We Need?

  1. Access to a remote FTP server from the local system. To keep it simple, we use a VirtualBox environment.
  2. FTP components are installed on both the local and remote systems.

NOTE: Since the FTP traffic is unencrypted, it is therefore an unsecured service. We thus recommend not to use it to transfer sensitive data over the internet and other unreliable networks.

FTP Command Syntax

The FTP command has the following syntax:

Here, [IP] denotes the IP address of the target remote system.

The FTP command uses the FTP protocol to connect a system to another system, which is usually a remote server, using the FTP protocol.

After a connection is established, users can also transfer files between the connected systems and manage the files and directories on them.

Creating an FTP Connection

We can create an FTP connection to a remote server using it’s IP address along with the FTP command:

For example, to connect to a remote server with the 192.168.56.10 IP address, run the following command:

When prompted, enter the credentials for the FTP user. Let’s see a live example of logging into an FTP server.

FTP Logging a Server

As soon as we establish a connection to the FTP server, we need to enter the username and the password to log in:

After entering the right credentials, we should be on the FTP interface:

Alternatively, we can first run the FTP command. Then, use the following command on the FTP interface:

From this interface, we can interact with the local machine as well as the remote server. We will soon see this in the following sections.

Listing the FTP Commands

Once we are inside the FTP interface, we can see and use all its commands. Let’s see all the supported commands by simply entering the “?”:

This represents us with many commands like dir, ls, disconnect, and so on. Let’s take a hand on a bunch of them.

Listing the Directory Contents

Let’s first see how we can list the content of the current directory on the remote system like the FTP server. Simply use the dir command here:

As mentioned earlier, we can manage the local machine from the remote machine. Let’s see how we can display the contents of the local directory:

Читайте также:  Лучший консольный браузер linux

The previous command displays the contents of our local system. To get more detailed listing, we can run the following command:

Similar to pwd which displays the current directory path, we can use the lcd command to display the same local path from the remote machine:

Changing the Current Directory

To navigate to the other directories on the remote server, we can use the usual cd command. For example, from the remote directories that are listed previously, we can change to the directory upload:

Uploading the Files

We can use the put command to send a single file to a remote server. Let’s see how to do this by simply uploading a from_local.txt local file:

After the command is successful, we will see a message like “Transfer complete”. By default, the file lands in the current directory on the remote server. However, we can customize this location by specifying the full path:

We can also use the dot (.) separator to denote the current path:

Let’s now see how to deal with multiple file uploads. We can use the FTP mput command to upload multiple files. For this, we need to specify the file names separated by spaces:

Interestingly, we can use the wildcards here if the file names share something in common. For example, to upload all the files with the name file but with different types, we can use the following command:

Before you can upload the files, you have to enter “yes” to confirm your action.

Downloading the Files

Let’s see how to download the files from the remote server to the local system. Instead of using put, we need to use its antonym like get. For instance, we can download/send a file, say file3.txt, to the local system as follows:

As seen in the uploaded scenario, we can also download a file to the directories other than the current directory on the local system. Just specify the full path on the local system:

Similar to mput, we can use the mget command to download multiple files. Again, let’s see it in action:

Also, the wildcards can simplify our work for similar types of files:

Conclusion

In this article, we cover a high-level overview of the FTP command on Linux. Besides the FTP client, there are other FTP clients for Linux such as Lftp, FileZilla, etc.

About the author

Ali Imran Nagori

Ali imran is a technical writer and Linux enthusiast who loves to write about Linux system administration and related technologies. You can connect with him on LinkedIn
.

Источник

How to Use the Linux ftp Command

FTP (File Transfer Protocol) is a network protocol used for transferring files from one computer system to another. Even though the safety of FTP tends to spark a lot of discussion, it is still an effective method of transferring files within a secure network.

In this tutorial, we will show you how to use the ftp command to connect to a remote system, transfer files, and manage files and directories.

Читайте также:  Install spawn in linux

How to use the ftp command in Linux

  • Access to a local system and a remote FTP server (learn how to install an FTP server on Ubuntu, CentOS 7, or Raspberry Pi).
  • A working Internet connection.
  • Access to the terminal window.

IMPORTANT: FTP traffic is not encrypted and is thus considered unsafe. It is not recommended to transfer files over the Internet using FTP. To learn more about secure alternatives to FTP, have a look at our articles on SFTP and TSL vs. SSL.

Linux ftp Command Syntax

The Linux ftp command uses the following basic syntax:

The IP is the IP address of the system you are connecting to.

The options available for the ftp command are:

FTP Command Options Description
-4 Use only IPv4.
-6 Use only IPv6.
-e Disables command editing and history support.
-p Uses passive mode for data transfers, allowing you to use FTP despite a firewall that might prevent it.
-i Turns off interactive prompting during multiple file transfers.
-n Disables auto-login attempts on initial connection.
-g Disables file name globbing.
-v Enables verbose output.
-d Enables debugging.

The ftp command connects you to a remote system and initiates the FTP interface. The FTP interface uses the following commands to manage and transfer files to the remote system:

Command Description
! Temporarily escape to the local shell.
$ Execute a macro.
? Display help text.
account Supply a password for the remote system.
append Append a local file to a file on the remote system.
ascii Set the file transfer type to network ASCII (default type).
bell Enable a sound alert after each transfer is complete.
binary Set the file transfer type to binary image transfer.
bye Exit the FTP interface.
case Toggle upper/lower case sensitivity when ID mapping during the mget command.
cd Change the current working directory on the remote system.
cdup Change to the parent of the current working directory on the remote system.
chmod Change file permissions on the remote system.
close Exit the FTP interface.
cr Toggle carriage return stripping on ASCII file transfers.
debug Toggle debugging mode.
delete Delete a file from the remote system.
dir List the contents of a directory on the remote system.
disconnect Terminate the FTP session.
exit Terminate the FTP session and exit the FTP interface.
form Set the file transfer format.
get Transfer a file from the remote system to the local machine.
glob Toggle meta character expansion of local file names.
hash Toggle displaying the hash sign («#«) for each transferred data block.
help Display help text.
idle Set an inactivity timer for the remote system.
image Set the file transfer type to binary image transfer.
ipany Allow any type of IP address.
ipv4 Only allow IPv4 addresses.
ipv6 Only allow IPv6 addresses.
lcd Change the current working directory on the local machine.
ls List the contents of a directory on the remote system.
macdef Define a macro.
mdelete Delete multiple files on the remote system.
mdir List the contents of multiple directories on the remote system.
mget Transfer multiple files from the remote system to the local machine.
mkdir Create a directory on the remote system.
mls List the contents of multiple directories on the remote system.
mode Set the file transfer mode.
modtime Show the last time a file on the remote system was modified.
mput Transfer multiple files from the local machine to the remote system.
newer Transfer a file from the remote system to the local machine only if the modification time of the remote file is more recent than that of the local file (if a local version of the file doesn’t exist, the remote file is automatically considered newer).
nlist List the contents of a directory on the remote system.
nmap Set templates for default file name mapping.
ntrans Set translation table for default file name mapping.
open Establish a connection with an FTP server.
passive Enable passive transfer mode.
prompt Force interactive prompts when transferring multiple files.
proxy Execute command on an alternate (proxy) connection.
put Transfer a file from the local machine to the remote system.
pwd Display the current working directory on the remote system.
qc Toggle displaying a control character («?«) in the output of ASCII type commands.
quit Terminate the FTP session and exit the FTP interface.
quote Specify a command as an argument and send it to the FTP server.
recv Transfer a file from the remote system to the local machine.
reget Transfer a file from the remote system to the local machine if the local file is smaller than the remote file. The transfer starts at the end of the local file. If there is no local version of the file, the command doesn’t execute.
rename Rename a file on the remote system.
reset Clear queued command replies.
restart Restart a file transfer command at a set marker.
rhelp Display help text for the remote system.
rmdir Remove a directory on the remote system.
rstatus Show the status of the remote system.
runique Toggle storing files on the local machine with unique filenames.
send Transfer a file from the local machine to the remote system.
sendport Toggle the use of PORT commands.
site Specify a command as an argument and send it to the FTP server as a SITE command.
size Display the size of a file on the remote system.
status Show the status of the FTP interface.
struct Set the file transfer structure.
sunique Toggle storing files on the remote system with unique filenames.
system Show the operating system on the remote system.
tenex Set the file transfer type to allow connecting to TENEX machines.
tick Toggle printing byte counter during transfers.
trace Toggle packet tracing.
type Set a file transfer type.
umask Set a default permissions mask for the local machine.
user Provide username and password for the remote FTP server.
verbose Toggle verbose output.
Читайте также:  Linux delete dir and files

How to Use ftp Command in Linux

The ftp command connects a computer system to a remote server using the FTP protocol. Once connected, it also lets users transfer files between the local machine and the remote system, and manage files and directories on the remote system.

Establish an FTP Connection

To establish an FTP connection to a remote system, use the ftp command with the remote system’s IP address:

For instance, connecting to a remote server with the IP address 192.168.100.9:

Источник

Оцените статью
Adblock
detector