The text adventure game of exiting a telnet session

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, December 12, 2019

Follow me on Twitter as @mattiasgeniar

We’ve all been there, right? You debug something, you try telnet to see if a port is open, and now you’re stuck in a telnet session.

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


And the answer seems so obvious. It’s staring us right in the face!

Escape character is '^]'.

Good! There’s an escape sequence. This is like one of those text based adventure games. I can beat this!

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



So you carefully copy/paste the ^] text shown at the top. A caret and then a closing square bracket. That wasn’t too hard. But why isn’t this working?

Ah it turns out that ^ sign is a symbol. It represents the CTRL button on the keyboard. It’s a key combination that I have to press.

This is where the text adventure turns the difficulty level way up. My keyboard doesn’t have a ] sign on it. 😱

Azerty Belgian keyboard

It’s got all sorts of obscure markers though. What’s that § thing below the number 6? And how often do you need a ù? Clearly one of those should’ve been a ] button!

But have no fear, there are hidden key combo’s. On Mac I can type OPTION + SHIFT + ° and that produces ].

So the magic incantation to exit a telnet session has to be CMD + OPTION + SHIFT + °. That’s four (4) keys at the same time. Good thing we’ve been given 5 fingers! Something tells me the end-boss in this game is going to require 5 key combo’s.

Let’s go!

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



It’s a Unix system. I know this.

I bet that Jurassic Park girl knows how to quit a telnet session. I’ve only been managing Linux servers for 15 years, what the heck do I know?

OK Mattias, think. What are you missing in this game? You’re playing it in Belgium, but it was probably designed by someone from the US. Or Sweden.

What do those keyboards look like?

Qwerty US keyboard

Aha, they do have a dedicated key for the ] symbol. Spoiled little brats.

On to the text adventure: the key I’m looking for appears to be 2 keys to the right of P key. Good, let’s try!

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


telnet> quit
Connection closed.

I’ve won! I’ve beaten the end game! 🎉

Turns out, the magic key combination to exit a telnet session is CMD + that one weird key 2 positions to the right of the P. Unless you’re on a German keyboard. Then it’s one position to the right of P, not two. Because obviously.

★☆☆☆☆ — Lousy text adventure game, does not work.

The cheatcodes to beat the exit-a-telnet-session game

Most text adventure games have cheatcodes. I’ll provide the same for the how to exit a telnet session text adventure. If you’re stuck and want to quit, but you don’t have a ] on your keyboard, try one of those.

  • Dutch, Belgian: ctrl + $
  • French: ctrl + 6
  • Finnish, Swedish, Norwegian, Danish: ctrl + å
  • Swiss: ctrl + ¨
  • German: ctrl + ü
  • Hungarian: ctrl + 5
  • Portuguese: ctrl + ´
  • Canadian French: ctrl + ç

Or get a keyboard with a dedicated button.

Create your own text adventure telnet game!

You can create your own levels of the telnet game. Telnet allows you to set a custom escape character with the -e flag.

This would be especially diabolical if you were to, say, create a system-wide alias for telnet on all your servers to mess with your coworkers.

$ telnet -e x 8080
Connected to
Escape character is 'x'.


telnet> quit
Connection closed.

With the -e parameter you can give it a sane escape value. Or you could try to make the combo even worse with an alias and reverse the square bracket.

$ alias telnet='telnet -e ['

I’m not saying I would do that.

Playing the text adventure game

If you want to play the text adventure, telnet to a known nameserver. They respond to port 53 via UDP and TCP (for large DNS replies). Depending on the nameserver version they’re running, they don’t immediately close the connection if you send it garbage inputs.

$ telnet 53

Have fun!

Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.