invalid byte sequence for encoding “UTF8”

November 28, 2009    |   Posted by admin   |    Category: Mysql & PostGres SQL

Error:

root@host [~]#  psql databasename < dump.sql

ERROR:  invalid byte sequence for encoding “UTF8”: 0xd1e9
HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by “client_encoding”.

The above error is received while restoring a pgsql dump and when the clicnt_encoding of the database is mismatched.

Solution:

1) Edit the dump.sql file

vi dump.sql

2) Change the line

SET client_encoding = ‘SQL_ASCII’;

to

SET client_encoding = ‘latin-1’;

i.e. you need to change the client_encoding from ‘SQL_ASCII’ to ‘latin-1’.

3) Save the file and restore the database once again.

Comments Off on invalid byte sequence for encoding “UTF8”

INFECTED (PORTS: 465) + LKM Trojan installed

November 27, 2009    |   Posted by admin   |    Category: cPanel Management

Chkrootkit scan result: INFECTED (PORTS: 465) + Possible LKM Trojan installed

You may see the following output in the chkrootkit scan:

INFECTED (PORTS: 465)
You have 1 process hidden for readdir command
You have 1 process hidden for ps command
chkproc: Warning: Possible LKM Trojan installed

The server is not infected but these are false positives.

The warning “INFECTED (PORTS: 465)” is a false alarm and can be ignored. The port 465 belogs to SMTPS service and if not in use, you can block it using iptables to avoid the false alarm.

Regarding “chkproc: Warning: Possible LKM Trojan installed”, it is generated when a process is killed and initiated when chkrootkit is running. Normally, you see whether they were php, perl or someother processes.

Comments Off on INFECTED (PORTS: 465) + LKM Trojan installed

Howto: change Port OR Network Interface Speed?

November 22, 2009    |   Posted by admin   |    Category: Linux Administration

How to change Port speed OR Network Interface Speed?

To set a specific speed limit on a Network Interface say 10mbps, edit the file network interface file and set the limit which will make the changes permanent even after a reboot.

Edit the file:

root@server [~]# pico /etc/sysconfig/network-scripts/ifcfg-eth0

Add the following line at the end of the file:

ETHTOOL_OPTS=”speed 10 duplex full autoneg off”

Save the file and restart the network service.

root@server [~]# service network restart

This way you can set the duplex or auto negotiation as well. Once done, you can check the network speed using the ethtool command

root@server [~]# ethtool eth0

Script to change IP address of all the accounts.

November 20, 2009    |   Posted by admin   |    Category: cPanel Management

How to change IP address of all the accounts on a cPanel server?

The “Change Site IP Address” option is WHM is not feasible in case you need to change IP address of all the accounts on a server. In order to change IP address of all the domains on a cPanel server, you have to use the “swapip” script provided by cPanel.

The following script will do the needful:

for i in `cat /etc/trueuserdomains | cut -d: -f1`
do
/usr/local/cpanel/bin/swapip OLDIP NEWIP $i;
done;

where,

OLDIP is the current IP assigned to the domain.
NEWIP is the new IP which you would like to assign.
$i is the domain names read per line from the /etc/trueuserdomains file.

Comments Off on Script to change IP address of all the accounts.

How to recompile kernel?

November 20, 2009    |   Posted by admin   |    Category: Linux Administration

How to compile a kernel on a CentOS server?

Compiling a kernel on a CentOS server is probably easy than other Operating Systems but still you should take care while selecting modules else the server won’t boot up on the new kernel. New System admins find it difficult to compile a kernel, however, the following steps should help them a bit.

1) Download the kernel:

cd /usr/local/src/
wget http://www.kernel.org/pub/linux/kern…x.xx.xx.tar.gz

2) Extract the kernel:

tar -zxf linux-2.xx.xx.tar.gz

3) Here you can use previous config during compilation and select the new required modules:

cd linux-*
cp /boot/config-`uname -r` .config

This will copy the current kernel config in the extracted directory of the new kernel.

4) Now configure the kernel using “make menuconfig”. It will present a graphical display with all the available modules.

make menuconfig

Most of them are already selected since you are using the previous config. You need to make sure you select the new modules for example, the ones related to iptables. Each module provides a HELP module which will help you to understand what the module is all about.

5) Compile the kernel:

make

6) Compile the modules:

make modules

7) Install the modules:

make modules_install

8 ) Install the kernel:

make install

This will place the required files of the new kernel under the /boot directory.

Now, the /etc/grub/grub.conf file will have “default=1” where, ‘1’ is the old kernel. You now need to change “default” value to ‘0’ i.e. from

default=1
to
default=0

Save the file and reboot the server. The server will boot up with the new kernel. However, if the kernel is not compiled properly, your server won’t come online and you will have to change the “default” value back to ‘1’ to boot the server using a single usermode and investigate the issue further.

To overcome this issue, you can use the following steps to test the new kernel.  Once you complete the kernel installation using the “make install” command, execute the command:

root@server[#]# grub

At the grub prompt, execute:

savedefault –default=0 –once
quit

You now need to reboot the server to pick up the new kernel just once i.e. even if the server won’t boot up on the new kernel, you just need another reboot and the server will come online on the old kernel. This will save time and will allow you to work immediately on the issue.

Comments Off on How to recompile kernel?