How To Format Disk in linux

In the previous post we discussed how to re-size disk space,
Now lest say you want to add additional disk to your machine.

Follow the commands: 

step 1 -  Partition
# fdisk -l | grep Disk
Disk /dev/sda: 549.7 GB, 549755813888 bytes
Disk /dev/sdb: 107.3 GB, 107374182400 bytes 

you'll see the disks on your machine, we want to partition the new disk /dev/sdb

# fdisk /dev/sdb
n - add new partition - follow the instruction
p - print the partition table - check the partition
w - write table to disk and exit

step 2 - Format

mkfs.ext3 /dev/sdb1

step 3 - Mount
# mkdir /New-Disk
# mount /dev/sdb1 /New-Disk

step 4 - Update /etc/fstab
# vi /etc/fstab
add the next line to the file:
/dev/sdb1     /New-Disk     ext3     defaults     1 2
Save and close the file.

Now check the changes:
# df -h

How To display Timestamp in History command

By default, the history command shows just the command number and the command.
it could be very useful to add a timestamp to be shown, this can help you to monitor things by the time you run something.

To add the timestamp you need to export the next command:
#  export HISTTIMEFORMAT='%F %T '

if you want, you can add this line to your profile, so next you boot your machine, it will run automatic:
just edit /etc/profile  and add the line above.

Best Regards

How to resize ext3 partition - GPartEd

Hi, couple of days ago was asked to increase ext3 partition without LVM.
After searching the web I found a cool Linux Live CD called GPatrEd.
because it has just one partition  " /dav/sda1 on / "  i could not unmount it the resize it with the new space.
I was had to used a live CD.
I'm talking about virtual machine, so first I increased the disk space of the virtual machine
then I restart and boot from GPartEd live CD.
The UI is very simple and fun actually, 
all you need to do is to resize the partition with the mouse the click APPLY.

After finishing, I restart the machine again and WALLA I had new partition space on my server.


How To install Load Balancer with HAProxy on Debian

Hi, today I want to discuss on how to install a LB for web servers base on http (linux or windows) on debian.

First we need to add the source of the installation to sources.list
# vi /etc/apt/sources.list

and add the following lines:
deb etch main
deb-src etch main

deb lenny main

deb etch/updates main contrib
deb-src etch/updates main contrib

Next we need to update the sources and install the HAproxy

# apt-get update
# apt-get install haproxy

First we backup the original configuration
# cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.orig
# cat /dav/null > /etc/haproxy/haproxy.cfg

and new we create a new configuration for our Round Robin LB.
edit the haproxy.cfg file and add the following lines:
# vi /etc/haproxy/haproxy.cfg
        log   local0
        log   local1 notice
        maxconn 4096
        user haproxy
        group haproxy

        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

listen webfarm LB-IPAddress:80
       mode http
       stats enable
       stats auth someuser:somepassword
       balance roundrobin
       cookie JSESSIONID prefix
       option httpclose
       option forwardfor
       server webA serverA-IP:80 cookie A check
       server webB serverB-IP:80 cookie B check

make sure you change the RED lines to your settings.
and now we need to ENABLE the haproxy in /etc/default/haproxy
# vi /etc/default/haproxy
and set ENABLE=1

to start haproxy just run:
# /etc/init.d/haproxy start

that's it you have a Load Balancer Installed and work.

HAproxy Statistics:
In this configuration we enable the statistics of haproxy, you can acsses from you browser by enter http://LB-IPAddress/haproxy?stats

The user and the password is like you type in the configuration in "stats auth someuser:somepassword"

Enjoy and please comment !!!


How To install Apache MySQL and PHP

The easy way to install a web server with apache MySQL and PHP is by a project called XAMPP
XAMPP is a project of apache friends how let you the easy way to install Apache distribution containing MySQL, PHP and Perl.

I was trying to create a new WordPress blog on one of my servers. and I found this project very helpful.
All you have to do is to download a tar file from from XAMPP website untar him and thats it.
I will show you how it goes:

Download the last version of XAMPP from here -
Run the command:
tar xvfz xampp-linux-1.7.3a.tar.gz -C /opt

That's all. XAMPP is now installed below the /opt/lampp directory.
All you need to do to start the XAMPP is:
# /opt/lampp/lampp start

You should now see something like this on your screen:Starting XAMPP 1.7.3a...
LAMPP: Starting Apache...
LAMPP: Starting MySQL...
LAMPP started.

Go to your server via you browser ~ http://localhost

for more information and tricks go to the main project website -

Apache Compile Wallpaper

A new Wallpaper I found
Discover Simple, Private Sharing at

How To make SSH Tunnel

In this post I'll discuss no how to make ssh tunnel
this how to will show you the basic, and I hope you will take the good from it to your needs.

the main configuration is:
edit /etc/ssh/ssh_config with your favorite editor
# vi /etc/ssh/ssh_config
and add flowing lines in the end

Host test
HostName localhost
User your_user_name
LocalForward 2022 SERVER1_IP:22
LocalForward 2080 SERVER2_IP:80
LocalForwars 2025 SERVER3_IP:25

save the file.
and run: # ssh test
now if you'll try to access to localhost on port 2080 you'll go to SERVER2 on port 80, you can test it from your browser - http://localhost:2080/ or try to ssh to locahost with port 2022
# ssh -p 2080 localhost

and you'll see you go to SERVER1.

You can run the ssh tunnel from one command line instead of edit the ssh_config.
# ssh -N -f User_Name@SERVER2_IP -L 2080/localhost/80
this script tell the server to forward all the traffic to port 2080 to SERVER2 on port 80

Or if you want to make REVERSE tunnel you can run the same command but with -R instead of -L
# ssh -N -f User_Name@SERVER2_IP -R 2022/localhost/22
(with this script you can access from the remote machine (SERVER2) via ssh to your machine with port 2022)
run # ssh -p 2022 localhost from SERVER2

I'm hoping this post will help you to understand the basic of ssh tunneling
Please comment