I have a Linux server with services running inside systemd containers. To access the shell inside a container, I can use the command machinectl login <container>. That command will give me the container's login prompt and this message:

Connected to container <name>. Press ^] three times within 1s to exit session.

After I'm done and type exit or logout, I'm returned to the container's login prompt. In order to get back to the host's shell, I need to send the control character ^] (three times within one second).

I'm using an international (Finnish) keyboard and instead of having its own dedicated key, the ] character is +9. But when I press ctrl++9, it's not recognized as the control character ^] and I'm stuck at the login prompt.

How can I send a proper ^] control character with an international keyboard?


There might be a more direct solution, but here's the one I found.

If you go to
TerminalPreferences...Profiles → the profile you're using → Keyboard
you'll get a list of mappings between function keys and special keystrokes.

Terminal Preferences

We want to add the ^] to this list, so click on +, and choose the key, and optionally modifier, you would like use. (I went with ctrl+F12, and since F12 is also the key for volume up, what I actually need to press is fn+ctrl+F12.)

In the text field, we need to enter the correct control character, but the thing is, ctrl++9 is not recognized here either. The solution is to directly paste in the correct octal code, which happens to be \035 (you can copy&paste it from here).

Keyboard Mapping

Now pressing fn+ctrl+F12 sends the proper ^] control character, and I can get back to the host's shell.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .