Preparing for Java and Spring Boot Interview?

Join my Newsletter, its FREE

Sunday, July 25, 2021

How to close telnet terminal in Linux and Windows (quit, exit not working)? Example

The telnet is one of the most useful Linux networking commands, which is used to check if a server is listening on a particular port and it's whether up and running or not, but it's a little bit tricky to use, especially, if you are not using it on daily basis. Though I have used telnet before, when I use it after a long time, I actually forgot how to close the telnet terminal and how to get out of it. I tried every possible  Linux commands I can think of which is used to close, cancel a command, or exit from VIM editor in UNIX, like  Ctrl + C, quit, exit, q! and even the escape character '^]', only to realize that nothing is working. It may sound silly that an experienced developer cannot even come out of a telnet terminal but this is a true story. 

What I have noticed in general is that, even though we learn new things when our experience grows, we actually forget something equally important as well, particularly if we don't use that thing or command on daily basis.

Our mind is trained to keep only important stuff in memory, if a particular thing, particular knowledge or concept is not used for a long time and doesn't find very important something like life or death, it slowly offloads it.  The trick here is to revise and reuse it once in a while.

I finally managed to come out from the telnet command prompt after a bit of struggle, and trial and error but I was surprised how difficult it can be to use one of the top 10 networking commands in UNIX.

So, not to forget again and to help anyone who is stuck in the same situation, I decided to share my thoughts in this post.

Let's see the exact command to close the telnet terminal in Linux and Windows 10.  Though, keep referring a good UNIX command course like Linux Command Line Basics not to forget important commands like telnet.

How to close telnet terminal in Linux and Windows

Before looking at how to come out of the telnet command prompt, let's first look at how not paying enough attention and thinking that every command will work same way can confuse you easily.

$ telnet 8080
Connected to (
Escape character is '^]'.


You can see below that I had tried everything I could to come out of telnet windows but nothing worked, but had I paid attention to the telnet message that  "Escape character is '^]'", I would have probably been able to come out of telnet terminal earlier.

The trick here is you need to first type escape character e.g. '^]' which is 'Ctrl + ]' and then type quit to close the telnet terminal in Linux or any UNIX system.

I expect the same command will work on Windows and Mac also as telnet is ubiquitous and you will find telnet command in a host of the operating system including the big three e.g. Linux, Windows, and Mac. See these Best Websites to learn Linux for FREE to learn more about basic commands like telnet command in UNIX/Linux.

How to close telnet terminal in Linux and Windows (quit, exit not working)

Here are the exact steps to end a telnet session in Linux and Windows :

1. Open the telnet prompt by holding down the ‘Ctrl’ key and push the ‘]’ key. (prompt: Microsoft Telnet>)
2. Type quit.
3. Push the ‘Enter’ key.

The telnet is an extremely useful command and is used a lot in client-server applications e.g. you can use this to solve connection refused error in Java, which is mostly due to incorrect client-server communication.

In the electronic trading and FIX protocol world, telnet is a great tool to diagnose FIX session connection issues as described in this article.

How to come out of telnet command prompt

You can even use telnet to check if your own HTTP server is running or not as I have discussed when talked about building HTTP server in Java, here.

That's all about how to exit from the telnet terminal on Windows or Linux. As I told its one of the must-know networking commands and is available on almost all operating system. When you don't use it regularly sometimes it becomes tricky to operate as shown in this article, but just remember that you need to first type escape character to actually type command in telnet, while it is connected to a server.

Other Linux command tutorials for Java Programmers
  • 10 examples of lsof commands in UNIX (examples)
  • 10 basic networking commands in Linux (list)
  • How to send an HTTP request from the Linux command prompt? (command)
  • 10 examples of chmod command in UNIX (examples)
  • 10 examples of xargs command in UNIX? (examples)
  • 10 UNIX and Linux command-based questions from Interviews (list)
  • 10 Examples of curl command in Linux (examples)
  • 5 Courses to learn Bash Scripting in Linux (Courses)
  • How to find the largest file and directory in Linux (tutorial)
  • How to find which process is using a port in Linux (tutorial)
  • 10 Tips to work fast in Linux (tips)
  • 5 Free Courses to Learn Linux Online (courses)
  • Practical Guide to Linux Commands (book

Thanks for reading this article so far. If you like these Linux command tutorial then please share with your friends and colleagues. If you have any questions or feedback then please dro a note.


Anonymous said...

was not easy trying to exit out of telnet. thanks!

Anonymous said...

Just sat here for a few minutes staring at the telnet window thinking "how do I exit telnet". Googled, read this and laughed. TY :)

javin paul said...

You are not alone Anonymous, I even myself written this article forgot to exit from telnet, VI, ftp etc. Glad that you find it useful

Anonymous said...

Thanks!! Great tip. the " CTRL + ] " & then typing "quit" worked great.

Post a Comment