In this post, I would like to show you how to install TFTP server on a Ubuntu machine and how to use it.
TFTP, short from Trivial File Transfer Protocol, is a protocol that, as the name suggests, helps you transfer files between a TFTP client and a remote TFTP server. It is very easy to install TFTP and to implement it. “It is primarily used in the early stages of nodes booting from a local area network.” (Source: Wikipedia). TFTP is running on top of the UDP protocol and it is using the well-known port 69.
Table of Contents

Search for TFTP software
In Ubuntu, if you are looking for a specific software to install and you do not know which package contains it, you can run a command similar to the one below and check for available packets.
petru@petru-ubuntu:~$ apt-cache search tftp | grep tftp
erlang-tftp - Erlang/OTP TFTP client and server
python3-txtftp - Twisted-based TFTP implementation
tftp-hpa - HPA's tftp client
tftp-hpa-dbg - HPA's tftp (debug)
tftpd-hpa - HPA's tftp server
atftp - advanced TFTP client
atftpd - advanced TFTP server
golang-github-pin-tftp-dev - TFTP server and client library for Golang (library)
libnet-tftp-perl - Perl module for accessing TFTP servers
libnet-tftpd-perl - Perl extension for Trivial File Transfer Protocol Server
puppet-module-puppetlabs-tftp - Puppet module for managing tftp-hpa
python3-fbtftp - Framework to build dynamic TFTP servers (Python3)
tftp - transitional package
petru@petru-ubuntu:~$

Install TFTP
As you can see from the above results, there are multiple packages containing the tftp string. I will install the tftpd-hpa package.
To install the TFTP server, run the following command.
petru@petru-ubuntu:~$ sudo apt-get install tftpd-hpa
[sudo] password for petru:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
pxelinux
The following NEW packages will be installed:
tftpd-hpa
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 39.5 kB of archives.
After this operation, 116 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu lunar/main amd64 tftpd-hpa amd64 5.2+20150808-1.4 [39.5 kB]
Fetched 39.5 kB in 0s (142 kB/s)
Preconfiguring packages ...
Selecting previously unselected package tftpd-hpa.
(Reading database ... 167587 files and directories currently installed.)
Preparing to unpack .../tftpd-hpa_5.2+20150808-1.4_amd64.deb ...
Unpacking tftpd-hpa (5.2+20150808-1.4) ...
Setting up tftpd-hpa (5.2+20150808-1.4) ...
Processing triggers for man-db (2.11.2-1) ...
petru@petru-ubuntu:~$

Confirm that TFTP is up and running
After the package is installed, you need to check that the TFTP server is up and running.
petru@petru-ubuntu:~$ systemctl status tftpd-hpa.service
● tftpd-hpa.service - LSB: HPA's tftp server
Loaded: loaded (/etc/init.d/tftpd-hpa; generated)
Active: active (running) since Mon 2023-05-01 11:13:17 BST; 2min 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 3372 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=0/SUCCESS)
Tasks: 1 (limit: 4581)
Memory: 900.0K
CPU: 21ms
CGroup: /system.slice/tftpd-hpa.service
└─3380 /usr/sbin/in.tftpd --listen --user tftp --address :69 --secure /srv/tftp
May 01 11:13:17 petru-ubuntu systemd[1]: Starting tftpd-hpa.service - LSB: HPA's tftp server...
May 01 11:13:17 petru-ubuntu tftpd-hpa[3372]: * Starting HPA's tftpd in.tftpd
May 01 11:13:17 petru-ubuntu tftpd-hpa[3372]: ...done.
May 01 11:13:17 petru-ubuntu systemd[1]: Started tftpd-hpa.service - LSB: HPA's tftp server.
petru@petru-ubuntu:~$

From the systemctl command you can confirm that the TFTP service is running. Now, let’s check that the TFTP server is listening for new connections.
Run a similar command to the one below. If netstat is not installed on your machine, run the ss command.
petru@petru-ubuntu:~$ sudo netstat -lu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 localhost:domain 0.0.0.0:*
udp 0 0 localhost:domain 0.0.0.0:*
udp 0 0 0.0.0.0:tftp 0.0.0.0:*
udp 0 0 0.0.0.0:mdns 0.0.0.0:*
udp 0 0 0.0.0.0:40569 0.0.0.0:*
udp6 0 0 [::]:tftp [::]:*
udp6 0 0 [::]:43276 [::]:*
udp6 0 0 [::]:mdns [::]:*

To confirm that TFTP is running on the well-known port 69, add the -n option to the netstat command.
petru@petru-ubuntu:~$ sudo netstat -lun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 127.0.0.54:53 0.0.0.0:*
udp 0 0 127.0.0.53:53 0.0.0.0:*
udp 0 0 0.0.0.0:69 0.0.0.0:*
udp 0 0 0.0.0.0:5353 0.0.0.0:*
udp 0 0 0.0.0.0:40569 0.0.0.0:*
udp6 0 0 :::69 :::*
udp6 0 0 :::43276 :::*
udp6 0 0 :::5353 :::*

Check the default TFTP configuration
After you have confirmed that the TFTP is up and running, you can start to download files from your TFTP server.
In order to find out where you can place the files that you want to download with your TFTP client, you need to check the TFTP default configuration.
The TFTP default configuration in located in this file /etc/default/tftpd-hpa.
Run the below command to read the default configuration for your TFTP server.
petru@petru-ubuntu:~$ cat /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"

As you can see, you can place the files that you intend to download with your TFTP clients in the /srv/tftp directory. I created a test file and placed it in this directory.
petru@petru-ubuntu:~$ cd /srv/tftp/
petru@petru-ubuntu:/srv/tftp$ ls
test.txt
petru@petru-ubuntu:/srv/tftp$ cat test.txt
This is a test file. Checking if TFTP is working properly.
For more details visit www.gulian.uk
petru@petru-ubuntu:/srv/tftp$

Test the connectivity to the TFTP server
Everything is in place on the server side. It is time to check the TFTP client and download the test file.
I will check the connectivity to the TFTP server with the ping command.
pgulian@pgulian-ltm1 test-tftp % ping -c 2 172.16.10.60
PING 172.16.10.60 (172.16.10.60): 56 data bytes
64 bytes from 172.16.10.60: icmp_seq=0 ttl=64 time=0.641 ms
64 bytes from 172.16.10.60: icmp_seq=1 ttl=64 time=0.259 ms
--- 172.16.10.60 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.259/0.450/0.641/0.191 ms
pgulian@pgulian-ltm1 test-tftp %

Download a file from TFTP server
The TFTP server is reachable from my TFTP client. Next, connect to the TFTP server and download the test file.
pgulian@pgulian-ltm1 test-tftp % ls
pgulian@pgulian-ltm1 test-tftp % tftp 172.16.10.60
tftp> status
Connected to 172.16.10.60.
Mode: netascii Verbose: off Tracing: off
Rexmt-interval: 5 seconds, Max-timeout: 25 seconds
tftp>

If you do not know which commands are available, press ? for help.
tftp> ?
Commands may be abbreviated. Commands are:
connect connect to remote tftp
mode set file transfer mode
put send file
get receive file
quit exit tftp
verbose toggle verbose mode
blksize set an alternative blocksize (def. 512)
tsize toggle extended tsize option
trace toggle packet tracing
status show current status
binary set mode to octet
ascii set mode to netascii
rexmt set per-packet retransmission timeout
timeout set total retransmission timeout
tout toggle extended timeout option
? print help information
tftp>

Run the get command to download the file from the TFTP server and the quit command to terminate the connection to the TFTP server.
tftp> get test.txt
Received 100 bytes in 0.0 seconds
tftp> quit
pgulian@pgulian-ltm1 test-tftp % ls
test.txt
pgulian@pgulian-ltm1 test-tftp % cat test.txt
This is a test file. Checking if TFTP is working properly.
For more details visit www.gulian.uk
pgulian@pgulian-ltm1 test-tftp %

It seems that everything is working as it should. By following these instructions, you have installed TFTP server on a Ubuntu machine and worked with the TFTP client.
If you want to use FTP instead of TFTP, take a look at this post: FTP server – 5 essential steps to install it on Ubuntu.
I hope you find this post useful. Share it on your social media channels so that other people can read it too.
[…] How to install TFTP server on Ubuntu […]