# cPanel # Exim - Find Spam **To get a sorted list of email sender in exim mail queue. It will show the number of mails send by each one.** ``` exim -bpr | grep "<" | awk {'print $4'} | cut -d "<" -f 2 | cut -d ">" -f 1 | sort -n | uniq -c | sort -n ``` **List mail ID's for that account:** ``` exim -bpr | head -1000 | grep "spoofed-email@suspicious-domain.com" | head -4 ``` **Looking up info on mail with ID:** ``` find /var/spool/exim/ -name 1XgdkD-0001XD-8b | xargs head -1 ``` **How many Frozen mails on the queue:** ``` /usr/sbin/exim -bpr | grep frozen | wc -l ``` **Deleteing Frozen Messages:** ``` /usr/sbin/exim -bpr | grep frozen | awk {‘print $3′} | xargs exim -Mrm ``` **Find a CWD:** ``` grep cwd /var/log/exim_mainlog | grep -v /var/spool | awk -F"cwd=" '{print $2}' | awk '{print $1}' | sort | uniq -c | sort -n ``` **Code breakdown:** **To remove a message from a sender in the queue:** ``` exim -bp | grep email@domain.com | sed -r 's/(.{10})(.{16}).*/\2/' | xargs exim -Mrm ``` **To remove a message from the queue:** ``` exim -Mrm {message-id} ``` **To remove all messages from the queue, enter:** ``` exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash ``` # 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