tftp Command in Linux



The tftp command in Linux is a user-level client for the Trivial File Transfer Protocol (TFTP). TFTP is a simple protocol used for transferring files. TFTP is a simplified, older form of FTP used for uploading or downloading files between network hosts. It operates over UDP port 69, a connectionless protocol that enables data transfer without establishing a fixed session, making it less reliable than connection-oriented alternatives. It is primarily used in local area networks.

Table of Contents

Here is a comprehensive guide to the options available with the tftp command in Linux −

Caution − The tftp command allows file transfers over UDP without authentication or encryption. Use only in secure, trusted networks, and ensure proper server access controls are in place.

Installation tftp Command

The tftp client is not installed by default on most Linux distributions. Make sure the package is installed before using the command. To install it on Ubuntu, Kali Linux, Raspberry Pi OS, Debian, and other Debian-based distributions, use the following command −

sudo apt install tftp-hpa

To install it on Arch Linux, use the command below −

sudo pacman -S tftp

To install tftp client on Fedora, use the following command −

sudo dnf install tftp

To verify the installation of the tftp client, check its version using the command −

tftp -V
tftp Command in Linux1

Syntax of tftp Command in Linux

The syntax of the tftp command in Linux is as follows −

tftp [options] [host]

In the above syntax, the [options] field is used to specify the options that are listed in the following section. The [host] field is used to specify the IP address or hostname of the TFTP server.

tftp Command Options

The options for the Linux tftp command are listed below −

Options Description
-4 Use IPv4 only, even if IPv6 is available.
-6 Use IPv6 only if compiled in.
-c <cmd> Execute a command as if entered at the TFTP prompt (must be the last argument).
-l Enable literal mode to prevent special handling of ":" in filenames.
-m <mode> Set default transfer mode (often used with -c).
-R a:b Force the originating port number to be within the range a to b.
-v Enable verbose mode by default.
-V Print version and configuration, then exit.

How to Use TFTP Command in Linux?

This section explores how to use the tftp command in Linux with examples −

Using TFTP Client in Interactive Mode

To connect to a TFTP server, use the tftp command followed by the host IP address −

tftp 192.168.24.1
tftp Command in Linux2

An interactive mode will begin. To list the interactive mode supported commands, type help and press Enter

help
tftp Command in Linux3

To check the status, use the status command −

status
tftp Command in Linux4

To set the verbose mode, use the verbose command −

verbose
tftp Command in Linux5

To set per-packet transmission time, use the rexmt command −

rexmt 5

To modify the total transmission timeout, use the timeout command followed by the number of seconds −

timeout 30

To download the file from the server, use the get command −

get file.txt
tftp Command in Linux6

To receive multiple files, use the get command followed by filenames −

get file1.txt file2.txt

Similarly, to upload the file, use the put command −

put file.txt

To get multiple files, simply specify the filenames.

To enable the packet tracing mode, use the trace command −

trace
tftp Command in Linux7

To get help about a specific command, use the help or ? followed by the command −

? put
tftp Command in Linux8

To quit the tftp interactive mode, use the following command −

quit

Using the TFTP Client with One-Line Commands

To use the tftp client in one line, use the following command −

tftp -v 192.168.64.1 -c file.txt
tftp Command in Linux9

The above command is receiving the file from the server. To use a specific mode −

tftp -v -m binary 192.168.64.1 -c get file.txt

Conclusion

The tftp command in Linux is a simple tool for transferring files using the Trivial File Transfer Protocol, commonly used in trusted local networks. It operates without authentication or encryption over UDP port 69, making it suitable only for secure environments.

This tutorial explained how to install the tftp client on various Linux distributions, described its syntax and options, and demonstrated both interactive and one-line command usage for uploading and downloading files.

Advertisements