Tag Archives: centos 6

How to reduce the root partition in LVM

In this tutorial, I am using the CentOS6(I believe that its also applicable on other Linux distro but didn’t try yet) that has ext4 partition lv_root mounted as / and lv_swap as swap from the volume group vg_centos6 (which is default), that has two hard drives (66GB & 25GB). Due to some reasons, I want to remove the 25GB hard drive from my computer and want to add new 50 GB hard drive. Before, removing the hard drive from the computer, we need to resize the lv_root, then remove it from volume group and at the end from the physical volume.

WARNING: It’s really dangerous, so backup your data before attempting this. Please don’t blame me, if you destory your system. You are responsible for your own actions!

Check the size of  lv_root before starting this process:

df -h

0 Read more of this post


How to extend the root partition in LVM

In this tutorial, I am using the CentOS6(but also applicable on other Linux distro) that has ext4 partition lv_root mounted as / and lv_swap as swap from the volume group vg_centos6 (which is default), we pretend that we are running out of space in lv_root(/) and volume group (vg_centos6) doesn’t have any free space. We added a brand new drive with 20 GB space. Now, we need to assign this 20 GB space to volume group and then extend lv_root(/).

WARNING: Backup your data before attempting this.

First, we’ll check the file system disk space usage and logical volume information:

sudo df -h
sudo lvs


Read more of this post

Fixing httpd: [warn] module php5_module is already loaded, skipping

I have a CentOS webserver with the Apache and PHP installed on it and it works perfectly but when I restart the Apache service, I get this error:

[warn] module php5_module is already loaded, skipping

To solve this problem, I have to verify this module load call in two files and need to remove/comment from one of these file.

First, I need to check Apache main file:

sudo nano /etc/httpd/conf/httpd.conf

Read more of this post

How to install VNC server on CentOS 6

VNC is a protocol that is used to share the desktop with other users/computers over the network/Internet.In order to share a desktop, VNC server must be install and configure on the computer and VNC client must be run on the computer that will access the shared desktop.

When we install the minimal copy of CentOS Server, it only gives us the “Command Line” interface.

But some people prefer GUI instead and for this they install Full version of Gnome on CentOS. Actually there is a better way and that is to install VNC. VNC provides a lightweight virtual desktop than full blown version of Gnome.

To run the VNC Server on CentOS, we have to install these required packages:

sudo yum groupinstall Desktop

sudo yum install tigervnc-server

sudo yum install xorg-x11-fonts-Type1

This is optional:

sudo yum install vnc

To start VNC Server on boot

sudo chkconfig vncserver on

To setup users’ VNC password:


Edit the /etc/sysconfig/vncservers file:

sudo nano /etc/sysconfig/vncservers

Add the following to the end of the file:

VNCSERVERARGS[1]="-geometry 1024x600"

The iptables rules need to be amended to open the VNC ports:

sudo iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6001:6003 -j ACCEPT
sudo service iptables save
sudo service iptables restart

Restart the VNC Server:

sudo service vncserver restart

Now kill the VNC Server:

vncserver -kill :1

Edit the xstartup file in .vnc directory:

nano .vnc/xstartup

Comment the last line and run the Gnome:

#twm & 
exec gnome-session &

Restart the service:

sudo service vncserver restart

Now, download VNCViewer onto our desktop computer from which we want to access the shared desktop. Connect using ServerIP/Name:1 (:1 is for the VNC server window), In my case it is centos:1.

Enter the password that we created using the vncpasswd command:

We now have GUI access to our server.

Ability to connect for multiple users:

Create a local user, using the following command:

sudo adduser ali

Create a password for newly created user:

sudo passwd ali

Switch to the newly created user and run vncpasswd command for it:

su ali

Edit the /etc/sysconfig/vncservers file:

sudo nano /etc/sysconfig/vncservers

Add these lines for new user:

VNCSERVERS="1:arbab 2:ali"
VNCSERVERARGS[1]="-geometry 1024x600"
VNCSERVERARGS[2]="-geometry 1024x600"

Restart the VNC service:

sudo service vncserver restart

Kill the vncserver session for new user and edit the xstartup file:

su ali
vncserver -kill :2
cd ~
nano .vnc/xstartup

Modify the file so it looks like this:

#twm & 
exec gnome-session &

Restart the VNC service:

sudo service vncserver restart

Connect with newly created user using centos:2, Where centos is my server name:

Enter the password that we created using the vncpasswd command:

We now have GUI access to our server for newly created user.

Hope this will help you!

Please Remember me in your prayers!

Enjoy 🙂

Time synchronization on CentOS 6.2 using NTP

To install the ntp, just enter this command at the terminal:

sudo yum install ntp

To make the ntpd start at boot time, use this commands:

sudo chkconfig ntpd on

After installation, edit the default ntp configuration:

sudo nano  /etc/ntp.conf

Commented out/remove the default CentOS servers,you can add your own time-servers here to synchronize with, http://www.pool.ntp.org/zone/europe or http://www.pool.ntp.org/zone/north-america lists:

After you are done with the configuration, just start the ntp service:

sudo service ntpd start

To check if the NTP service is synchronizing:

sudo ntpq -pn

To check the synchronization log:

sudo tail -f /var/log/messages

Geeky Comparison with Windows clock after synchronization:

Hope this will help you!

Please Remember me in your prayers!

Python 2.7 on CentOS 6.2 with Setuptools

First check the python version that is currently install on CentOS 6.2:


Before installing the python, please install these packages:

sudo yum install gccgcc-c++.x86_64 compat-gcc-34-c++.x86_64 openssl-devel.x86_64 
zlib*.x86_64 wget make setuptool

Now download the Python 2.7 (In my case, I will download it in tmp directory):

cd /tmp/
wget http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2

Switch to the super user (root):


Extract the downloaded Python 2.7 package:

tar -xvjf Python-2.7.tar.bz2

Move to the Python 2.7 directory and configure the package:

cd  Python-2.7

It’s time to actually build the binary from the source code:


Now it’s finally time to install the program:

make install

Edit the user .bash_profile file:

nano ~/.bash_profile

replace PATH=$PATH:$HOME/bin
with PATH=$PATH:$HOME/bin:/opt/python27/bin

Reload the .bash_profile:

source ~/.bash_profile
echo "/opt/python27/lib" > /etc/ld.so.conf.d/python27.conf

Check the Python version now 🙂


Now, we will install the setuptool and for this we need to fetch the setuptools from the website:

cd ..
wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg

Run the setuptools using this command:

sh setuptools-0.6c11-py2.7.egg

Next, we will install the gevent:

yum install libevent.x86_64 libevent-devel.x86_64


wget http://pypi.python.org/packages/source/g/gevent/gevent-0.13.0.tar.gz

tar -xvzf gevent-0.13.0.tar.gz

cd gevent-0.13.0

python2.7 setup.py install

Logout from root user and check the python version for user arbab:


Hope this will help you!

Please Remember me in your prayers!

How to install Java 6 on CentOS 6.2

First, we will check that java is already install or not on our system?

java -version

As, we can see that the java is not install on our system, so we will downloads the Java binary installer from Oracle. (In this example, we will download & install the jdk, but the procedure is exactly the same for jre).

Transfer the downloaded file (jdk-6u32***) to the CentOS from Windows machine using WinSCP.

Now, move to the directory where you copy the jdk file(in my case, it is in tmp directory) and give execute permission to jdk file:

cd /tmp/
sudo chmod +x jdk-6u32-linux-x64-rpm.bin

Run the jdk file:

sudo ./jdk-6u32-linux-x64-rpm.bin

Apply the alternatives:

sudo alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_32/bin/java 17000 

We are done 🙂

Check the installed version of java:

java -version


Hope this will help you!


Please Remember me in your prayers!

How to install Webmin on CentOS 6.2

Webmin is a web-based interface for system administration for Linux/Unix. You can setup user accounts, Apache, DNS,DHCP, file sharing and much more by using any modern web browser.

Before installing the Webmin,disabled the SELinux:

Make SELINUX=disabled:

Restart the Server!!

First, we need to install the dependencies with this command:

sudo yum install perl

Also, install the wget:

sudo yum install wget

Now, we need to download the Webmin rpm package from Sourceforge (I download it  in my home directory):

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.580-1.noarch.rpm

Then just run the following command:

sudo rpm -U webmin-1.580-1.noarch.rpm

Webmin is installed now and you will be able to access it via a browser using, http://server-ip:10000. In my case it is,http://CentOS:10000.

Configure the iptables rule in order to allow access to the Webmin:

sudo iptables -I INPUT 4 -m state --state NEW -m tcp -p tcp --dport 10000 -j ACCEPT
sudo service iptables save

Now access Webmin via a browser using, http://server-ip:10000(In my case it is,http://CentOS:10000):

After login, Webmin main page will show you the summary of your server:

Hope this will help you!

Please Remember me in your prayers!

How to install Samba server on CentOS 6

Part 1: Configuring anonymous share with samba server

To install the samba package,enter the following command:

sudo yum install samba samba-client samba-common

Check the version of installed samba software by using this command:

smbd --version

Configure the samba service, so that, it will start automatically at boot time:

sudo chkconfig smb on
sudo chkconfig nmb on

Disable the SELinux:

sudo nano /etc/selinux/config

Change SELinux from enforcing to disabled:


Add these Iptables rules, so that samba will work perfectly:

sudo iptables -I INPUT 4 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
sudo iptables -I INPUT 5 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
sudo service iptables save

Restart the Server!!!

Go to your Windows machine and use this command in order to check the WORKGROUP name:

net config workstation

It will show the output, something like this:

Backup the smb.conf file, then delete it and create the new one:

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo rm /etc/samba/smb.conf
sudo touch /etc/samba/smb.conf
sudo nano /etc/samba/smb.conf

Add these lines, in your smb.conf file (or change it according to your requirement):

#======================= Global Settings =====================================
 workgroup = WORKGROUP
 security = share
 map to guest = bad user
#============================ Share Definitions ==============================
 path = /samba/share
 browsable =yes
 writable = yes
 guest ok = yes
 read only = no

Save the smb.conf file and restart the service:

sudo service smb restart
sudo service nmb restart

Access the samba share from windows (where centos is the name of my samba server):

wao, we are able to access the samba share successfully :-)

Let’s try to create something, inside the share folder:

Error, we cannot create anything inside the share folder :-(

Check the current permission on the samba share:

cd /samba/
ls -l

Change it, in such a way that everyone can read and write it(Check it, that it is allowed in your environment or not):

sudo chmod -R 0777 share
ls -l

Try to create something again, inside the share folder:

Verify the newly created file on samba server:

cd share/
ls -l

Part 2: Add and manage users and groups

Add a group in your CentOS server (in my case smbgrp):

sudo groupadd smbgrp

Create a new share, set the permission on the share:

cd /samba/
sudo mkdir secure
sudo chown -R arbab:smbgrp secure/ 
ls -l 
sudo chmod -R 0770 secure/
ls -l

Add the user to the samba group and create samba password:

sudo usermod -a -G smbgrp arbab
sudo smbpasswd -a arbab

Edit the smb.conf file:

sudo nano /etc/samba/smb.conf

Add the newly created samba share in smb.conf file:

path = /samba/secure
 valid users = @smbgrp
 guest ok = no
 writable = yes
 browsable = yes

Restart the samba service:

sudo service smb restart
sudo service nmb restart

Check the syntax error with testparm:

sudo testparm

Testing from Windows Machine:

Verification from CentOS server:

cd /samba/secure/
ls -l 

Hope this will help you!

Please Remember me in your prayers!

Enjoy :-)

%d bloggers like this: