User`s guide

Reference 100
vzctl exec, vzctl exec2, and vzctl enter
These commands are used to run arbitrary commands inside a Virtual Private Server being
authenticated as root on the Hardware Node. The syntax of these commands is as follows:
vzctl exec|exec2 vpsid command
vzctl enter vpsid
where command is a string to be executed in the Virtual Private Server. If command is
specified as “-” then the commands for execution will be read from the standard input until the
end of file or “exit” is encountered.
The difference between exec and exec2 is the exit code. vzctl exec returns 0 in case
vzctl has been able to launch the command and does not take into account the exit code of the
command itself. vzctl exec2 returns the exit code of the command executed in the Virtual
Private Server.
When using exec or exec2, you should remember that the shell parses the command line and,
if your command has shell meta-characters in it, you should escape or quote them.
vzctl enter is similar to vzctl exec /bin/bash. The difference between the two is
that vzctl enter makes the shell interpreter believe that it is connected to a terminal. As
such, you receive a shell prompt and are able to execute multiple commands as if you were
logged in to the Virtual Private Server.
However, be aware that vzctl enter is a potentially dangerous command if you have un-
trusted users inside the Virtual Private Server. Your shell will have its file descriptors accessible
for the VPS root in the /proc filesystem and a malicious user could run ioctl calls on it.
Never use vzctl enter for Virtual Private Servers you do not trust. That is why, vzctl
enter is only supposed to be an off-duty way of connecting to VPSs, not a complete
replacement of ssh. Therefore, it has certain limitations, for example, you cannot establish ssh
connections while being connected to a VPS through vzctl enter.
vzlist
The vzlist utility is used to list the VPSs existing on the given Hardware Node together with
additional information about these VPSs. The output and sorting of this information can be
customized as needed. The utility has the following syntax:
vzlist [-a] [-S] [-o parameter[.specifier] \
[,parameter[.specifier]...]] [-s [-]parameter[.specifier]] \
[-H] [-h hostname_pattern] [vpsid ...]
vzlist –L|--list
Here follows the description of available options:
Option Description
-a, --all
List all the VPSs existing on the Node. By default, only running
VPSs are shown.
-S, --stopped
List only stopped VPSs.