Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Use the Telnet Command in Linux

Install telnet and use it to test connections to ports on remote machines.

How-To Guides2 min read4 steps1 screenshot
The telnet command in Linux

What is Telnet

Telnet is an old protocol and command to connect to a remote machine on a TCP port, by default port 23.

Features

  1. Simple. It is a quick way to test whether a port is reachable.
  2. Interactive. You can type text to services such as a web server, SMTP or POP3 server and see the reply.

Limitations

  1. No security. Telnet sends everything, including passwords, as plain text.
  2. Replaced by SSH, which does the same job with encryption.

Use telnet today to test ports and talk to text-based services, not to log in to servers.

Install Telnet

Debian and Ubuntu:

sudo apt update && sudo apt install telnet

CentOS and Red Hat:

sudo yum install telnet

Fedora:

sudo dnf install telnet

Test a port

telnet example.com 80
  • Connected to example.com. means the port is open.
  • Connection refused means nothing listens on the port.
  • A long wait means a firewall probably drops the traffic.

To leave, press Ctrl+] and type quit.

Talk to a web server

telnet example.com 80
GET / HTTP/1.1
Host: example.com

Press Enter twice. The server answers with its headers and page.

Test a mail server

telnet mail.example.com 25
EHLO test.example.com
QUIT

Installing a Telnet server (telnetd) is not recommended. If you need remote login use SSH. If you must test, install it only on a closed network and remove it afterwards.

Other tools to test a port

nc -vz example.com 80

nc (netcat) does the same and does not need the old client.

Quick recap

  • telnet host port tests a TCP port.
  • Do not use Telnet for logins; use SSH.