Friday, September 10, 2010

Can't mount: /vz/root/100 /vz/private/100: No such file or directory

When you start a VPS, you may got this error:
Can't mount: /vz/root/100 /vz/private/100: No such file or directory


[root@testpc ~]# vzctl start 100
Starting container ...
Can't mount: /vz/root/100 /vz/private/100: No such file or directory


To fix this using


# umount /vz/root/100


then,


# vzctl start 100






.

Wednesday, September 8, 2010

-bash: ./sc_serv: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

[root@testpc ~]# ./sc_serv sc_serv.conf
-bash: ./sc_serv: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory




when you try ot run " ./sc_serv ", you may got the error like this '-bash: ./sc_serv: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory'




To solve this error, you need to install glibc 32 bit


[root@testpc ~]# yum install glibc.i686


[root@testpc ~]# rpm -qf /lib/ld-linux.so.2
glibc-2.11.90-15.i686


[root@testpc ~]#./sc_serv
*******************************************************************************
** SHOUTcast Distributed Network Audio Server
** Copyright (C) 1998-2004 Nullsoft, Inc.  All Rights Reserved.
** Use "sc_serv filename.ini" to specify an ini file.
*******************************************************************************
......
.......
.........
............
...............
.................


:)



Friday, September 3, 2010

HOw to install WordPress(Centos):

HOw to install  WordPress :


Before installing wordpress you have to install httpd,php and mysql..



# yum -y install httpd*  php*  mysql-server
# chkconfig httpd on
# chkconfig mysqld on
# /etc/init.d/mysqld start
# /etc/init.d/httpd start



Create wordpress database:

# mysql -u root -p
mysql> CREATE DATABASE Databasename;
(eg: CREATE DATABASE wordpressdb;)
mysql> show databases;
mysql> exit

Download and configure wordpress:

wget http://wordpress.org/latest.zip
unzip latest.zip
cd wordpress
cp -a * /var/www/html
cd /var/www/html
mv wp-config-sample.php wp-config.php

# vi wp-config.php

--edit in this line--

define('DB_NAME', 'wordpressdb');
define('DB_USER', 'root');
define('DB_PASSWORD', 'mysqlrootpass');

Server configuraion is completed.. now you have to do the online confiuration..

http://{ip or hostname}/wp-admin/install.php


Enjoy....... :)





Tuesday, August 31, 2010

Install and Configure telnet :

Install and Configure telnet :



Install telnet:


# yum install telnet*


This will install telnet and xinetd packages...


# chkconfig telnet on
# chkconfig xinetd on
# /etc/init.d/xinetd start


# vi /etc/xinetd.d/telnet


# default: on
# description: The telnet server serves telnet sessions; it uses \
#       unencrypted username/password pairs for authentication.
service telnet
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/in.telnetd
        log_on_failure  += USERID
        disable         = no
}


# /etc/init.d/xinetd restart




To connect:


telnet {host ip}


# telnet 192.168.1.x


# telnet 192.168.1.x
Trying 192.168.1.x...
Connected to 192.168.1.x.
Escape character is '^]'.
Fedora release 9 (Sulphur)
Kernel 2.6.33-default on an x86_64 (4)
login:
Password:




Give the username and password....


===============================================


If you got an error like


"getaddrinfo: localhost Name or service not known 
Connection closed by foreign host."


check the /etc/hosts file having two lines..


127.0.0.1 localhost.localdomain localhost
192.168.1.x   restpc.com


where restpc.com is my host name..


And in /etc/sysconfig/network file also having the same HOSTNAME as restpc.com


===============================================


The default port number of telnt 23.


To check the telnet port number


# /usr/sbin/semanage port -l | grep telnet
telnetd_port_t                 tcp      23


oR


# cat /etc/services | grep telnet


================================================


To Download this document  in txt format just click the following link..


http://www.ziddu.com/download/15762093/InstallandConfiguretelnet.txt.html





Saturday, August 14, 2010

service failed to start due to unresolved dependencies: set(['user', 'iptables_openvpn'])

"service failed to start due to unresolved dependencies: set(['user', 'iptables_openvpn'])
service failed to start due to unresolved dependencies: set(['user', 'iptables_openvpn'])
service failed to start due to unresolved dependencies: set(['user', 'iptables_openvpn'])
service failed to start due to unresolved dependencies: set(['iptables_openvpn']) "

This is mostly the iptables modules issue in the node, do the following steps to solve the issue.



** First check the TUN/TAP is enabled or not

Run the following command in your VPS to check the TUN/TAP is enabled or   not.
# cat /dev/net/tun
If this shows "File descriptor in bad state" means TUN/TAP is enabled in your -vps. If  not enable it.



** Edit /etc/vz/vz.conf and add "ipt_state" and "iptable_nat" to the end of the list of IPTABLES modules(From node).



** Install the following kernel module using the following command(From node).

         # modprobe ipt_mark
         # modprobe ipt_MARK



** Now restart the container(From node).

         # vzctl restart xxx


This will solve your issue.


         

Thursday, July 22, 2010

How to Change the ip address in Linux

Change the ip address in Linux:



YOU CAN USE ANY ONE OF THE FOLLOWING METHODS.

METHOD 1(GUI) :

[root@localhost ~]#system-config-network
(a)Select the ethernet interface(Eg:eth0) and change the ip and netmask.
OR
[root@localhost ~]#setup
(a)Select the 'Network configuration' tab.
(b)Select the ethernet interface(Eg:eth0) and change the ip and netmask.



METHOD 2(SCRIPT) :

[root@localhost ~]#cd /etc/sysconfig/network-scripts/
[root@localhost ~]#vi ifcfg-eth0
Enter the new ip in this script file.



METHOD 3(COMMAND LINE) :

(Make sure you are not changin the remote hosts ip. If you use this command to change the remote host ip, you will lost the commection)

Set new ip to 192.168.1.11
[root@localhost ~]#ifconfig eth0 192.168.1.11
Set new ip with nermask
[root@localhost ~]#ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up



.

Monday, June 28, 2010

How to install Directadmin

How to install Direct admin

Direct Admin installation is very simple process to do.

Before installation kindly check the following packages are installed..

gcc
gcc-c++
automake
make
flex

If not install it using yum.



Install DirectAdmin:

# wget http://directadmin.com/setup.sh

# chmod +x setup.sh

# ./setup.sh

 When you run this setup.sh, it will ask you to fill the following informatrion..

==========
Client ID:

License ID:

Hostname:

Is this correct? (y,n) :

Is eth0 your network adaptor with the license IP? (y,n) :

Enter the name of the ethernet device you wish to use :

Is XXX.XXX.XXX.XXX the IP in your license? (y,n) :

DirectAdmin will now be installed on: Enterprise 5
Is this correct? (must match license) (y,n) :

You now have 2 options for your apache/php setup.

Enter your choice (1 or 2):

Would you like the default settings of apache 2.2 and php 5 cli? (y/n):
==========


it will take little bit time to install the directadmin..
At the end of the installation it wil generate username,passoerd... and display it
like..

 -----------------------
The following information has been set:

Admin username:   admin
Admin password:   xxxxxxx
Admin email:      xxx@xxxxxxx


Server IP: xxx.xxx.xxx.xxx
Server Hostname: xxxxxxxxxxx.com

To login now, follow this link:

http://XXX.XXX.XXX.XXX:2222

and enter your Admin username and password when prompted.

Thank you for using DirectAdmin.
-------------------

.

Monday, June 21, 2010

How to create software raid0

How to create software raid0

RAID:

RAID- Redundant Array of Independent Disks
RAID0- is a method of storing data on multiple computer storage devices to achieving faster read and write speeds.The data is broken down into blocks and each block is written to a separate disk drive. If one disk fails total data will loose.

Here we are going to create software raid0.

consider we have 2 hardisk sda and sdb

# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1318    10482412+  83  Linux
/dev/sda3            1319        1579     2096482+  82  Linux swap / Solaris
/dev/sda4            1580       60801   475700715   83  Linux

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1       60801   488384001   42  SFS


We are going to create raid in /dev/sda4 and /dev/sdb1

First we have to change the id of both the partitions.

# fdisk /dev/sda
..........
..........
Command (m for help):t
Partition number (1-4):4
Hex code (type L to list codes):fd
Command (m for help):w


# fdisk /dev/sdb
..........
..........
Command (m for help):t
Partition number (1-4):1
Hex code (type L to list codes):fd
Command (m for help):w

NOw,

# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1318    10482412+  83  Linux
/dev/sda3            1319        1579     2096482+  82  Linux swap / Solaris
/dev/sda4            1580       60801   475700715   fd  Linux

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1       60801   488384001   fd  SFS

Use the partprobe to reload the changes without rebooting the box:

# partprobe /dev/sda4
partprobe /dev/sdb1


Create raid0:

# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sda4 /dev/sdb1

create file system on our raid,

# mkfs.ext3 /dev/md0 

To check the raid0,

# cat /proc/mdstat 
Personalities : [raid0]
md0 : active raid0 sdb1[1] sda4[0]
      964083520 blocks 64k chunks
unused devices:


and,

# mdadm --detail /dev/md0 
/dev/md0:
        Version : 0.90
  Creation Time : Wed Jun 16 02:01:47 2010
     Raid Level : raid0
     Array Size : 964083520 (919.42 GiB 987.22 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Wed Jun 16 02:01:47 2010
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

     Chunk Size : 64K

           UUID : 7df3ae47:4d85c172:4522530b:f2487312
         Events : 0.1

    Number   Major   Minor   RaidDevice State
       0       8        4        0      active sync   /dev/sda4
       1       8       17        1      active sync   /dev/sdb1


Finally we have to mount the raid to any location like,

# mount /dev/md0 /raid

If you want to prementaly mount it, give the detais in the fstab.

I think this document is usefull for you...... :-)



.

To Compress Drectory/File in Linux

To Compress Drectory/File in Linux.

Here we are going compress the directory/file using the tar command.
This is a good way to create backups and archives.

Some of the options used with the tar are: 

-c:  Create archive
-v:  Verbose i.e show the progress of the files being archived.
-f:  Archive File name
-t:  Show the list of files in the tar file.
-x:  Extract files from an archive.
-z:  Compress the tar file with gzip(gzip-Compression Tool)
-j:  Compress the tar file with bzip2(bzip-Compression Tool)


Example:

1)To compress the /home/admin/user1 folder as backup1.tar.gz

# tar -zcvf backup1.tar.gz  /home/admin/user1

To restore the 'tar.gz',

# tar -zxvf backup1.tar.gz

to restore in a particular directory

# tar-zxvf backup1.tar.gz -C /tmp


2)To compress the /home/admin/user1 folder as backup1.tar.bzip2

# tar -jcvf backup1.tar.bzip2  /home/admin/user1

To restore the 'tar.bzip2',

# tar -jxvf backup1.tar.bzip2






.

Sunday, June 20, 2010

SSHD fatal: daemon() failed: No such device

SSHD fatal: daemon() failed: No such device:

If you got error like "sshd stop failed", check the log message in  /var/log/secure . Here you may find the "SSHD fatal: daemon() failed: No such device" error.

You can solve it using the following simple steps:

# rm -rf /dev/null
# mknod /dev/null c 1 3
/etc/rc.d/init.d/sshd restart


.

Wednesday, June 16, 2010

Install and use rsync

Install and use rsync


rsync is a free software computer program for Unix and Linux like systems.


Using rsync we can take backup/mirroring a directory tree of files from one machine to another machine or in a same machine.


To install rsync:


In  Ubuntu,
# apt-get install rsync


In  CentOS/Fedora Core Linux,
# yum install rsync


rsync syntax:


rsync {source}  {destination}


Options:
--delete : delete files that don't exist on sender (system)
-v          : Verbose
-a         : archive mode
-r         : recurse into directories
-z        : compress file data


Example:


In a single machine:


# rsync -avz /src/bar /data/tmp


This will transfer all files from the directory /src/bar to /data/tmp/bar directory.


# rsync -avz /src/bar/ /data/tmp


This will transfer all files from the directory /src/bar to /data/tmp/.
"/" (slash) on a source means "copy the contents of this directory".




From a local computer to a remote server:


rsync  -avz  --rsh='ssh -p{ssh-port.no}'   {source}  {remote machine IP}:{destination}


example:


rsync  -avz   --rsh='ssh  -p2222'  /src/bar/  192.168.1.1:/data/tmp/


If the remote server using default port(22):


rsync  -avz   -e ssh  /src/bar/  192.168.1.1:/data/tmp/


.

Saturday, June 12, 2010

chkconfig in Ubuntu

chkconfig in Ubuntu :

chkconfig in ubuntu is  sysv-rc-conf



On Ubuntu you need to install

# sudo apt-get install sysv-rc-conf
Once it is installed run the command

# sudo sysv-rc-conf


Friday, June 11, 2010

How to set mysql root password

How to set mysql root password:

You can easily set the mysql root password...

# mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql> exit


Now try to login with the password:

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.......
.......

Wednesday, May 26, 2010

How to change the hostname in Linux

To change the host name in Ubuntu, Debian,.....

# vi /etc/hostname

new_hostname

# /etc/init.d/hostname.sh restart

To change the host name in Redhat,CentOs,fedora,......

Give the new hostname in the following files

# vi /etc/hosts
# vi /etc/sysconfig/network

OR

# sysctl kernel.hostname=new_hostname


.

Tuesday, May 18, 2010

How to configure csf on vps

Configure csf on vps

1) Configuration in node(Main Server):

Before starting the csf installation check whether the following modules are inserted in the kernel:

ipt_conntrack
ip_tables
ipt_LOG
ipt_multiport
ipt_REJECT
ipt_state
ipt_limit
ipt_recent
ipt_owner
iptable_nat

You can check it as follows

# lsmod |grep -i {modules}

If not insert these modules into the kernel

#modprobe {modules}
eg: modprobe ipt_recent

Add these modules to iptable configuration as follows

# vi /etc/sysconfig/iptables-config

Add the following in this file

IPTABLES_MODULES="iptable_filter iptable_mangle ipt_limit ipt_multiport ipt_tos ipt_TOS ipt_REJECT ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_LOG ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_conntrack ipt_state ipt_helper iptable_nat ip_nat_ftp ip_nat_irc"

Add these modules in the VPS configuration file

# vi /etc/sysconfig/vz-scripts/100.conf

IPTABLES_MODULES="iptable_filter iptable_mangle ipt_limit ipt_multiport ipt_tos ipt_TOS ipt_REJECT ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_LOG ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_conntrack ipt_state ipt_helper iptable_nat ip_nat_ftp ip_nat_irc"

Main server(node) configuration is over. Now restart the vps

# vzctl restart
eg: vzctl restart 100

2) VPS configurttion:

Enter in to VPS

#cd /usr/local/src/
# wget http://www.configserver.com/free/csf.tgz

# tar zxvf csf.tgz
# cd csf
# ./install.sh

To test all the iptable modules are available

# ./csftest.pl

If you are running apf_bfd firewall, it has to be removed for csf works

# ./remove_apf_bfd.sh

Now to configure csf config file to implement firewall as per our need

# vi /etc/csf/csf.conf

TESTING = “1"
(We will change it to zero “0″ when we finished and sure we have configured correctly)

TCP_IN = “20,21,22,25,53,80,110,143,443,465,587,993,995″
TCP_OUT = “20,21,22,25,53,80,110,113,443″
UDP_IN = “20,21,53″
UDP_OUT = “20,21,53,113,123"
(Put your all ports which you want to be open on your server for incoming & outgoing traffic seperated by comma)

PORTFLOOD = “80;tcp;20;5″
(To protect your server any specific port from DOS attacks, you can define it in PORTFLOOD tag. By default its empty and i did like to limit 20 connections per 5 sec to port 80 (webserver))

After this save the file and restart the csf service

# /etc/init.d/csf start

If you completed with configuation and sure that every rules is implemented correctly then change Testing from 1 to 0 for run CSF permanently.

TESTING = “0″

and restart the service again to activate it

# /etc/init.d/csf restart



Sunday, May 2, 2010

To test whether the TUN/TAP device is available

To test whether the TUN/TAP device is working or not:

# cat /dev/net/tun

If you receive the message cat: /dev/net/tun: File descriptor in bad state your TUN/TAP device is ready for use.

If you receive the message cat: /dev/net/tun: No such device the TUN/TAP device was not successfully created.


.

Command to check the software raid is working fine

Command to check the software raid is working fine:

Check the mdstat file:

# cat /proc/mdstat

You are looking for a line like this:

md0 : active raid1 sdb5[0] sda5[1] 32000 blocks [2/2] [UU]

If the last part ever changes you know one of the drives has failed, ie if it changes to "[2/1] [U_]" then the second drive is out.



Saturday, May 1, 2010

SSL: error:00000000:lib(0):func(0):reason(0)

SSL: error:00000000:lib(0):func(0):reason(0)

When you restart the kloxo you may got this error message.
To solve this,

# yum downgrade openssl
# yum update

This will fix the issue.


.

Friday, April 23, 2010

TypeError: rpmdb open failed

TypeError: rpmdb open failed
When you install or update a package using yum you will get this error.

solution:

#rm /dev/urandom
#mknod -m 644 /dev/urandom c 1 9




.

Wednesday, April 21, 2010

Transaction Check Error:

When you are running 'yum update' you will get the following error.

Transaction Check Error:
file /usr/share/emacs/site-lisp/psvn.el from install of subversion-1.4.6-0.1.el5.rf conflicts with file from package subversion-1.4.2-2.el5
file /usr/share/xemacs/site-packages/lisp/psvn.el from install of subversion-1.4.6-0.1.el5.rf conflicts with file from package subversion-1.4.2-2.el5
...................
......................


Solution:

# yum erase subversion

After that 'yum update' will work fine.


.

Sunday, April 18, 2010

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

first stop the mysql:
# service mysqld stop

enter into the mysql safe mode
# mysqld_safe --skip-grant-tables &

login as a root with no password
# mysql -uroot mysql

In mysql command prompt
> UPDATE user SET password=PASSWORD("newpassword") WHERE user="root";
> FLUSH PRIVILEGES;
> EXIT

restart the mysql
# /etc/init.d/mysqld restart

Now you can enter in to mysql using the root password "newpassword"



Thursday, April 15, 2010

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

"ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) "

When you restart the mysql you may got this error.

# ps ax | grep mysql

you will get two or more pid of mysql. kill all using the following command.

# kill -9 xxxx xxxx

Now restart the mysql.

.

how to install kloxo panel

how to install kloxo panel:

# wget http://download.lxlabs.com/download/kloxo/production/kloxo-install-master.sh
# sh ./kloxo-install-master.sh


Now you can login into the panel by "http://(ip):7778"
default username : admin
password : admin

.

thread.error: can't start new thread

"thread.error: can't start new thread"
When you try to install some package using yum you will get this error. Because yum-fastestmirror break the yum function. To run yum, disable the fastestmirror.


# vi /etc/yum/pluginconf.d/fastestmirror.conf

enabled=0 (default the value is '1' change it to '0')

# yum shell
Setting up Yum Shell
> update
> exit


Now you can install using yum.


.

Wednesday, April 14, 2010

How to check DDOS Attack on Server

How to check DDOS Attack on Server:

To list the IPs taking the most amounts of connections to a server:

#netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

To check active connections that are open to your server:

# netstat -n | grep :80 |wc -l



.

Saturday, April 10, 2010

How to find the hostname, domainname, ip and os installed in linux

To find the hostname:
You can find the host name using following commands

# hostname
OR
# uname -n
OR
# cat /proc/sys/kernel/hostname
OR
# sysctl kernel.hostname


To find the domainname:
You can find the domainname by

# dnsdomainname

To find the ip address:
You can find the ip address by

# ifconfig

OR

#route -n

To find which OS is installed in linux

# cat /etc/*release*
Or
#cat /etc/issue


.

PRNG is not seeded

Starting sshd: PRNG is not seeded

# service sshd start

starting sshd : PRNG is not seeded


Solution:

# cd /dev/
# ./MAKEDEV generic


Install PhpMyadmin

How to install PhpMyadmin(CentOS)

# yum install phpmyadmin
# service httpd restart

To Test:

http://localhost(or ip)/phpmyadmin

You will get the PhpMyadmin home page. Using Mysql root password you can login.



                        ==============================


Error:


If you got error message when you open the phpmyadmin in webpage like, " 404 page not found....."



You must add the following 'include' and 'alias' in the bottom of the apache configuration file.

Include /etc/phpmyadmin/apache.conf
Alias /phpmyadmin /usr/share/phpmyadmin


Restart the apache and try again...

.

Friday, April 9, 2010

Unable to set capability on running container

Unable to set capability on running container:

# vzctl set 101 --capability net_admin:on --save

Unable to set capability on running container
WARNING: Some of the parameters could not be applied to a running container.
Please consider using --setmode option
Saved parameters for CT 101

Solution:
Restart the vps

#vzctl restart 101

Then do all the steps again.

.

Enable TUN/TAP

How to Enable TUN/TAP
How to configure TUN/TAP

You should do the following steps on the 'node'
To check the tun module has been already loaded on the node.
# lsmod | grep tun
If it is not loaded
# modprobe tun

Allow your container to use the tun/tap device
# vzctl set 101 --devices c:10:200:rw --save
# vzctl set 101 --capability net_admin:on --save

create the character device file inside the container
# vzctl exec 101 mkdir -p /dev/net
# vzctl exec 101 mknod /dev/net/tun c 10 200
# vzctl exec 101 chmod 600 /dev/net/tun


vzctl set {vps_id} --iptables
"iptable_filter iptable_mangle ipt_limit ipt_multiport ipt_tos ipt_TOS
ipt_REJECT ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_LOG ipt_length
ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_conntrack ipt_state
ipt_helper iptable_nat ip_nat_ftp ip_nat_irc" --save