How to list Subdomains, Addon domains and Parked domains of a cPanel account via command line?

If you are a server admin and want to sort out all related accounts easily and quickly from the command line then this will be helpful for you. In a cPanel server, there is a file “main” in “/var/cpanel/userdata/$username” (where $username is the actual username) which stores all accounts details. From there you can see all the domain associated with that specific cPanel account.

1, Log into server as root.
2, View the file as I mentioned.

cat /var/cpanel/userdata/test345/main
---
addon_domains: {}

cp_php_magic_include_path.conf: 0

main_domain: test345.com

parked_domains: []

sub_domains:
  - sub.test345.com

test345.com is the domain name and test345 is the username.

You can also list this from the WHM.

1, Log into WHM panel.
2, Under “Account Information” tab

List Parked Domains – To list all parked domains with original domain details.
List Subdomains – To list Subdomains, Addon Domains and Parked Domains.

That’s it.