#!/usr/bin/env bash
cd mqueue-client
deleted=0
for i in `ls`
do
rm -f $i
percentage=$(bc <<< “scale=2; ($deleted / 1035435) * 100”)
((deleted++))
echo “Deleted $i. Files deleted $deleted. $percentage% complete.”
done
Linux Hosting Tips & Tricks
#!/usr/bin/env bash
cd mqueue-client
deleted=0
for i in `ls`
do
rm -f $i
percentage=$(bc <<< “scale=2; ($deleted / 1035435) * 100”)
((deleted++))
echo “Deleted $i. Files deleted $deleted. $percentage% complete.”
done
Plesk : Configure qmail to use alternate SMTP port 26
You have a plesk dedicated server and having issues related to SMTP port 25. There are issues where ISP blocks SMTP port 25, in this case we can use alternate port (I will use port 26).
Kindly follow the below steps to change SMTP port on your plesk dedicated (linux) server to 26.
Login to your server as root
root# cd /etc/xinetd.d
root# ls -l | grep smtp*
root# cat smtp_psa
service smtp
{
socket_type = stream
protocol = tcp
wait = no
disable = no
user = root
instances = UNLIMITED
server = /var/qmail/bin/tcp-env
server_args = /usr/sbin/rblsmtpd -r bl.spamcop.net /var/qmail/bin/relaylock /var/qmail/bin/qmail-smtpd /var/qmail/bin/smtp_auth /var/qmail/bin/true /var/qmail/bin/cmd5checkpw /var/qmail/bin/true
}
root# nano /etc/services
Add the below lines
smtp_psa_new 26/tcp mail
smtp_psa_new 26/udp mail
root# cp smtp_psa smtp_psa_new
Change the service line in the new file “smtp_psa_new” to be this:
service smtp_psa_new
{
socket_type = stream
protocol = tcp
wait = no
disable = no
user = root
instances = UNLIMITED
server = /var/qmail/bin/tcp-env
server_args = /usr/sbin/rblsmtpd -r bl.spamcop.net /var/qmail/bin/relaylock /var/qmail/bin/qmail-smtpd /var/qmail/bin/smtp_auth /var/qmail/bin/true /var/qmail/bin/cmd5checkpw /var/qmail/bin/true
}
root# /etc/init.d/xinetd restart
And you should see smtp listening on ports 25, and 26:
Here’s how to reset your file and directory permissions if PHP is running through FastCGI, suPHP, or LSAPI:
1. find . -type f -exec chmod 644 {} \;
2. find . -type d -exec chmod 755 {} \;
3. chmod 550 pear
4. chmod 550 mage #for magento 1.5+
If PHP is running as a module (DSO), you will need to do this:
1. #for magento 1.5+
2. find . -type f -exec chmod 644 {} \;
3. find . -type d -exec chmod 755 {} \;
4. chmod o+w var var/.htaccess app/etc
5. chmod 550 mage
6. chmod -R o+w media
If you are running Pre 1.5 you can copy and paste this
1. find . -type f -exec chmod 644 {} \;
2. find . -type d -exec chmod 755 {} \;
3. chmod o+w var var/.htaccess app/etc
4. chmod 550 pear
5. chmod -R o+w media
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
1. Fatal error: Class ‘JFile’ not found in
fix
add this to the top of the php file
jimport(‘joomla.filesystem.file’);
2. display php errors off if deprecated after php version upgrade
error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED
Block Incoming Request From IP 1.2.3.4
The following command will drop any packet coming from the IP address 1.2.3.4:
/sbin/iptables -I INPUT -s {IP-HERE} -j DROP
/sbin/iptables -I INPUT -s 1.2.3.4 -j DROP
You can also specify an interface such as eth1 via which a packet was received:
/sbin/iptables -I INPUT -i {INTERFACE-NAME-HERE} -s {IP-HERE} -j DROP
/sbin/iptables -I INPUT -i eth1 -s 1.2.3.4 -j DROP
Please note that when the “!” argument is used before the interface name, the sense is inverted:
/sbin/iptables -I INPUT ! -i {INTERFACE-NAME-HERE} -s {IP-HERE} -j DROP
/sbin/iptables -I INPUT ! -i eth1 -s 1.2.3.4 -j DROP
If the interface name ends in a “+”, then any interface which begins with this name will match. If this option is omitted, any interface name will match:
/sbin/iptables -I INPUT -i {INTERFACE-NAME-HERE}+ -s {IP-HERE} -j DROP
/sbin/iptables -I INPUT -i br+ -s 1.2.3.4 -j DROP
You can replace -I INPUT (insert) with -A INPUT (append) rule as follows:
/sbin/iptables -A INPUT -s 1.2.3.4 -j DROP
/sbin/iptables -i eth1 -A INPUT -s 1.2.3.4 -j DROP
How Do I Block Subnet (xx.yy.zz.ww/ss)?
Use the following syntax to block 10.0.0.0/8 on eth1 public interface:
# /sbin/iptables -i eth1 -A INPUT -s 10.0.0.0/8 -j DROP
How Do I Block and Log Dropped IP Address Information?
You can turn on kernel logging of matching packets with LOG target as follows:
# /sbin/iptables -i eth1 -A INPUT -s 10.0.0.0/8 -j LOG –log-prefix “IP DROP SPOOF A:”
The next rule will actually drop the ip / subnet:
# /sbin/iptables -i eth1 -A INPUT -s 10.0.0.0/8 -j DROP
How Do I View Blocked IP Address?
Simply use the following command:
# /sbin/iptables -L -v
OR
# /sbin/iptables -L INPUT -v
OR
# /sbin/iptables -L INPUT -v -n
Sample outputs:
Chain INPUT (policy ACCEPT 3107K packets, 1847M bytes)
pkts bytes target prot opt in out source destination
0 0 DROP all — br+ any 1.2.3.4 anywhere
0 0 DROP all — !eth1 any 1.2.3.4 anywhere
0 0 DROP all — !eth1 any 1.2.3.4 anywhere
How Do I Search For Blocked IP Address?
Use the grep command as follows:
# /sbin/iptables -L INPUT -v -n | grep 1.2.3.4
How Do I Delete Blocked IP Address?
First, you need to display blocked IP address along with line number and other information, enter:
# iptables -L INPUT -n –line-numbers
# iptables -L INPUT -n –line-numbers | grep 1.2.3.4
Sample outputs:
num pkts bytes target prot opt in out source destination
1 0 0 DROP 0 — * * 116.199.128.1 0.0.0.0/0
2 0 0 DROP 0 — * * 116.199.128.10 0.0.0.0/0
3 0 0 DROP 0 — * * 123.199.2.255 0.0.0.0/0
To delete line number 3 (123.199.2.255), enter:
# iptables -D INPUT 3
Verify the same, enter:
# iptables -L INPUT -v -n
You can also use the following syntax:
# iptables -D INPUT -s 1.2.3.4 -j DROP
How Do I Save Blocked IP Address?
If you are using Redhat / RHEL / CentOS / Fedora Linux, type the following command:
# iptables -D INPUT -s 1.2.3.4 -j DROP
##########################
#////// command to save iptables ///////#
##########################
# /sbin/service iptables save
# less /etc/sysconfig/iptables
# grep ‘1.2.3.4’ /etc/sysconfig/iptables
For all other Linux distributions use the iptables-save command to dump the contents of an IP Table to a file:
# iptables-save > /root/myfirewall.conf
Please not that you need to run the ‘iptables-save’ or ‘service iptables save’ as soon as you add or delete the ip address.
A Note About Restoring Firewall
To restore your firewall use the iptables-restore command to restore IP Tables from a file called /root/myfirewall.conf, enter:
# iptables-restore < /root/myfirewall.conf
How Do I Block Large Number Of IP Address or Subnets?
You need to write a shell script as follows:
#!/bin/bash
_input=”/root/blocked.ip.db”
IPT=/sbin/iptables
$IPT -N droplist
egrep -v “^#|^$” x | while IFS= read -r ip
do
$IPT -A droplist -i eth1 -s $ip -j LOG –log-prefix “IP BlockList ”
$IPT -A droplist -i eth1 -s $ip -j DROP
done < “$_input”
# Drop it
$IPT -I INPUT -j droplist
$IPT -I OUTPUT -j droplist
$IPT -I FORWARD -j droplist