Common OpenVZ Commands for System Administrators
Posted on February 25th, 2019
OpenVZ is a container-based virtualization technology for Linux and it is free open source software, available under GNU GPL. OpenVZ creates isolated, multiple secure Linux on a single physical server. Each container is also known as VPSs (Virtual Private Servers) and it performs and executes exactly like a standalone server. a container can be start/stop/rebooted independently and have root access, users, IP addresses, memory, processes, files, applications, system libraries and configuration files. These containers do not have individual kernels. This uses a single patched Linux kernel and it supports only Linux OSs.
In this tutorial, I will show you basic OpenVZ commands to manage containers.
To list all running containers.
vzlist
Here is the sample output.
[root@openvz02 ~]# vzlist
CTID NPROC STATUS IP_ADDR HOSTNAME
28387 99 running 162.00.00.01 vps.example.com
37743 49 running 162.00.00.02 srv.example.org
To list all running and stopped containers.
vzlist -a
Sample output:
root@openvz02 ~]# vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
28272 – stopped 162.00.00.05 exampledomain.org
28387 104 running 162.00.00.01 vps.example.com
37743 49 running 162.00.00.02 srv.example.org
To start a container.
vzctl start CTID
example:
vzctl start 141
To stop container.
vzctl stop CTID
example:
vzctl stop 141
To restart container
vzctl restart CTID
example:
vzctl restart 141
Logging into the container from node.
vzctl enter CTID
example:
vzctl enter 141
To delete a container.
vzctl destroy CTID
example:
vzctl destroy 141
To suspend a container.
vzctl suspend CTID
example:
vzctl suspend 141
To set a hostname for a container.
vzctl set CTID –hostname new_hostname –save
example:
vzctl set 141 –hostname server.example.com –save
To add a new IP to a container.
vzctl set CTID –ipadd xx.xx.xx.xx –save
To delete an IP from container.
vzctl set CTID –ipdel xx.xx.xx.xx –save
To reset the root password of a container.
vzctl set CTID –userpasswd root:new_password –save
To add a new nameserver IPs to VPS
vzctl set CTID –nameserver xx.xx.xx.xx –save
To execute a command from the node.
vzctl exec CTID command
example:
vzctl exec 141 ls /root
To check resource usage of the container.
vzcalc -v CTID
If you need any further help, please do reach our support department.