Count cPanel accounts using whmapi1 and jq

The command is using whmapi1 and jq and needs to run as root.

whmapi1 listaccts want=user --output=json | jq '.data.acct | length'

This command does:

  1. Pipe the JSON output from whmapi1 listaccts into jq.
  2. Use jq to navigate to the array at .data.acct.
  3. Use the length function to count the number of elements (users) in the array, effectively giving you the count of cPanel users.