Updated: 18 October 2026 · Applies to: telnet 0.17 on AlmaLinux 9.8 and 10.2, inetutils-telnet 2.5 on Ubuntu 24.04, 2.6 on Debian 13 and 2.7 on Ubuntu 26.04, tested; Rocky Linux and RHEL use the same package as AlmaLinux
To install telnet on Linux, install the telnet client package:
sudo apt install telnet # Ubuntu, Debian sudo dnf install telnet # AlmaLinux, Rocky Linux, RHEL
Then test whether a port answers with telnet HOST PORT, for example telnet mail.example.com 25. Today telnet is a quick port-testing tool. Do not install a telnet server for remote logins: it sends everything, including passwords, unencrypted. Use SSH for that.
CentOS 7 and CentOS Linux 8 are end of life; the yum install telnet command from older guides still works on AlmaLinux and Rocky Linux, because yum there is dnf.
1. Install the telnet client
- Check whether it is already there:
telneton a fresh AlmaLinux 10.2 or Debian 13 container image gavebash: telnet: command not found. - Install it for your distribution:
- Ubuntu and Debian:
sudo apt update && sudo apt install telnet. Thetelnetpackage is now a transitional package that pulls ininetutils-telnet(GNU inetutils), and/usr/bin/telnetpoints to/usr/bin/inetutils-telnet. We got version 2.5 on Ubuntu 24.04, 2.6 on Debian 13 and 2.7 on Ubuntu 26.04. - AlmaLinux, Rocky Linux and RHEL:
sudo dnf install telnetinstalls the classic client, version 0.17, from the AppStream repository.
- Ubuntu and Debian:
- Check the result with
telnet 127.0.0.1 25on a machine with no mail server: aConnection refusedmessage means the client works.
2. Test a port
telnet 198.51.100.5 25
What the answer means (lab output):
- Open port:
Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'.
Something listens and the firewall lets you in. Some services greet you at once: according to RFC 5321, a mail server opens with a line that starts with220. - Nothing listens on the port:
telnet: connect to address 127.0.0.1: Connection refused(AlmaLinux) ortelnet: Unable to connect to remote host: Connection refused(Debian and Ubuntu). The server answered, but no program uses that port. - No route to host: often a firewall that rejects you (firewalld does this by default for closed ports), or a routing problem.
- It hangs at
Trying 192.0.2.1...: no answer at all. Usually a firewall drops the packets, or the address is wrong or offline. PressCtrl+Cto stop. - Name not found:
telnet: nosuchhost.example: Temporary failure in name resolution(AlmaLinux) orServer lookup failure(Debian and Ubuntu). Check the host name and DNS.
Leave out the port and telnet uses port 23, the telnet port itself, which is rarely what you want.
3. Talk to the service
Once connected, what you type goes to the service. For a quick web server check, type a request line and press Enter twice:
$ telnet 127.0.0.1 8080 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. HEAD / HTTP/1.0 HTTP/1.0 200 OK Server: SimpleHTTP/0.6 Python/3.12.14 Content-type: text/html; charset=utf-8 Content-Length: 830 Connection closed by foreign host.
(lab output from a Python test server on AlmaLinux 10.2, the Date line removed; the request line and the empty line are what you type). This works only for plain-text services on ports such as 25, 80 or 110. For ports that start with TLS (443, 465, 993), telnet shows nothing useful; use openssl s_client -connect mail.example.com:465 instead. For mail tests, see SMTP port numbers explained. Port 25 is open on all Ucartz servers.
4. Leave telnet
If the service does not close the connection itself, press Ctrl+] to get the telnet> prompt, then type quit. On AlmaLinux 10.2 this printed telnet> Connection closed.
5. Alternatives that are often already installed
nc -zv 198.51.100.5 25reports open or closed and exits, which suits scripts: see how to check if a remote port is open with nc.timeout 5 bash -c 'exec 3<>/dev/tcp/198.51.100.5/25' && echo openneeds nothing but bash.- To see whether a program listens on a port of your own server, use
ss: how to check if a port is in use on Linux. If the port is closed by your firewall, see how to open a port in Linux.
6. Do not run a telnet server
The server packages still exist (telnet-server on AlmaLinux, Rocky Linux and RHEL; inetutils-telnetd and telnetd on Debian), but telnet logins send the password in clear text over the network. Use SSH instead. If you find one on a server you manage, stop and remove it, for example sudo systemctl disable --now telnet.socket and sudo dnf remove telnet-server, and close port 23 in the firewall.