Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to find out a) which packages are currently in use, and b) which accounts are using them, so I can do some housekeeping.

If I go to 'Show Reseller Accounts', it'll list all the accounts by reseller and I can see which accounts use which, so I could go the longhand route of counting through them one by one, but I wondered if there's a way of getting a simple listing.

NB: I've seen that if I go to 'Edit Reseller privileges & nameservers' for one of my resellers, I'll see a 'Package limits' table which has a 'Current' column that shows exactly what I'm looking for... but it's for that reseller only, and I don't get this table for resellers that have no package limits (e.g. me).

share|improve this question

closed as off-topic by Falcon Momot, Bryan, Scott Pack, Nathan C, mdpc Jul 20 '13 at 6:00

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Are you willing to use SSH? –  Jay Jun 11 '12 at 1:51
    
Sure. Just to be clear, I'm asking about cPanel/WHM packages (not for example Linux packages). Can you help? –  Paul Masri Jun 11 '12 at 15:58
4  
Questions concerning the use of shared web hosting by end users or resellers, rather than the administration of web hosting, are off-topic. –  Falcon Momot Jul 19 '13 at 6:54

1 Answer 1

up vote 3 down vote accepted

Just paste both commands into a SSH terminal (the for .. one is still one line) and it should give you the result you want. If you plan on running these often, you might want to alias them or put them in a bash script.

a) This will list all of the cPanel/WHM packages, with a count

cd /var/cpanel/users/
grep PLAN *|cut -f2 -d=|sort|uniq -c|sort

The key to this command is each account has a file in /var/cpanel/users/ with an entry PLAN=x for their plan (hence the cut -f d= to retrieve the right-hand side). After that we just sort and count them, then sort the listing.

b) This will, for every package, output "Have package " and a list of accounts that have it.

cd /var/cpanel/users/
for package in `grep PLAN *|cut -f2 -d=|sort|uniq`; do echo "Have package $package: "; grep -l PLAN=$package *; done

For this one, we use the previous result to get a list of packages (without a count, just a list). Then we loop over all of these, and list all the files ( = account usernames) that have PLAN=that_package_we're_looping_over.

share|improve this answer
    
That is a truly awesome answer. Thank you! (I'll vote up your answer when I get the reputation points do to so.) –  Paul Masri Jun 13 '12 at 9:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.