Linux exit from lxc-console keyboard shortcut

last updated in Categories , ,

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:

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.

ADVERTISEMENTS

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive

1 comment

    Still, have a question? Get help on our forum!