How to find out information about a LXC (Linux container) CPU & Memory Usage

How can I find out information about a Linux container (LXC) such as CPU usage and memory usage from the command prompt? Is there is top command like a tool for lxc to monitor memory and cpu usage?

You need to use the lxc-info command to display the following information about a LXC:

    Tutorial details
    Difficulty Easy (rss)
    Root privileges Yes
    Requirements LXC+host
    Time 2m
  1. CPU usage in seconds.
  2. Block I/O usage.
  3. Memory usage.
  4. Kmem (kernel memory) usage.
  5. Networking TX/RX usage.

lxc-info syntax and example

The syntax is:

lxc-info -n {container-name-here}
lxc-info [options] -n {container-name-here}

To display information for cyberciti container, enter:

# lxc-info -n cyberciti

Fig.01: lxc-info in action

Show information for all containers whose name starts with nixcraft, run:

# lxc-info -n 'nixcraft.*'

Just print the container’s state

# lxc-info -s -n lxcdb

Just print the container’s pid

# lxc-info -p -n lxmemcache

ust print the container’s IP addresses

# lxc-info -i -n lxnginx

Say hello to lxc-top

You can use the lxc-top command to monitor container statistics. The output is updated every 3 seconds and is ordered according to the sortby value given by the user. The syntax is:

lxc-top [options]

Set amount of time in seconds to delay between screen updates:
# lxc-top --delay 5
To Sort the containers by name, cpu use, or memory use. The sortby argument should be one of the letters n,c,b,m,k to sort by name, cpu use, block I/O, memory, or kernel memory use respectively. The default is ‘n’.
# lxc-top --sort {sortby}
## [ CPU usage ] # lxc-top --sort c
## [ memory usage ] # lxc-top --sort m

htop cgroup option

First, install htop on a Linux operating system using the yum or apt-get:
$ sudo apt-get install htop
$ sudo yum install htop
Start the htop, enter:
# htop
Press F2 special key to enter into setup mode. Choose SETUP > Columns > Choose CGGROUP from Available Columns > Press F10 to save the changes:

Fig.02: Display htop cgroups columns on a Linux

You should see output as follows:

Fig.03: htop in action

🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron 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
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • Kristian Kirilov Sep 3, 2015 @ 9:31

    Thanks a lot!

  • Ahmad Sep 30, 2015 @ 14:11

    Thanks that was very helpful. a question if lxc-top is missing how can I install this option.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @