How to quit telnet

The telnet utility, a once common protocol that graced the terminal of every system administrator and power user, was a precursor for the SSH protocol. Since telnet sends all data, including usernames and passwords, over the network in clear text, it is not often used anymore. Despite the other protocols that have come to replace it, telnet remains an ideal utility to test the connection to a certain port of a device, and can be handy in other niche scenarios, or even send an email.

After establishing a successful telnet connection, you will eventually want to quit out and return to your regular terminal. In this tutorial, we will show you how to quit a telnet session on a Linux system.

In this tutorial you will learn:

  • How to quit telnet
How to quit telnet
How to quit telnet
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software telnet
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to quit telnet on Linux step by step instructions

  1. First, let’s use the telnet command to connect to a listening service:
    $ telnet 80
    Connected to
    Escape character is '^]'.

    You will notice in the above output, the last line which says Escape character is '^]'.. In Linux, the ^ character is commonly used to represent the Ctrl key on your keyboard. So, this text is telling us that pressing the ] key while holding down Ctrl is an escape sequence.

  2. By escaping from the telnet connection, we can pass different commands to telnet while not interfering with the connection that we already have established. So, let’s use the Ctrl + ] combination.

    As you can see, the telnet prompt has changed, which indicates that we have entered command mode and can pass other commands to telnet, independent of the stream we have open.

  3. This mode will accept the quit command, which tells telnet to close the connection we have open. Our terminal will then return to a regular prompt, outside of telnet.
    telnet> quit
    Connection closed.
Quitting from a telnet connection in Linux
Quitting from a telnet connection in Linux
The steps above show the proper and intended way to quit out of a telnet connection. However, to quit more quickly (and less gracefully), you could also use the Ctrl + C combination. This is a well known key combo which can be used to immediately quit out of the majority of running processes in your Linux terminal.

Closing Thoughts

In this tutorial, we saw how to quit out of a telnet connection on a Linux system. Although telnet is not commonly used these days, knowing some basics about the command can be super handy for Linux administrators that need a quick, no frills tool to test the connectivity to a certain port on a local or remote server.