A great linux stuff website

Non SSL to SSL redirection 301 code .htaccess

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R=301,L]


Find core dump file and remove + Linux server

# find /home/* -name core.[0-9]* -exec rm {} \;

# find /home/*/public_html -name core.[0-9]*

# find /home/*/public_html -name core.[0-9]* | xargs rm -vf

Mysql database backup Dump/restore in plesk server

# mysqldump -uadmin -p`cat /etc/psa/.psa.shadow` ethos_db > /var/www/vhosts/ethosclaims.co.uk/httpdocs/ethos_db.sql

# mysql -uadmin -p`cat /etc/psa/.psa.shadow` muzmatchappdb < muzmatchappdb.sql

Commands to find out bandwidh usage for pop3 in cpanel

root@master[~]# grep domain.com /var/log/maillog* | grep retr= | grep -v retr=0 | awk {‘print $11’} | cut -d, -f1 | cut -d= -f2 | awk ‘{t += $1} END { print “total: “, t /1024 /1024 /1024, ” GB transferred over POP3″}’

total: 12.2214 GB transferred over POP3

root@master[~]# grep domain.com /var/log/maillog | grep retr= | awk {‘print $7″ “$1” “$2” “$3” “$11’} | grep -v retr=0

How to find Duplicate Spam email Activity with same subject in cpanel

In order to find the duplicate same subject message which could be caused the spam activity on cpanel based server, in order to find this need to filter those activity using below command which will help.

# following command shows From which script spamming[highest emails are sending] is running :

grep “cwd=” /var/log/exim_mainlog | awk ‘{for(i=1;i <=10; i++) {print $i}}' | sort | uniq -c | grep cwd | sort -n

following command shows From which email address or domain spamming is running :

# exim -bpr | grep "<" | awk {'print $4'} | cut -d "” -f 1 | sort -n | uniq -c | sort -n

# awk -F”T=\”” ‘/<=/ {print $2}' /var/log/exim_mainlog | cut -d\" -f1 | sort | uniq -c | sort -n

To find out sending possible logs for spam messages

# grep "Melt Fat Naturally" /var/log/exim_mainlog | awk '{print $6}' | sort | uniq -c | sort -n

Below command will help to find out exacly IP address sending emails from:

# egrep "<= master@yourdomain.com" /var/log/exim_mainlog | grep "Melt Fat Naturally" | grep -o "\[[0-9.]*\]" | sort -n | uniq -c | sort -n

Magento Error: “Front controller reached 100 router match iterations”

Usually this error comes because of the unwanted cache files under mangeto installation those should be available under /home/user/public_html/var/cache

This cache files generated due to the magento upgrade.

In order to resolve the issue just remove those cache files or rename it, issue will be resolved.

Disable Direct root Login Linux

In most of the cases we need to login our server using 2 steps authentication by disabling direct root login.

Below are the steps which we can used.

1. adduser support
2. passwd support
>> create strong password for support user as per request.

Please keep support password
3. vi /etc/group

Make sure admin user wheel settings

1. Copy and paste this line to edit the file for SSH logins
# vi /etc/ssh/sshd_config

2. check for the next line
Protocol 2, 1

3. Uncomment it and change it to look like
Protocol 2

4. Next, find the below line and change “Yes” to “No” (This will disable direct root login)
PermitRootLogin yes

5. Save the file and exit

7. Now you can restart SSH
# /etc/rc.d/init.d/sshd restart


Try to login then using user support

ssh support@ That is all.