CPanel

From Just another day in the life of a linux sysadmin
Jump to navigation Jump to search

CPanel Specific issues and commands

Create a WHM root user login URL bypassing all forms of front end auth must have ssh access

whmapi1 create_user_session user=root service=whostmgrd | grep url | sed -e "s/$(/bin/hostname)/$(cat /var/cpanel/mainip)/g" | awk '{print $2}'

CPanel as well just replace $cpuser

whmapi1 create_user_session user=$cpuser service=cpaneld locale=en | grep url | sed -e "s/$(/bin/hostname)/$(cat /var/cpanel/mainip)/g" | awk '{print $2}'


if you see ioncube loader error with softaculous that states The ioncube loader needs to be installed and a php -m shows it is set the loader in WHM Tweak settings PHP section


Counter datafile "/var/cpanel/Counters"


quick bash to find overquota mailboxes, makes the assumption that any subfolders are under the inbox

for maildirsizefile in $(find /home/*/mail/ -mindepth 2 -name 'maildirsize' ); do maildirsize=$(cat $maildirsizefile | sed 's/,0C//' ); UNLIMITED='2147483647C'; Q=$(echo $maildirsize | awk '{print $1}'| sed 's/S//' ); CUR=$(echo $maildirsize | awk '{print $2}' ); if $Q != $UNLIMITED  ; then if $CUR -gt $Q ; then echo $maildirsizefile OVERQUOTA ; fi ; fi; done

Find a count of all domains on the server including addon domains

find /var/cpanel/userdata/ -type f | xargs grep documentroot | awk -F":" '{print$1}' | egrep -v "(cache|SSL|nobody)"  | awk -F'/' '{print $6}' |awk -F"\." '{print $(NF-1)"."$NF}' | uniq | wc -l

Fixquotas didnt fix mail quotas

Default mail account not updating even with fixquotas


/scripts/generate_maildirsize --confirm --allaccounts --verbose CPANELUSERNAME


ALSO MOVE ALL DOVECOT FILES IN THE USERS MAILDIR TO .bak logout and log back in


Removing an addon domain

Ever tried removing an addon domain and recreating it only to see:

already exists in the userdata

This can be a bit tricky as there are a few locations that this is stored within cpanel. Try the following:

First ensure all DNS records are removed within the main cpanel DNS zonefile that reference the addon domain. Then look further via ssh:

grep DOMAIN.com /var/cpanel/users/*
grep -R DOMAIN.com /var/cpanel/userdata/*

Also look within the main users userdata folder:

grep DOMAIN.com /var/cpanel/userdata/USERNAME/main

Also try looking in /etc/named.conf


Remove all instances of the addon domain and see if any are left with the following

whmapi1 domainuserdata domain=DOMAIN.USER.com


If not success.jpg then run the following:

/scripts/rebuilddnsconfig
/scripts/updateuserdatacache 
/usr/local/cpanel/bin/resetcaches 
/scripts/updateuserdomains
/scripts/rebuildhttpdconf ; service httpd restart

If this does not fix the issue you may need to recursively grep for the domain name within /var/cpanel however this provides plenty of results that dont really matter as they are not creating the issue that prevents adding this again like autossl and cache info.