15+ Commonly using OpenVZ commands and its usages

OpenVZ is a container based, OS level virtualization technique for Linux. OpenVZ creates multiple secure, isolated Linux containers (otherwise known as VEs or VPSs) on a single physical server. Each container performs and executes exactly like a stand-alone server.

These isolated OSs are called containers or virtual private servers. These containers does not have kernels. The OpenVZ uses a single patched Linux kernel and therefore it can only support Linux OSs. Other virtualization technologies like XEN, VMware, KVM etc provide full virtualization and can run multiple OSs and different kernel versions.

This type of virtualization is very fast and efficient. Memory allocation is soft in this virtualization technique, which means the memory allocated for a container is not dedicated. The memory allocated is virtual, it can be used by any other VMs on the node, if it’s free (not in use by the original VM).

A container can be rebooted independently and have root access, users, IP addresses, memory, processes, files, applications, system libraries and configuration files. Here I am listing some useful OpenVz commands with example.

Let’s start, here CTID representing the ID of a container (VPS – Virtual Private Server).

1, Command to list the running VPSs in a node

# vzlist


# vzlist
       106        104 running   xx.xx.xx.xx  server1.test.com	
       107         46 running   xx.xx.xx.xx  server2.test.com	
       108         83 running   xx.xx.xx.xx  server3.test.com
       109         86 running   xx.xx.xx.xx  server4.test.com

2, Command to list running and stopped VPSs in an node

This command lists all (running and stopped) the VPSs in a node.

# vzlist -a


# vzlist -a
        CTID      NPROC STATUS    IP_ADDR         HOSTNAME
       106        104 running   xx.xx.xx.xx  server1.test1.com	
       107         46 running   xx.xx.xx.xx  server2.test2.com	
       108         83 running   xx.xx.xx.xx  server3.test3.com
       109         86 running   xx.xx.xx.xx  server4.test4.com
       110          - stopped   xx.xx.xx.xx  server5.test5.com

Start, Stop and Restart

3, To start a VPS

# vzctl start CTID


# vzctl start 110

4, To stop or shutdown a VPS

# vzctl stop CTID


# vzctl stop 110

5, To view the status of a VPS

# vzctl status CTID


# vzctl status 110
CTID 116 exist unmounted down

6, To restart a VPS

# vzctl restart CTID


# vzctl restart 110

Logging into a container

7, To enter a VPS

# vzctl enter CTID


# vzctl enter 106
entered into CT 106

Suspend and delete a container

8, Delete a container

# vzctl destroy CTID

9, Suspending a container

# vzctl suspend CTID

Other operations

10, Set hostname for a Server

# vzctl set CTID --hostname New_hostname --save

11, Add new IP to VPS

# vzctl set CTID --ipadd xx.xx.xx.xx --save

12, Delete IP from VPS

# vzctl set CTID --ipdel xx.xx.xx.xx --save

13, Reset root password of a VPS

# vzctl set CTID --userpasswd root:new_password --save

14, To add NameServer IPs to VPS

# vzctl set CTID --nameserver xx.xx.xx.xx --save

15, Executes commands for a container from node

# vzctl exec CTID command


# vzctl exec 110 df -h
# vzctl exec 101 df -h 
Filesystem Size Used Avail Use% Mounted on
/dev/simfs 130G 89G 27G 78% /
none 8.0G 4.0K 8.0G 1% /dev
none 8.0G 0 8.0G 0% /dev/shm

16, To check the resource usages

# vzcalc -v CTID


# vzcalc -v 110
# vzcalc -v 101
Resource Current(%) Promised(%) Max(%)
Low Mem 1.53 182706895112.42 182706895112.42
Total RAM 33.79 n/a n/a
Mem + Swap 1.73 38695649865149.61 n/a
Alloc. Mem 2.95 38695649865149.61 38695649865149.61
Num. Proc 0.05 n/a 2395786836523892.00
Memory 33.79 38695649865149.61 2395786836523892.00

That’s it. 🙂

Also read;

1, Top website/server uptime/downtime online monitoring tools
2, Introduction to CloudLinux and installation guide
3, Introduction to CageFS and PHP Selector and installation – CloudLinux

Post navigation

Arunlal Ashok

Linux Systems Architect at Endurance International Group. I know her (Linux) since many years. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com

11 thoughts on “15+ Commonly using OpenVZ commands and its usages

  1. master centos 6, create vps Centos 7 error
    “[[email protected] ~]# /etc/init.d/network start
    Failed to get D-Bus connection: No such file or directory
    Starting network (via systemctl): Failed to get D-Bus connection: No such file or directory”
    Fix error

  2. Keep sharing basic commands for other like redhat, centos, ubuntu, vm platforms etc software and OS…..also email me and share important commands and basics…..

Leave a Reply

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