# cPanel Notes ### Useful scripts ##### **Restart ssh from URL** > [http://11.22.33.44:2086/scripts2/doautofixer?autofix=safesshrestart](http://11.22.33.44:2086/scripts2/doautofixer?autofix=safesshrestart) ##### **To setup nat**

The /var/cpanel/cpnat file acts as a flag file for NAT mode. If the installer mistakenly detects a NAT-configured network, delete the/var/cpanel/cpnat file to disable NAT mode.

```shell /scripts/build_cpnat ``` ##### **cpmove** Create a cpmove for all domains ```shell #!/bin/bash while read line do echo "-----------Backup cPanel : $line ---------------" /scripts/pkgacct $line done < "/root/cPanel_Accounts_list.txt" ``` Restore cpmove from list ```shell #!/bin/bash while read line do echo "-----------Restore du compte cPanel : $line ---------------" /scripts/restorepkg $line done < "/root/cPanel_Accounts_list.txt" ``` ##### **Access logs for all account by date** ```shell cat /home/*/access-logs/* > all-accesslogs.txt && cat all-accesslogs.txt | grep "26/Nov/2017:17" | sort -t: -k2 | less ``` ##### **Update Licence** ```shell /usr/local/cpanel/cpkeyclt ``` #### **Fix account perms** ```shell #!/bin/bash if [ "$#" -lt "1" ];then echo "Must specify user" exit; fi USER=$@ for user in $USER do HOMEDIR=$(egrep "^${user}:" /etc/passwd | cut -d: -f6) if [ ! -f /var/cpanel/users/$user ]; then echo "$user user file missing, likely an invalid user" elif [ "$HOMEDIR" == "" ];then echo "Couldn't determine home directory for $user" else echo "Setting ownership for user $user" chown -R $user:$user $HOMEDIR chmod 711 $HOMEDIR chown $user:nobody $HOMEDIR/public_html $HOMEDIR/.htpasswds chown $user:mail $HOMEDIR/etc $HOMEDIR/etc/*/shadow $HOMEDIR/etc/*/passwd echo "Setting permissions for user $USER" find $HOMEDIR -type f -exec chmod 644 {} ; -print find $HOMEDIR -type d -exec chmod 755 {} ; -print find $HOMEDIR -type d -name cgi-bin -exec chmod 755 {} ; -print find $HOMEDIR -type f ( -name "*.pl" -o -name "*.perl" ) -exec chmod 755 {} ; -print fi done chmod 750 $HOMEDIR/public_html if [ -d "$HOMEDIR/.cagefs" ]; then chmod 775 $HOMEDIR/.cagefs chmod 700 $HOMEDIR/.cagefs/tmp chmod 700 $HOMEDIR/.cagefs/var chmod 777 $HOMEDIR/.cagefs/cache chmod 777 $HOMEDIR/.cagefs/run fi ``` Run on all accounts ```shell for i in `ls -A /var/cpanel/users` ; do ./fixperms.sh $i ; done ``` ##### **Find IP's of users in CLI** ```shell cat /olddisk/var/cpanel/users/* | grep "IP\|USER" ``` ##### **SharedIP** ```shell vim /var/cpanel/mainips/root IP1 IP2 ``` ### WHM Directories The below directories can be located under */usr/local/cpanel* - /3rdparty - Tools like fantastico, mailman files are located here - /addons - Advanced GuestBook, phpBB, etc. - /base - phpMyAdmin, Squirrelmail, Skins, webmail, etc. - /bin - cPanel binaries - /cgi-sys - CGI files like cgiemail, formmail.cgi, formmail.pl, etc. - /logs - cPanel access\_log, error\_log, license\_log, stats\_log - /whostmgr - WHM related files - /base/frontend - cPanel theme files - /perl - Internal Perl modules for compiled binaries - /etc/init - init files for cPanel services