Administrate CloudLinux OS from command line

If You have installed cloudlinux with any controlpanel such as cPanel, Plesk, ISPmanager, DirectAdmin, InterWorx then you will get GUI to manage but if you installed the cloudlinux with plain os such as CentOS & RHEL obviously you have only option to work with CLI. In this case don’t worry we (2daygeek) here to help you to manage cloudlinux os from command line.

1) lvectl command usage

lvectl is the primary tool for LVE management. To use it, you have to be administrator. lvectl is part of lve-utils package.

syntax : lvectl command [veid] [options]

How to list loaded LVE’s with LVE id

# How to list loaded LVE's with LVE id #
[email protected] [~]# lvectl list | more
      ID   SPEED    NCPU    PMEM    VMEM      EP   NPROC      IO    IOPS
 default      25       1    1.0G    1.0G      20     100    1024    1024
     512      25       1    1.0G    1.0G      20     100    1024    1024
     514      25       1    1.0G    1.0G      20     100    1024    1024
     515      25       1    1.0G    1.0G      20     100    1024    1024
     516      25       1    1.0G    1.0G      20     100    1024    1024
     517      25       1    1.0G    1.0G      20     100    1024    1024
     518      25       1    1.0G    1.0G      20     100    1024    1024
     513      25       1    1.0G    1.0G      20     100    1024    1024
.
.

How to list loaded LVE’s with username instead of LVE id

[email protected] [~]# lvectl list-user | more
      ID   SPEED    NCPU    PMEM    VMEM      EP   NPROC      IO    IOPS
 default      25       1    1.0G    1.0G      20     100    1024    1024
datapoin      25       1    1.0G    1.0G      20     100    1024    1024
  devpro      25       1    1.0G    1.0G      20     100    1024    1024
dhanjale      25       1    1.0G    1.0G      20     100    1024    1024
dowellte      25       1    1.0G    1.0G      20     100    1024    1024
earthrec      25       1    1.0G    1.0G      20     100    1024    1024
electron      25       1    1.0G    1.0G      20     100    1024    1024
deepamfl      25       1    1.0G    1.0G      20     100    1024    1024
evergree      25       1    1.0G    1.0G      20     100    1024    1024
gitiwapt      25       1    1.0G    1.0G      20     100    1024    1024
.
.

How to remove limits for cpu, ncpu, io, nproc, pmem, vmem and entry processes for particular user

# Default limits for 2daygeek #
[email protected] [~]# lvectl list-user | grep daygeekc
daygeekc      25       1    1.0G    1.0G      20     100    1024    1024

# Removing limits for 2daygeek #
[email protected] [~]# lvectl set-user daygeekc --unlimited

# Check new limits for 2daygeek #
[email protected] [~]# lvectl list-user | grep daygeekc
daygeekc     100       1      0K      0K       0       0       0       0

# How to set specific process, cpu, etc limits for 2daygeek #
[email protected] [~]# lvectl set-user daygeekc --speed=50%
daygeekc      50       1    1.0G    1.0G      20     100    1024    1024

# How to remove customized limits for 2daygeek and turn back to default #
[email protected] [~]# lvectl delete-user daygeekc
[email protected] [~]# lvectl list-user | grep daygeekc
daygeekc      25       1    1.0G    1.0G      20     100    1024    1024

# To get more information and option about lvectl #
[email protected] [~]# lvectl

2) lveps command usage

lveps tool show information about running LVEs.

syntax : lveps [options]

# To get running LVEs information #
[email protected] [~]# lveps -p -n
      ID     EP    PNO        COM    TNO    TID       CPU      MEM         DT         DO
     621      3      6        ---      6    ---      1163      115          0          0
            ---    ---        php    --- 137743         0       26        N/A        N/A
            ---    ---        php    --- 137742         0       26        N/A        N/A
            ---    ---        php    --- 137741         0       26        N/A        N/A
            ---    ---      httpd    --- 132958         0        5        N/A        N/A
            ---    ---      httpd    --- 132443         0        5        N/A        N/A
            ---    ---      httpd    --- 131632         0        5        N/A        N/A

# To get more information and option about lveps #
[email protected] [~]# lveps --help

3) lvetop command usage

lvetop utility allows to monitor LVE usage.

syntax : lvetop

# lvetop utility allows to monitor LVE usage #
[email protected] [~]# lvetop
      ID     EP    PNO    TNO     SPEED      MEM         IO       IOPS
daygeekc      0      0      0       11%        0          0          0

4) cldetect command usage

cldetect is used to detect installed software, and adjust CloudLinux options accordingly.

syntax : /usr/bin/cldetect [–options]

# lvetop utility allows to monitor LVE usage #
[email protected] [~]# /usr/bin/cldetect --detect-cp
cPanel,11.50.0

# To get more information and option about cldetect #
[email protected] [~]# /usr/bin/cldetect

5) lve-stats & lve-stats 2 command usage

Package lve-stats & lve-stats 2 collects LVE usage statistics, and allows to query the data.

syntax : /usr/sbin/lveinfo [OPTIONS]

To query historical LVE info using LVE id

[email protected] [~]# /usr/sbin/lveinfo
+---+----+----+----+---+---+----+---+---+---+-----+------+-----+-----+------+-----+------+------+------+---+-----+-----+------+-----+-----+-----+
| ID|aCPU|mCPU|lCPU|aIO|mIO|lIO |aEP|mEP|lEP|aVMem|mVMem |lVMem|aPMem|mPMem |lPMem|aNproc|mNproc|lNproc|EPf|VMemF|PMemF|NprocF|aIOPS|mIOPS|lIOPS|
+---+----+----+----+---+---+----+---+---+---+-----+------+-----+-----+------+-----+------+------+------+---+-----+-----+------+-----+-----+-----+
|641| 4  | 25 | 25 | 0 | 29|1024| 0 | 6 | 20|14.5M|107.6M| 1.0G| 9.4M|317.3M| 1.0G|  0   |  6   | 100  | 0 |  0  |  0  |  0   |  1  | 234 | 1024|
|621| 1  | 21 |100 | 0 | 0 | 0  | 0 | 2 | 0 | 1.4M|76.9M |  0  | 9.7M|95.6M |  0  |  0   |  2   |  0   | 0 |  0  |  0  |  0   |  0  |  0  |  0  |
|515| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0   | 1.0G| 395K| 520K | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|518| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0   | 1.0G| 120K| 120K | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|534| 0  | 1  | 25 | 0 | 64|1024| 0 | 1 | 20| 41K | 5.6M | 1.0G| 3.9M|10.3M | 1.0G|  0   |  1   | 100  | 0 |  0  |  0  |  0   |  0  |  15 | 1024|
|563| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0   | 1.0G| 2.7M| 2.7M | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|582| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0   | 1.0G| 84K | 84K  | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|588| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0   | 1.0G| 105K| 108K | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|618| 0  | 9  | 25 | 0 | 6 |1024| 0 | 0 | 20|  0  |  0   | 1.0G| 8.0M|14.9M | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|639| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0   | 1.0G| 12K | 12K  | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
+---+----+----+----+---+---+----+---+---+---+-----+------+-----+-----+------+-----+------+------+------+---+-----+-----+------+-----+-----+-----+

To query historical LVE info using username instead of LVE id

[email protected] [~]# /usr/sbin/lveinfo -d
+--------+----+----+----+---+---+----+---+---+---+-----+-----+-----+-----+------+-----+------+------+------+---+-----+-----+------+-----+-----+-----+
|   ID   |aCPU|mCPU|lCPU|aIO|mIO|lIO |aEP|mEP|lEP|aVMem|mVMem|lVMem|aPMem|mPMem |lPMem|aNproc|mNproc|lNproc|EPf|VMemF|PMemF|NprocF|aIOPS|mIOPS|lIOPS|
+--------+----+----+----+---+---+----+---+---+---+-----+-----+-----+-----+------+-----+------+------+------+---+-----+-----+------+-----+-----+-----+
|daygeekc| 1  | 25 |100 | 0 | 0 | 0  | 0 | 3 | 0 | 1.9M|87.1M|  0  |12.6M|118.1M|  0  |  0   |  3   |  0   | 0 |  0  |  0  |  0   |  0  |  0  |  0  |
|dhanjale| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0  | 1.0G| 172K| 172K | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|earthrec| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0  | 1.0G| 72K | 72K  | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|electron| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0  | 1.0G| 104K| 112K | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|hindusta| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0  | 1.0G| 68K | 68K  | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|icaisale| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0  | 1.0G| 156K| 156K | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|jiptech | 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0  | 1.0G| 188K| 188K | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|needsbuy| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0  | 1.0G| 5.5M| 5.5M | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|nivasign| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0  | 1.0G| 5.0M| 5.2M | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
|renghaho| 0  | 0  | 25 | 0 | 0 |1024| 0 | 0 | 20|  0  |  0  | 1.0G| 280K| 280K | 1.0G|  0   |  0   | 100  | 0 |  0  |  0  |  0   |  0  |  0  | 1024|
+--------+----+----+----+---+---+----+---+---+---+-----+-----+-----+-----+------+-----+------+------+------+---+-----+-----+------+-----+-----+-----+

Display top 10 users, by max CPU usage for some date duration

[email protected] [~]# lveinfo --from='2015-07-25' --to='2015-08-05' -o cpu_max --display-username
+--------+----+----+----+---+----+----+---+---+---+------+------+-----+-----+------+-----+------+------+------+----+-----+-----+------+-----+------+-----+
|   ID   |aCPU|mCPU|lCPU|aIO|mIO |lIO |aEP|mEP|lEP|aVMem |mVMem |lVMem|aPMem|mPMem |lPMem|aNproc|mNproc|lNproc|EPf |VMemF|PMemF|NprocF|aIOPS|mIOPS |lIOPS|
+--------+----+----+----+---+----+----+---+---+---+------+------+-----+-----+------+-----+------+------+------+----+-----+-----+------+-----+------+-----+
|daygeekc| 2  |100 |100 | 1 |1024|1024| 6 |149| 20|212.6M| 3.9G | 1.0G|25.3M|738.2M| 1.0G|  6   | 152  | 100  |5996|  0  |  0  |  0   |  9  |100573| 1024|
|holidays| 0  | 25 | 25 | 2 |1024|1024| 0 | 20| 20| 341K |209.0M| 1.0G| 1.6M|113.1M| 1.0G|  0   |  22  | 100  | 9  |  0  |  0  |  0   |  1  |12431 | 1024|
|needsbuy| 0  | 25 | 25 | 1 |1024|1024| 0 | 15| 20| 1.5M |524.6M| 1.0G| 7.0M|657.4M| 1.0G|  0   |  15  | 100  | 0  |  0  |  0  |  0   |  0  | 2270 | 1024|
|renghaho| 0  | 25 | 25 | 0 |1024|1024| 0 | 20| 20| 26K  |265.8M| 1.0G| 293K|666.6M| 1.0G|  0   |  20  | 100  | 46 |  0  |  0  |  0   |  0  | 3517 | 1024|
|royaljo | 0  | 25 | 25 | 0 |1020|1024| 0 | 2 | 20| 884  |35.5M | 1.0G| 154K|122.9M| 1.0G|  0   |  2   | 100  | 0  |  0  |  0  |  0   |  0  |  95  | 1024|
|workstud| 0  | 25 | 25 | 3 |1024|1024| 0 | 20| 20| 1.0M |650.1M| 1.0G| 7.1M|688.9M| 1.0G|  0   |  20  | 100  | 3  |  0  |  0  |  0   |  0  | 2302 | 1024|
|  619   | 0  | 25 | 25 | 2 |1024|1024| 0 | 20| 20| 564K |331.9M| 1.0G| 1.9M|718.8M| 1.0G|  0   |  21  | 100  |214 |  0  |  0  |  0   |  1  | 6145 | 1024|
|  620   | 0  | 25 | 25 | 0 |1024|1024| 0 | 3 | 20| 48K  |39.3M | 1.0G| 744K|82.0M | 1.0G|  0   |  3   | 100  | 0  |  0  |  0  |  0   |  0  | 2011 | 1024|
|brockcoi| 0  | 25 | 25 | 0 |1024|1024| 0 | 7 | 20| 84K  |126.0M| 1.0G| 797K|296.9M| 1.0G|  0   |  7   | 100  | 0  |  0  |  0  |  0   |  0  | 195  | 1024|
|ginnyhel| 0  | 25 | 25 | 0 |1024|1024| 0 | 3 | 20|  1K  |35.4M | 1.0G| 187K|99.5M | 1.0G|  0   |  3   | 100  | 0  |  0  |  0  |  0   |  0  | 315  | 1024|
+--------+----+----+----+---+----+----+---+---+---+------+------+-----+-----+------+-----+------+------+------+----+-----+-----+------+-----+------+-----+

Display LVE info about particular user for some date duration.

[email protected] [~]# lveinfo --from='2015-08-01' --to='2015-08-05' --user=daygeekc --display-username
+-----------+-----------+----+----+----+---+---+---+---+
|    From   |     To    |aCPU|mCPU|lCPU|aEP|mEP|lEP|EPf|
+-----------+-----------+----+----+----+---+---+---+---+
|07-31 23:30|08-01 00:30| 1  | 55 |100 | 0 | 1 | 0 | 0 |
|08-01 00:30|08-01 01:30| 0  | 26 |100 | 0 | 2 | 0 | 0 |
|08-01 01:30|08-01 02:30| 7  | 79 |100 | 0 | 2 | 0 | 0 |
|08-01 02:30|08-01 03:30| 0  | 21 |100 | 0 | 2 | 0 | 0 |
|08-01 03:30|08-01 04:30| 0  | 19 |100 | 0 | 2 | 0 | 0 |
.
.
|08-04 15:30|08-04 16:30| 1  | 31 |100 | 0 | 2 | 0 | 0 |
|08-04 16:30|08-04 17:30| 1  | 36 |100 | 0 | 2 | 0 | 0 |
|08-04 17:30|08-04 18:30| 1  | 39 |100 | 0 | 1 | 0 | 0 |
|08-04 18:30|08-04 19:30| 2  | 31 |100 | 0 | 2 | 0 | 0 |
|08-04 19:30|08-04 20:30| 4  | 39 |100 | 0 | 2 | 0 | 0 |
|08-04 20:30|08-04 21:30| 1  | 38 |100 | 0 | 2 | 0 | 0 |
|08-04 21:30|08-04 22:30| 1  | 36 |100 | 0 | 2 | 0 | 0 |
|08-04 22:30|08-04 23:30| 1  | 31 |100 | 0 | 2 | 0 | 0 |
+-----------+-----------+----+----+----+---+---+---+---+

Some of useful lve-stats 2 commands for generate chart.

# creates a chart representing LVE usage for user; #
[email protected] [~]# /usr/sbin/lvechart [OPTIONS]

# creates a chart representing MySQL usage for user #
[email protected] [~]# /usr/sbin/dbgovchart [OPTIONS]

# displays information from system state (snapshots) for user #
[email protected] [~]# lve-read-snapshot [OPTIONS]

# creates/recreates database for lve-stats #
[email protected] [~]# lve_create_db [-h] [--recreate] [--print-sql]

6) cagefsctl command usage

cagefsctl is used to manage CageFS. It allows you to initialize and update CageFS, as well as enable/disable CageFS for individual users.

syntax : /usr/sbin/cagefsctl [OPTIONS]

# initialize CageFS (create CageFS if it does not exist) #
[email protected] [~]# /usr/sbin/cagefsctl --init

# To list enabled cagefs user #
[email protected] [~]# /usr/sbin/cagefsctl --list-enabled
190 enabled user(s)
absolute
adhavacashew
aishwary
.
.
mageshco
.
.

# To list disable cagefs user #
[email protected] [~]# /usr/sbin/cagefsctl --list-disabled
1 disabled user(s)
whmza

# Grep particular user from cagefs #
[email protected] [~]# /usr/sbin/cagefsctl --list-enabled | grep mageshco
mageshco

# How to disable user from cagefs #
[email protected] [~]# /usr/sbin/cagefsctl --disable mageshco

# To list disable cagefs user #
[email protected] [~]# /usr/sbin/cagefsctl --list-disabled
2 disabled user(s)
mageshco
whmza

# How to enable user from cagefs #
[email protected] [~]# /usr/sbin/cagefsctl --enable mageshco
Updating users ...

# To list disable cagefs user #
[email protected] [~]# /usr/sbin/cagefsctl --list-disabled
1 disabled user(s)
whmza

Sometimes you will want to execute a command, as user, inside CageFS.

# If user has shell enabled - you can simply use #
[email protected] [~]# /bin/su - $USERNAME  -c "_command_"

# Yet, if user has shell disabled- you can simply use #
[email protected] [~]# /sbin/cagefs_enter_user $USERNAME "_command_"

7) MySQL Governor

MySQL governor is software to monitor and restrict MySQL usage in shared hosting environment. The monitoring is done via resource usage statistics per each MySQL thread.

# dbtop : Utility to monitor MySQL usage. Requires db_governor to be running. It shows usage for the current, mid and long intervals. #
[email protected] [~]# dbtop [OPTIONS]

# dbctl #
[email protected] [~]# dbctl command [parameter] [options]

# lveinfo tool is part of lve-stats package. It was extended to collect historical information about MySQL usage. #
[email protected] [~]# lveinfo --dbgov [options]

# dbgovchart is analog of lvechart tool to create charts representing customer's to MySQL usage #
[email protected] [~]# /usr/sbin/dbgovchart [OPTIONS]

8) Inode

inodes Limits extension to LVE Manager allows you to set inodes limits for your customers. An inode is a data structure on a file system used to keep information about a file or a folder. The number of inodes indicates the number of files and folders an account has. inodes limits work on the level of disk quota, and will be enabled on /home partition only.

syntax : /usr/bin/cl-quota [options]

# print inode limits for all users #
[email protected] [~]# /usr/bin/cl-quota | more
                              id     inodes_used     inodes_soft     inodes_hard
--------------------------------------------------------------------------------
                               0               -               0               0
                               1              57               0               0
                               2               3               0               0
                              25             221               0               0
                              27            9529               0               0
                              47             183               0               0
                              68               2               0               0
                              89              27               0               0
                              97               8               0               0
                              99               4               0               0
                             173               4               0               0
                             497               4               0               0
                             498               1               0               0

# print inode limits for particular user #
[email protected] [~]# /usr/bin/cl-quota -u daygeekc
                              id     inodes_used     inodes_soft     inodes_hard
--------------------------------------------------------------------------------
                             621           15294               0               0

9) PHP Selector

PHP Selector is a CloudLinux component that sits on top of CageFS. It allows each user to select PHP version & module based on their needs. PHP Selector requires account to have CageFS enabled to work.

# lists all available alternatives for an interpreter. #
[email protected] [~]# selectorctl --list

# If used with –-show-native-version to display native version #
[email protected] [~]# selectorctl --user-current --user=username

# sets specified version as the one to use for this end user. changes user symlinks for the PHP interpreter to point to alternative 5.4. #
[email protected] [~]# selectorctl --set-user-current=5.4 --user=username

# The ranges of affected customers or versions can be narrowed with --version or --user options. #
[email protected] [~]# selectorctl --reset-options --user=user1,user2 --version=5.3,5.4

# list users that use particular version of interpreter, specified with --version option. For example, to see all users that use PHP version 5.3 #
[email protected] [~]# selectorctl --list-users --version=5.3

# changes all (or particular user) from one interpreter version to another. #
[email protected] [~]# selectorctl --change-to-version=5.2 --version=5.3

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...