How to use the telnet command in Linux


Telnet is an application protocol used on the Internet or local area network to provide a bidirectional interactive text-oriented communication facility using a virtual terminal connection. User data is interspersed in-band with Telnet control information in an 8-bit byte oriented data connection over the Transmission Control Protocol (TCP).

Installing Telnet Client on Linux

RHEL / CentOS / Fedora
dnf install telnet
Ubuntu / Debian
apt-get install telnet
telnet 80
Trying ...
Connected to
Escape character is '^]'.
Connection closed by foreign host.
Telnet client
telnet --help
info telnet
man telnet
GET /path/to/file.html HTTP/1.1
Connection: close

The syntax for the telnet command is as follows:

  telnet [-468EFKLacdfrx] [-X authtype] [-b hostalias] [-e escapechar] [-k realm] [-l user] [-n tracefile] [host [port]]

Force IPv4 address resolution.
Force IPv6 address resolution.
Strip 8th bit on input and output. Telnet is 8-bit clean by default but doesn't send the TELNET BINARY option unless forced.
Specifies an 8-bit data path. This causes an attempt to negotiate the TELNET BINARY option on both input and output.
Stops any character from being recognized as an escape character.
If Kerberos V5 authentication is being used, the -F option allows the local credentials to be forwarded to the remote system, including any cre‐dentials that have already been forwarded into the local environment.
Specifies no automatic login to the remote system.
Specifies an 8-bit data path on output. This causes the BINARY option to be negotiated on output.
-X atype
Disables the atype type of authentication.
Attempt automatic login. Currently, this sends the user name via the USER variable of the ENVIRON option if supported by the remote system. The name used is that of the current user as returned by getlogin(2) if it agrees with the current user ID, otherwise it is the name associated with the user ID.
-b hostalias
Uses bind(2) on the local socket to bind it to an aliased address (see ifconfig(8) and the ''alias'' specifier) or to the address of another interface than the one naturally chosen by connect(2). This can be useful when connecting to services which use IP addresses for authentication and reconfiguration of the server is undesirable (or impossible).
Disables the reading of the user's .telnetrc file. (See the toggle skiprc command on this man page.)
Sets the initial value of the debug toggle to TRUE.
-e escapechar
Sets the initial telnet escape character to escapechar. If escapechar is omitted, then there will be no escape character.
If Kerberos V5 authentication is being used, the -f option allows the local credentials to be forwarded to the remote system.
-k realm
If Kerberos authentication is being used, the -k option requests that telnet obtain tickets for the remote host in realm realm instead of the remote host's realm, as determined by krb_realmofhost.
-l user
When connecting to the remote system, if the remote system understands the ENVIRON option, then user will be sent to the remote system as the value for the variable USER. This option implies the -a option. This option may also be used with the open command.
-n tracefile
Opens tracefile for recording trace information. See the set tracefile command below.
Specifies a user interface similar to rlogin(1). In this mode, the escape character is set to the tilde (~) character, unless modified by the -e option.
Turns on encryption of the data stream if possible.
Indicates the official name, an alias, or the Internet address of a remote host.
Indicates a port number (address of an application). If a number is not specified, the default telnet port is used.

Related Tags