Change the hostname of a vps

6 07 2011

You have to change the hostname in the following files:

/etc/hosts
/etc/sysconfig/network
/proc/sys/kernel/hostname





Create Bootable USB from Linux

17 05 2011

Install Livecd-tools and spin-kickstarts using Yum
yum install livecd-tools spin-kickstarts

Make the partition bootable
/sbin/parted /dev/sdb
(parted) toggle N boot
(parted) quit

Run the command from shell
/usr/bin/livecd-iso-to-disk /path/to/live.iso /dev/sdb1





Set Timezone on Linux Machine

23 02 2010

ln -sf /usr/share/zoneinfo/Asia/Calcutta /etc/localtime

Using TZ environment

export TZ=Asia/Calcutta

date





Resize /tmp in cpanel servers

10 01 2010

service chkservd stop
service httpd stop
service mysql stop
service postgresql stop

lsof | grep /tmp

kill the process

umount /var/tmp

umount /tmp

vi /scripts/securetmp

replace “256000″ with “512000″

rm -rf /usr/tmpDSK
/scripts/securetmp –auto

cd /tmp

ln -s /var/lib/mysql/mysql.sock

service postgresql start
service mysql start
service httpd start
service chkservd start





Upgrade Python to 3.1

18 11 2009

cd /usr/local/src

wget http://www.python.org/ftp/python/3.1.1/Python-3.1.1.tar.bz2

tar -jxvf Python-3.1.1.tar.bz2

cd Python-3.1.1

./configure

make

make install

Now move /usr/bin/python /usr/bin/python.bk

then create symlink :

ln -s /usr/local/bin/python3 /usr/bin/python

check python -V





How to Boot second kernel if first fails

6 10 2009

Reference :  http://www.linux-noob.com/forums/index.php?/topic/2928-grub-single-boot-and-kernel-panic-reboot/

If for example your grub.conf looks like the one i have below. This boots into the 2.6.20-1.2944 by default.

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.20-1.2944.fc6)
        root (hd0,0)
        kernel /vmlinuz-2.6.20-1.2944.fc6 ro root=LABEL=/ acpi=off
        initrd /initrd-2.6.20-1.2944.fc6.img
title Fedora Core
        root (hd0,0)
        kernel /vmlinuz-2.6.20 ro root=LABEL=/ acpi=off
        initrd /initrd-2.6.20.img

If you want to have it so that 2.6.20 boots on next boot, run the following command from the console before rebooting.
echo “savedefault –default=1 –once” | grub –batch
then
reboot

Now, if you have a kernel that panics and need it to reboot if it panics. change your config and add the panic=# (# being seconds before auto reboot) to the kernel line. Example file below

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.20-1.2944.fc6)
        root (hd0,0)
        kernel /vmlinuz-2.6.20-1.2944.fc6 ro root=LABEL=/ acpi=off panic=5
        initrd /initrd-2.6.20-1.2944.fc6.img
title Fedora Core (2.6.20)
        root (hd0,0)
        kernel /vmlinuz-2.6.20 ro root=LABEL=/ acpi=off panic=5
        initrd /initrd-2.6.20.img

so the order of operations on this are as follows.

1.) Add new kernel to grub.conf
2.) set default=# in grub.conf to the failsafe kernel (the one you want it to try if the other fails)
3.) run the following:
echo “savedefault –default=1 –once” | grub –batch
4.) reboot

Copied from :  http://www.linux-noob.com/forums/index.php?/topic/2928-grub-single-boot-and-kernel-panic-reboot/





Remote access to mysql database

4 08 2009

Step 1 : vi  /etc/my.cnf
———————————————
pid-file        = /var/run/mysqld/mysqld.pid

socket          = /var/run/mysqld/mysqld.sock

port            = 3306

basedir         = /usr

datadir         = /var/lib/mysql

tmpdir          = /tmp

language        = /usr/share/mysql/English

bind-address    = mysql server ip

# skip-networking
———————————————

bind-address : IP address to bind to.

skip-networking : Don’t listen for TCP/IP connections at all. All interaction with mysqld must be made via Unix sockets. This option is highly recommended for systems where only local requests are allowed. Since you need to allow remote connection this line should removed from file or put it in comment state.

Step 2 : /etc/init.d/mysql restart

Step 3 : Grant access to remote IP address

mysql -u root -p mysqlGrant access to new database

Step 4 : If you want to add new database aaa for user bbb and remote IP xxx.xxx.xxx.xxx then type following commands at mysql prompt:

mysql> CREATE DATABASE aaa;
mysql> GRANT ALL ON aaa.* TO bbb@’xxx.xxx.xxx.xxx’ IDENTIFIED BY ‘PASSWORD’;

Step 5 : Grant access to existing database

mysql> update db set Host=’xxx.xxx.xxx.xxx’ where Db=’webdb’;
mysql> update user set Host=’xxx.xxx.xxx.xxx’ where user=’webadmin’;

mysql> exit

Step 6 : Test it From remote system

mysql -u webadmin –h 65.55.55.2 –p





Script used to transfer account from cpanel server

3 07 2009
#!/bin/bash

ls -1 /var/cpanel/users > /root/user_list

PORT="22"

ssh-keygen -t dsa

KEY=`cat /root/.ssh/id_dsa.pub`

ssh $1 -p$PORT "mkdir -p /root/.ssh;echo ${KEY} >> /root/.ssh/authorized_keys" 2>&1
scp /var/cpanel/packages/* $1:/var/cpanel/packages/

for user in $(cat /root/user_list);do /scripts/pkgacct $user;done
scp /home/user_list $1:/home
scp /home/cpmove* $1:/home




Red5 installation

26 06 2009

cd /root

vi red5install

copy paste the below script

echo " "
echo "Hello ,Please choose  the RED5 version : (1,2,3 or 4)"
echo " "
echo "1.  RED5 0.7.0"
echo "2.  RED5 0.6.3"
echo "3.  RED5 0.5  "
echo "                     Press Any other key to install 1. RED5 0.7.0"
read ver
cd /usr/src
echo ""
echo ""
echo "Downloading and installing   jpackage utils rpm......."
echo ""
echo ""
wget -c --tries=inf http://mirrors.dotsrc.org/jpackage/1.7/generic/free/RPMS/jpackage-utils-1.7.5-1jpp.noarch.rpm
rpm -Uvh jpackage-utils-1.7.5-1jpp.noarch.rpm
echo ""
echo ""
echo "Downloading and installing   JDK 1.6 update 5 ..........."
echo ""
echo ""
wget -c --tries=inf http://69.72.132.53/jdk-6u5-linux-i586.rpm
rpm -Uvh jdk-6u5-linux-i586.rpm
echo ""
echo ""
echo "Downloading and installing   Apache Ant 1.7  ..........."
echo ""
echo ""
wget -c --tries=inf http://archive.apache.org/dist/ant/binaries/apache-ant-1.7.0-bin.tar.gz
tar -xzvf apache-ant-1.7.0-bin.tar.gz
mv apache-ant-1.7.0 /usr/local/ant
echo ""
echo ""
echo "Exporting Paths and Variables for Ant  ..........."
echo ""
echo ""
echo 'export PATH=$PATH:/usr/local/ant/bin'>>/etc/profile
echo 'export ANT_HOME=/usr/local/ant'>>/etc/profile
export PATH=$PATH:/usr/local/ant/bin
export ANT_HOME=/usr/local/ant
echo ""
echo ""
echo "Downloading and installing   RED 5  ..........."
echo ""
echo ""
case $ver in
2)
wget -c --tries=inf http://dl.fancycode.com/red5/0.6.3/src/red5-0.6.3.tar.gz
tar -xzvf red5-0.6.3.tar.gz
mv red5-0.6.3 /usr/local/red;;
3)
wget -c --tries=inf http://dl.fancycode.com/red5/red5-0.5.tar.gz
tar -xzvf red5-0.5.tar.gz
mv red5-0.5 /usr/local/red;;
1|*)
wget -c --tries=inf http://red5.nl/installer/red5-0.7.0.tar.gz
mkdir red5
mv red5-0.7.0.tar.gz red5/
cd red5
tar -xzvf red5-0.7.0.tar.gz
rm -rf red5-0.7.0.tar.gz
cd ..
mv red5 /usr/local/red;;
esac
wget -c --tries=inf http://linuxstuffs.net/red5
mv red5 /etc/init.d/
chmod 755 /etc/init.d/red5
cd /usr/local/red
chmod 755 red5.sh
ant -v
./red5.sh

chmod 755 red5install

./red5install

Its done !!!

—————————————————————————————————–

if  http://linuxstuffs.net/red5 doesn’t work, please use the following method.

cd /etc/init.d/
touch red5
chmod 755 red5
vi red5

----------------------------------------------------------

RED5_DIR=/opt/red5
test -x $RED5_DIR/red5.sh || exit 5

case "$1" in
    start)
        echo -n "Starting Red5 Service"
        echo -n " "
        cd $RED5_DIR
        su -s /bin/bash -c "$RED5_DIR/red5.sh &" red5
        sleep 2
        ;;
    stop)
        echo -n "Shutting down red5"
        echo -n " "
        su -s /bin/bash -c "killall -q -u red5 java" red5
        sleep 2
        ;;
    restart)
        $0 stop
        $0 start
        ;;
esac
----------------------------------------------------------

Then you can simply start, stop, and restart red5 from that script by typing:

/etc/init.d/red5 start

/etc/init.d/red5 stop
/etc/init.d/red5 restart




Recompile Perl in Cpanel servers

16 06 2009

To check what is the perl version on your system, use:

perl -v

This is perl, v5.8.7 built for i686-linux

If you need to upgrade your perl installation without breaking your CPanel, please follow this method.

wget http://layer1.cpanel.net/perl588installer.tar.gz
tar xfz perl587installer.tar.gz
cd perl587installer
./install

After this is done, run:

/scripts/upcp

You can also run the following to ensure that all the necessary modules were reinstalled:

/usr/local/cpanel/bin/checkperlmodules

Once you have completed the upgrade, you can check again the perl version (perl -v) to ensure that this was properly installed.








Follow

Get every new post delivered to your Inbox.