Learning Center
Linux

How to Use Telnet Command on Linux

24 Jul 2025
Awais Khan
Awais Khan

The telnet command is a great and handy Linux network service communication utility. From remote server and system port scans, to debugging network connections, telnet offers easy text-based interaction with a remote host.

In this step by step guide, you can see how to install, configure, and utilize telnet on Linux server. We shall also discuss its various options and features so that you can have a complete idea.

What is Telnet?
Copy link

telnet, or "Telecommunication Network," is a remote network protocol on another computer over the Transmission Control Protocol (TCP). telnet provides the ability to directly specify the remote host on a particular port so that commands may be sent and output directly read in real time.

telnet is employed primarily for:

  • Testing Open Ports: Determine if a server has an open port.

  • Accessing Services: Get direct access to the web, e-mail, or other networked services.

  • Troubleshooting Network Issues: Fix network connectivity issues or port not available issues.

Installing Telnet on Linux
Copy link

telnet is not pre-installed on most modern Linux distributions. Installation depends on your system type.

For Ubuntu/Debian-Based Systems

An Ubuntu or any Debian-based Linux user can install telnet with the apt package manager:

sudo apt install telnet

For Red Hat/CentOS-Based Systems

telnet can be installed on RedHat, CentOS, or Fedora by using the yum or dnf package managers:

sudo yum install telnet

For newer versions:

sudo dnf install telnet

Understanding the Telnet Command Syntax
Copy link

The telnet command syntax is simple:

telnet [hostname/IP] [port]

Where:

  • [hostname/IP]: Specifies the hostname or IP address of the remote host.

  • [port]: Specifies the port number you want to connect to. It can be omitted, and the default port (23) is used. 

telnet establishes one direct connection to services on specific ports, like HTTP (port 80), SMTP (port 25), or FTP (port 21).

Different Options Available for the Telnet Command
Copy link

The telnet command is highly customizable, offering several options that enhance its usability and functionality.

Option

Description

-4

Forces telnet to use IPv4 only when establishing a connection.

-6

Forces telnet to use IPv6 only when connecting.

-8

Allows transfer of 8-bit data via telnet.

-E

Disables the telnet escape character operation, disallowing escape sequences during the session.

-K

Prevents telnet from automatically passing credentials (e.g., a Kerberos ticket) to the remote host.

-L

Enables the loopback mode so that telnet can connect to the same host.

-X atype

Specifies the authentication type (i.e., KERBEROS_V4) to be used during the telnet session.

-a

Automatically fills in the user's login name attempting to log onto the remote system.

-d

Enables debugging mode, providing detailed information about the connection process and communication.

-e char

Alters the escape character for telnet.

-l user

Specifies the username for the login attempt.

-n tracefile

Writes session activity to a specified trace file for debugging or logging.

-b addr 

Defines a local interface or address for telnet to use when connecting.

-r

Creates a reverse telnet connection.

Using Telnet: Practical Applications
Copy link

telnet provides diagnostic and testing capabilities for networks. Some of these include:

telnet is often used to verify if a specified port of a server is open. To verify port 80, enter the following command:

telnet example.com 80

Image2

If the port is open, telnet will connect, and you might have a blank screen expecting input. This is a good indication that the port is listening and expecting to chat. If the port is firewalled or closed, you would get an error message such as "Connection refused."

telnet can debug email servers by sending raw SMTP commands. To open an SMTP server on port 25:

telnet mail.example.com 587

Image5

Once connected, you can directly type SMTP commands such as HELO, MAIL FROM, and RCPT TO to communicate with the server. For example:

Image3

telnet enables manual HTTP requests to debug web servers. For example:

telnet example.com 80

Image4

After connecting, type:

GET / HTTP/1.1
Host: example.com

Press Enter twice to send the request, and the server's response will appear.

Image6

If the server supports both IPv4 and IPv6, you can force the connection to use IPv4:

telnet -4 example.com 80

Image1

This ensures compatibility with IPv4-only networks.

telnet can connect to a MySQL database server to check if the port is open (default port 3306).

telnet database.example.com 3306

Replace database.example.com with the MySQL server address. 

If the connection is successful, telnet will display a protocol-specific greeting message from the MySQL server.

Security Considerations When Using Telnet
Copy link

Although telnet is a handy utility, it is fundamentally unsafe since it sends the data, including passwords, in cleartext. Consequently:

  • Don't Use Telnet Over Unsecure Networks: Utilize a secure, private network whenever possible.

  • Use Alternatives: Use SSH (Secure Shell) for encrypted communication.

  • Restrict Access: Turn off telnet on your servers if you do not use it.

By understanding these risks, you can take precautions to secure your systems.

Exploring Advanced Telnet Use Cases
Copy link

telnet’s utility extends to a variety of specialized scenarios:

  • Monitoring Services: Use telnet to interactively query protocols like IMAP or POP3 to diagnose emails.

  • IoT Device Management: telnet can be utilized as an immediate interface to communicate with IoT devices that utilize text-based communication protocols.

  • Educational Use: It is an excellent learning tool for studying network protocols and server responses.

Troubleshooting Common Telnet Issues
Copy link

Despite its simplicity, telnet may run into issues such as:

  • Connection Refused: This would usually be so if the target port is firewalled or closed.

  • Time-Out Errors: These could reflect network delay or routing issues.

  • Permission Denied: Check appropriate user privilege and port availability.

Regularly checking server configurations and network settings can help resolve these issues.

Exploring Telnet Alternatives
Copy link

If telnet's lack of encryption is a security risk to your system, there are several alternatives that offer comparable functionality with added security and features:

  • SSH (Secure Shell): SSH is the most common telnet substitute, providing secured communication, tunneling, and strong authentication. Use the ssh command to securely connect to remote servers.

  • Netcat (nc): Netcat is a full-featured networking debugging tool, port scanner, and connection tester. It can handle both TCP and UDP.

  • OpenSSL S_client: OpenSSL can be utilized to test SSL/TLS protocols securely on particular ports.

Conclusion
Copy link

telnet in Linux is a simple and convenient network diagnostics and debugging tool. As long as you understand its security limitation and have sufficient configurations, telnet remains a convenient debugging tool, test tool, and communications tool for network services.

From this guide, you have a working configuration that strikes a balance between convenience and responsible caution. Get the best out of your Linux experience and control your systems securely and efficiently remotely.