Handy Openvz Commands

Some of the most comment openvz commands I’ve used in my years of working with servers I hope these come handy to you.

You must be logged in ย within the root of the dedicated server in order for these commands to work

Just before the # is the command you would do.

Finding Vz templates that’s currently on the server
# ls /vz/template/cache/
centos-4-x86.tar.gz fedora-7-x86.tar.gz suse-10.3-x86.tar.gz
centos-4-x86_64.tar.gz fedora-7-x86_64.tar.gz suse-10.3-x86_64.tar.gz
centos-5-x86.tar.gz fedora-8-x86.tar.gz ubuntu-7.10-x86.tar.gz
centos-5-x86_64.tar.gz fedora-8-x86_64.tar.gz ubuntu-7.10-x86_64.tar.gz
debian-3.1-x86.tar.gz fedora-9-x86.tar.gz ubuntu-8.04-x86.tar.gz
debian-4.0-x86.tar.gz fedora-9-x86_64.tar.gz ubuntu-8.04-x86_64.tar.gz
debian-4.0-x86_64.tar.gz

How to start, stop, check status of vps and well throw in force starting
# vzctl start 101
[This command starts Container 101, if it is not started yet]

# vzctl exec 101 service sshd status
sshd is stopped

# vzctl exec 101 service sshd start
Starting sshd: [ OK ]
# vzctl exec 101 service sshd status
sshd (pid 3801) is running...
# vzctl start 103 --force
Starting container ...
Container is mounted
Adding IP address(es): 192.168.16.3
Setting CPU units: 1000
Configure meminfo: 65536
Container start in progress...

How to change the root password of openvz container

# vzctl set 101 --userpasswd root:test
Running commands in a Container. Something I wasn’t aware of.
# vzctl exec 103 /etc/init.d/sshd status
openssh-daemon is stopped
# vzctl exec 103 /etc/init.d/sshd start
Starting sshd: [ OK ]
# vzctl exec 103 /etc/init.d/sshd status
openssh-daemon (pid 9899) is running...

Credits toย Official Openvz Site

Author: Chris