Linux exit from lxc-console keyboard shortcut

I‘m using Debian Linux server with Linux Containers (lxc). How do I disconnect and exit from an lxc-console to a shell prompt without closing ssh session?

Linux Containers (LXC) is an operating-system-level virtualization method for running multiple isolated Linux systems (containers) on a control host using a single Linux kernel. You need to use the lxc-console command or lxc console {container} command to log in to a running Linux container. The syntax is as follows:
Tutorial details
DifficultyEasy (rss)
Root privilegesNo
Requirementslxc
TimeLess than a minute

ADVERTISEMENTS


lxc-console -n container-name
lxc-console -n webserver
lxc-console -n pgsql
lxc console c1-www
lxc console nginx-container

To exit an lxc-console from a shell prompt:

  1. Open a shell prompt.
  2. Login to a host server called server1.
  3. Use the lxc-console command to log in to a running container called ‘memcache’ type: lxc-console -n memcache
  4. To exit an lxc-console session, type Ctrl-A followed by Q.

Here is a sample session:

Gif.01: How to disconnect from lxc-console demo

Gif.01: How to disconnect from lxc-console demo

How do I exit from LXD based ‘lxc console’ session

LXD is a next generation system container manager. It offers a user experience similar to virtual machines but using Linux containers instead. The syntax is as follows:

  1. Open terminal window
  2. Another option is to log in into remote LXD server
  3. Use the ‘lxc console’ to log into a running container called ‘arch’: lxc console arch
  4. To detach and exit from the ‘lxc console’ command, press: <CTRL>+a q

Here is a sample session that shows how to disconnect from lxc console command from LXD:
How to exit from lxc console of LXD under Linux
LXD isn’t a rewrite of LXC, in fact it’s building on top of LXC to provide a new, better user experience. Under the hood, LXD uses LXC through liblxc and its Go binding to create and manage the containers. It’s basically an alternative to LXC’s tools and distribution template system with the added features that come from being controllable over the network.

Conclusion

You learned how to exit from lxc-console and ‘lxc console’ commands by pressing various command line under when using Linux containers such as lxc/LXD.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
Network Utilitiesdig host ip nmap
Package Managerapk apt
Processes Managementbg chroot disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w

ADVERTISEMENTS
1 comment… add one
  • huseyin May 28, 2015 @ 18:38

    thank you so much!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.