Is there a command to check if the container services are running on a Linux system? Someone suggested unshare but I am not sure if that is the best way to do it.
- 722
- 2
- 8
- 23
2 Answers
UPDATE: Upon re-reading your question, I realized that I had answered a slightly different one. You want to know whether a service is running, and I had originally answered how to tell if a package was installed. To answer your actual question, it depends upon your init system.
systemd - the basic command is
systemctl, which will list all services and their states, so you could either manually browse it manually or pipe it through agrepcommand, like so:systemctl | grep -e cgmanager -e cgproxy -e cgroupfs-mount. Or, as user muru suggests in the comments, simplysystemctl status 'cg*'.sysVinit - the basic command is
service --status-alland the grep command would beservice --status-all 2>&1 | grep -e cgmanager -e cgproxy -e cgroupfs-mount. Note that in this case, running services are denoted with a[+]prefix symbol. Also note that for the grep to work, the redirect2>&1must be made for theservicecommand.
ORIGINAL ANSWER:
Maybe the simplest thing to do is try
man cgroups. If that brings up a documentation page, then your host has the package installed. However, some installs are 'stingy' and don't installmanpages.You could try
cgmand see if that produces output. Most installs ofcgroupswill include that command, but not necessarily.You could look up the package list of your host distribution. On debian derivatives, that would be
dpkg -l |grep cgroup, but occasionally a system will restrict access torootorsudofordpkg.
There will be a lot of other ways.
- 2,648
- 19
- 27
- 3,028
- 12
- 23
-
7These all work. You can also `cat /proc/mounts` and you'll see several `cgroups` mounted in `/sys/fs/cgroup`. For `Fedora` and relatives, you can find the `libcgroup` and `libcgroup-tools` packages with `rpm -qa \*cgroup\*`. – Nasir Riley Mar 01 '18 at 01:59
-
2`systemctl` accepts wildcards, like so: `systemctl status 'cg*'` (or `systemctl list-units 'cg*'`) – muru Mar 01 '18 at 05:03
-
@muru - Thank you. I incorporated your comment into the answer. – user1404316 Mar 01 '18 at 05:08
You can check which cgroup features are enabled in kernel config with:
# zcat /proc/config.gz | grep CGROUP
CONFIG_CGROUPS=y
CONFIG_BLK_CGROUP=y
# CONFIG_DEBUG_BLK_CGROUP is not set
CONFIG_CGROUP_WRITEBACK=y
CONFIG_CGROUP_SCHED=y
CONFIG_CGROUP_PIDS=y
# CONFIG_CGROUP_RDMA is not set
# CONFIG_CGROUP_FREEZER is not set
CONFIG_CGROUP_HUGETLB=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_PERF=y
# CONFIG_CGROUP_DEBUG is not set
# CONFIG_SOCK_CGROUP_DATA is not set
# CONFIG_NETFILTER_XT_MATCH_CGROUP is not set
# CONFIG_CGROUP_NET_PRIO is not set
# CONFIG_CGROUP_NET_CLASSID is not set
(note: in order for /proc/config.gz to show up
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
need to be set)
- 203
- 1
- 2
- 5