Tổng hợp 15 lệnh OpenVZ commands thông dụng

20/09/2021

1, Command to list the running VPSs in a node

# vzlist

Example:

# vzlist
      CTID      NPROC STATUS    IP_ADDR         HOSTNAME
       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

Example:

# 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

Example:

# vzctl start 110

4, To stop or shutdown a VPS

# vzctl stop CTID

Example:

# vzctl stop 110

5, To view the status of a VPS

# vzctl status CTID

Example:

# vzctl status 110
CTID 116 exist unmounted down

6, To restart a VPS

# vzctl restart CTID

Example:

# vzctl restart 110

Introduction to Docker containers. Why Docker?

Containerisation helps to isolate processes. You can run your App/Services as an isolated process, running from a distinct image that provides all files necessary to support the processes. Read more..

Logging into a container

7, To enter a VPS

# vzctl enter CTID

Example:

# 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

Example:

# 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
ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Bash builtin examples

builtin candidate_builtin arg … in bash allows you to only call bash builtins. That is, even if an external command or...
29/12/2020

How to Return a String from Bash Functions

Use of BASH function that returns a value Bash Functions can’t return values like other standard programming languages....
28/12/2020

Ansible Archive and Unarchive

Ansible is a great tool to automate your configuration management. The benefit of Ansible is that you don’t need to set...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Dịch Vụ Xây Dựng Hệ Thống Peering Với Internet Exchange (IXP)
04/04/2025

Dịch Vụ Triển Khai VPN Site-to-Site & Remote Access
04/04/2025

Dịch Vụ Thiết Lập Hệ Thống Tường Lửa (Firewall)
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ảo Hóa & Cloud
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ceph
04/04/2025