Forward Incoming port 80 to 8080

Forward Incoming port 80 to 8080:-

We can set port forwarding by using iptables. Means we can set the rules in iptables.

If iptables rpm is not installed in server, so please insatll it.
[root@localhost ~]# yum install iptables

Start iptables service.
[root@localhost ~]# service iptables start

Make sure iptables starts up by default after a server restart
[root@locahost ~]# chkconfig iptables on

Then set the iptables rule.
[root@localhost ~]# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080

Save this rule.
[root@localhost ~]# service iptables save

You can test it from server IP Address. Open the browser and type the server IP Address.


Thats it...

Install tomcat 6 in Linux server.

Install tomcat 6 in Linux server.

Install the tomcat6 using yum..
[root@localhost ~]# yum install tomcat6

Start the tomcat6 service.
[root@localhost ~]# service tomcat6 start

Change default port of tomcat to 80 or any port.

Change default port of tomcat to 80 or any desire port:-

Most of user want to change this default port to 80. Port 80 is by default using for web site.
Kindly go through below step and change the port.

STEP 1:- Stop the tomcat service.
[root@localhost ~]# service tomcat6 stop

STEP 2:- Find the tomcat path, Defalut tomcat6 path is /etc/tomcat6/. There is configuration file by name server.xml.

STEP 3:- Run the below commands one by one.
[root@localhost ~]# sudo sed -i 's/port="80"/port="8080"/' /etc/tomcat6/server.xml

[root@localhost ~]# sudo sed -i 's/port="443"/port="8443"/' /etc/tomcat6/server.xml

Http default port is 8080 and Https default port is 8443. You have change it to 80 and 443 respectively.

You can also change this to any desire port. e.g. for http is 123 and https is 456. Then you run the below command as.

[root@localhost ~]# sudo sed -i 's/port="123"/port="8080"/' /etc/tomcat6/server.xml

[root@localhost ~]# sudo sed -i 's/port="456"/port="8443"/' /etc/tomcat6/server.xml

STEP 4:- Start the tomcat service as below.
[root@localhost ~]# service tomcat6 start.

STEP 5:- Check port 80 is listening or not using below command.
[root@localhost ~]# netstat -ano | grep :80

Also before changing tomcat port you make sure that on port 80 or desire port is not in use...

Configure NTP client server in linux

NTP client server configuration:-

STEP 1. Install the ntp rpm (Packages).
[root@localhost ~]# yum install ntp

STEP 2. Start NTP service.
[root@localhost~]# /etc/init.d/ntpd start

STEP 3. Check the NTP service status.
[root@localhost ~]# /etc/init.d/ntpd status

STEP 4. Open the NTP port 123 from server to out (Out Bound) in your hardware firewall (If you are using). This is UDP port.

STEP 5. Check the date and time, it is proper or not:-
[root@localhost ~]# date

STEP 6. Stop the NTP service.
[root@localhost ~]# /etc/init.d/ntpd stop

STEP 7. Syncing date and time from NTP servers, Run the below command.
[root@localhost ~]# ntpdate

STEP 8. Then start the NTP service.
[root@localhost~]# /etc/init.d/ntpd start

Disable user account in Linux

Disable user account in Linux:-

Method 1:-
[root@localhost ~]# usermod -s /bin/nologin user_name


-s= Shell
/bin/nologin= Shell name

Method 2:-
[root@localhost ~]# usermod -s /sbin/nologin user_name


/sbin/nologin= Shell name

Both methods will work fine....

Install and remove rpm(Packages) in Linux server/machine

Install and remove rpm(Packages) in Linux server:-

Install RPM:-

[root@localhost ~]# yum install package_name

e.g:- [root@localhost ~]# yum install mysql

Remove RPM:-

[root@localhost ~]# yum remove package_name

e.g:- [root@localhost ~]# yum remove mysql

How to increase Linux server remote session time

Increase Linux server remote session time:-

Put the below option in sshd_config file under /etc/ssh/ directory.

ClientAliveInterval 180

[root@localhost ~]# cd /etc/ssh/
[root@localhost ssh]# pwd
[root@localhost ssh]# ll
total 200
-rw------- 1 root root 132839 Mar 31 2010 moduli
-rw-r--r-- 1 root root 1827 Mar 31 2010 ssh_config
-rw------- 1 root root 3324 Nov 18 18:30 sshd_config
-rw------- 1 root root 668 Nov 17 00:49 ssh_host_dsa_key
-rw-r--r-- 1 root root 590 Nov 17 00:49
-rw------- 1 root root 963 Nov 17 00:49 ssh_host_key
-rw-r--r-- 1 root root 627 Nov 17 00:49
-rw------- 1 root root 1675 Nov 17 00:49 ssh_host_rsa_key
-rw-r--r-- 1 root root 382 Nov 17 00:49
[root@localhost ssh]#


180= Client ideal session time

How to set date and time in Linux Machine/Server

Login in machine as a root user and run the below command.

[root@localhost ~]# date -s "14 dec 2003 14:15:16"


14 dec 2003=Date you want set (14=Date, dec=Month & 2003=Year)
14:15:16:=Time you want to set (14=Hr, 15=Min & 16=Sec)

How to shutdown Linux Machine/Server

Log in Linux machine as a root user and run the below command.

[root@localhost ~]# init 0

How to reboot/restart Linux Machine

Log in Linux machine as a root user and run the below command.

[root@localhost ~]# init 6


[root@localhost ~]# reboot

Above both commands work.

Find out plesk admin password

Find out plesk "admin" password.

In plesk-10.x:- Login in server as a root user and run the below command.

[root@localhost ~]# /usr/local/psa/bin/admin --show-password

In Plesk-8.6 and Plesk-9.x:-Login in server as a root user and run the below command.

[root@i2mlnx ~]# cat /etc/psa/.psa.shadow && echo

Update Linux System/Machine/Server

Update Linux System/Machine/Server:-

Login as a root user and run the below command.

[root@localhost ~]# yum -y update

-y= Assume yes; assume that the answer to any question which would be asked is yes.

How to check LAMP Version

Check LAMP Version:-

Many times while managing several servers with different Operating System and version, you may be confused which LAMP version we are using. Same may happen this with client. Client may face difficulty in getting the LAMP version. Here is a small method to check the LAMP version.

1). Linux Version:-
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.1 (Santiago)

[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-042stab032.1 #1 SMP Sat Aug 13 18:16:00 MSD 2011 x86_64 x86_64 x86_64 GNU/Linux

As per above out put Operating System is RHEL 6.1 (64-Bit).

2). Apache Version:-
[root@loalhost ~]# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Aug 14 2010 08:53:20

As per above out put Apache version is 2.2.15.

3). Mysql Version:-
[root@localhost ~]# mysql -V
mysql Ver 14.14 Distrib 5.1.47, for redhat-linux-gnu (x86_64) using readline 5.1

As per above out put Mysql Version is 5.1.47 (64-Bit).

4). PHP Version:-
[root@localhost ~]# php -v
PHP 5.3.2 (cli) (built: Aug 17 2010 04:35:29)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

As per above out put PHP Version is 5.3.2.

How to check Hardware ID (HWID) Virtuozzo host

Check Hardware ID (HWID) of Hardware Node (Virtuozzo host/parent Server):-

You may use the below command on the virtuozzo host/parent server to find out the hardware ID (HWID).

[root@localhost ~]# cat /proc/vz/hwid

Hardware ID is use to maintain and associate the virtuozzo licenses.

Script for Container Creation

Script to creation of Virtuozzo Container (VPS):-
Create "container creation script" file and save this file with .sh extension (

[root@localhost ~]# vi

/usr/sbin/vzctl create 1003 --ostemplate centos-5-x86_64 --config slm.2048MB

/usr/sbin/vzctl set 1003 --onboot yes --save

/usr/sbin/vzctl set 1003 --hostname ABCD --save

/usr/sbin/vzctl set 1003 --ipadd --save

/usr/sbin/vzctl set 1003 --nameserver --save

/usr/sbin/vzctl set 1003 --userpasswd root:VpsC3arion --save

/usr/sbin/vzctl set 1003 --name XYZ --save

/usr/sbin/vzctl set 1003 --diskspace 104857600:104857600 --save

/usr/sbin/vzctl set 1003 --slmmemorylimit 4096M:4096M --save

/usr/sbin/vzctl start 1003


1003= Container ID (CTID)
centos-5-x86_64= Name of template
ABCD= Hostname of container IP address of container Name server
VpsC3arion= Password of container
XYZ= Name of container
104857600=Disk size in kb
4096M= Ram size of container

How to run this file:-

1). Set the permission of this file.

[root@localhost ~]# chmod a+x

2). Run this file.

[root@localhost ~]# ./

Install yum in parallels virtuozzo linux container

Yum installation in Virtuozzo Container:-

Login in to host/parent virtuozzo server as a root and just run the below command.

[root@localhost ~]# vzpkg install 104 -p yum


104= Container ID (CTID)

View or check the container ID (CTID) using below command.

[root@localhost ~]# vzlist -a

Using above command “vzpkg install 104 -p yum” you can also install any rpm (packages) in container.

E.g.:- [root@localhost ~]# vzpkg install 104 -p mysql

Installed mysql rpm in 104 container….

How to recover Mysql Data using ibdata1, ib_logfile0 and ib_logfile1

A couple of days ago my production (Live) Linux server was crashed. I was running Mysql in it. After making lots of efforts to recover database data, but I was unable to live mysql server back on it. I have only backup of /var/lib/mysql/ whole folder. I have copied all the contents of folder /var/lib/mysql/ (Don't copy ib_logfile0, ib_logfile1 files) in stock Linux server and follow the below steps and recover data from ibdata1, ib_logfile0 and ib_logfile1 and one by one taken backup of all database in .sql format in stock server and restore it on fresh (Production) mysql server. Don’t try these below steps on production server.

Kindly follow below steps to recover mysql database data.

STEP 1:- Installed the mysql rpm (Packages) in Linux stock server.[root@localhost ~]# yum install mysql-*

STEP 2:- Start the mysql service.
[root@localhost ~]# service mysqld start

STEP 3:- Go the directory /var/lib/ and check the ownership (permission) of mysql directory (Folder).
[root@localhost ~]# cd /var/lib/

[root@localhost lib]#ls –al

drwxr-xr-x 16 mysql mysql 4096 2003-12-02 20:36 mysql

STEP 4:- Stop the mysql service.
[root@localhost ~]# service mysqld stop

STEP 5:- Copy the ibdata1 and all database folder/directory in /var/lib/mysql/ directory. Don't copy ib_logfile0, ib_logfile1 files.

STEP 6:- Set the ownership (Permission) of all files and folders under /var/lib/mysql/ directory are mysql mysql
[root@localhost ~]# cd /var/lib/mysql/

[root@localhost mysql]# pwd

[root@lcoalhost mysql]# chown mysql:mysql *

STEP 7:- Start the mysql service.
[root@localhost ~]# service mysqld start

STEP 8:- Take the backup of all database one by one in .sql format and restore it to on Production mysql server.

For Mysql database backup and restoration.


Your server is crashed and got backup of /var/lib/mysql/ directory (Folder).

Take backup of Plesk-8.6 for linux

Plesk-8.6 Backup:-

This article describe how to take backup of Plesk-8.6. On Plesk backup restoration time .bak (Plesk backup file) and .map (Plesk Map file) both files are essential. So take the backup of both files. You can take backup using pleskbackup command or you can also set the cron job for this. We are describe both method below.

Manual Method:-

STEP 1:- Logged in server as root user (Super User) and run the below command.
[root@localhost ~]#/usr/local/psa/bin/pleskbackup all pleskbkp.bak

pleskbkp= Backup file name
all = Whole Plesk server backup

STEP 2:- Run the below command and take the backup of Plesk map file.
[root@localhost ~]#/usr/local/psa/bin/pleskrestore --create-map pleskbkp.bak -map

Where, Plesk server map file

Automatic Method:-

STEP 1:- Edit the crontab and put the script in it and save the same.
[root@localhost ~]# crontab -e
55 23 * * * /usr/local/psa/bin/pleskbackup all pleskbkp.bak
40 00 * * * /usr/local/psa/bin/pleskrestore --create-map pleskbkp.bak

STEP 2:- Run the below command and check the cron job list.
[root@localhost ~]# crontab -l
55 23 * * * /usr/local/psa/bin/pleskbackup all pleskbkp.bak
40 00 * * * /usr/local/psa/bin/pleskrestore --create-map pleskbkp.bak