List of general commands and usage OpenVZ

Its easy use OpenVZ to create a new container of VPS. Bellow we listing all of OpenVZ general commands and usage. You must have OpenVZ installed on your server host node.

Creating a new VPS

// Create new VPS 101 with the template centos-5.2-default

vzctl create 101 –ostemplate centos-5.2-default

// Add IP a.b.c.d to the VPS 101

vzctl set 101 –ipadd a.b.c.d –save

// Remove IP a.b.c.d from VPS 101

vzctl set 101 –ipdel a.b.c.d –save

// Add the nemaserver a.b.c.d to VPS 101

vzctl set 101 –nameserver a.b.c.d –save

// Set password 123456 for the 101 VPS

vzctl set 101 –userpasswd root:123456

// Set the VPS to start on server reboot

vzctl set 101 –onboot yes –save

// Allocate diskspace to the VPS 101 10G:11G means Softquota:Hardquota

vzctl set 101 –diskspace 10G:11G –save

// Add IP a.b.c.d to the VPS 101 and set the nameservers a.b.c.d to VPS 101

vzctl set 101 –ipadd a.b.c.d –nameserver a.b.c.d –save

Controling a VPS

// Start the VPS 101

vzctl start 101

// Stop 101 VPS

vzctl stop 101

// Restart 101 VPS

vzctl restart 101

// Enter into 101 VPS

vzctl enter 101

// Display the list of active VPS.s


// Display the list of all VPS.s

vzlist -a

// Destroy the VPS (good idea to stop it first)

vzctl destroy 101

// Show resources usage on VPS

vzcalc -v 101

// Execute commands against the VPS (in this case .df -m.)

vzctl exec 101 df -m

// Run yum update on VPS

vzyum 101 -y update

// Install package using yum on VPS

vzyum 101 -y install package

// Install package using rpm on VPS

vzrpm 101 -ivh package

Other details good to know

The templates are located under /vz/template/cache

When creating a new VPS you have to use the full template name eg. if the archived template name is “centos-4-i386-default-4.7-20082227.tar.gz” the template name you will have to use is “centos-4-i386-default-4.7-20082227”

The configuration files for every VPS is located under /etc/vz/conf/VPSID.conf

This file can be modified to suit your needs for every VPS but a VPS restart will be needed. Based on /etc/vz/conf/VPSID.conf basic config files for VPS can be created and saved somewhere on the server and can be used when creating new VPS’s to automatic allocate this settings on new VPS’s.

To create a VPS using a saved config file use this command:

vzctl create 101 –ostemplate centos-5-i386-default –config vps.basic

If you need more templates you can download them from:

More details about OpenVZ can be found at: !

Be the first to comment

Leave a Reply

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