Tag Archives: centos

IP Setting on CentOS6 using Shell Script

In this tutorial, I’ll show you that how we can do initial settings on CentOS6.x using shell script:

First create the script :

vi setting.sh

Screen Shot 2014-09-16 at 1.40.23 pm

Read more of this post

Initial Settings after installing the CentOS 7

1) To change the hostname permanently, edit the following file:

sudo vi /etc/hostname

centos7

Here you can simply put the name of your system (in my case, I have assigned it CentOS-7):

centos7 (1)

Read more of this post

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

1

Read more of this post

Installing RPMforge Repository on CentOS 6

 If you’re looking for a package on CentOS and can’t find in the main repos then there’s a good chance that you can find it, in the RPMforge repository.

RPMforge is a collaboration of packagers and is not part of Red Hat or CentOS but is designed to work with those distributions.

Download the rpmforge-release package:

I am using x86_64 server, so I will download the x86_64 package:

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

Install DAG’s GPG key:

sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

Verify the package you have downloaded:

sudo rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm

Install the package:

sudo rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm

Try to install some package, that failed before installing rpmforge repository:

Hope this will help you!

Please Remember me in your prayers!

Enjoy 🙂

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:

vncpasswd

Edit the /etc/sysconfig/vncservers file:

sudo nano /etc/sysconfig/vncservers

Add the following to the end of the file:

VNCSERVERS="1:arbab"
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
vncpasswd

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 🙂

How to find the Linux Distribution Name and Version

In this post, I will try to show you that how we can check the version of Linux (Debian, Fedora, Ubuntu, CentOS), a particular system is running. Sometime we login to the system but we don’t know that which Linux distribution is running on it, So in this post, we will try to find it by using the lsb_release command that displays certain Linux Standard Base(LSB) and distribution-specific information.

To show the release number of installed distribution:
lsb_release -r

To show the distributor ID:
lsb_release -i

 To show all of the above information:
lsb_release -a

To find Out the Kernel Version by using this command:
uname -mrs

Where:

Linux – Kernel name
3.2.0-24-generic – Kernel version
x86_64 – Kernel is 64-bit

Hope this will help you!

Please Remember me in your prayers!

OSPF routing between Cisco,Ubuntu,CentOS and Mikrotik Router!

Scenario:

  • Routers: 1 Ubuntu Linux with 3 nics, 1 Centos Linux with 3 nics, 1 Cisco 3640 Router with 3 FastEthernet interfaces and 1 Mikrotik Router with 2 interfaces.
  • Clients: 3 Windows Xp with 1 nic.
IP Details

All the Routers in this scenario have a default password of “zebra“.

Cisco Router:

  • fe0/0: 10.10.10.1/24
  • fe1/0:10.10.50.1 /24
  • fe2/0: Getting through DHCP

UbuntuRouter:

  • eth0: 10.10.10.2/24
  • eth1: 172.16.10.1/24
  • eth2: 10.10.100.1/24

CentOSRouter:

  • eth0: 172.16.10.2/24
  • eth1: 192.168.10.1/24
  • eth2: 10.10.150.1/24

Mikrotik Router:

  • ether1: 192.168.10.2/24
  • ether2: 10.10.200.1/24

Clients:

  • Ubuntu-Desktop: 10.10.50.50/24
  • WinXP-1: 10.10.100.50/24
  • WinXP-2: 10.10.150.50/24
  • WinXP-3: 10.10.200.50/24

Cisco Router Configuration:

UbuntuRouter Configuration:

Restart the Router!!!

CentOSRouter Configuration:

Restart the Router!!!

Mikrotik Router Configuration:

Neighbor verification from Routers:

Route verification from Routers:

Test from Clients:

Make a simple test from Ubuntu-Desktop.

Make a simple test from WinXP-1.

Make a simple test from WinXP-2.

Make a simple test from WinXP-3.

Configure NAT on Cisco Router:

This is just a bonus section, in which we will configure the NAT on Cisco router and also propagate the default route in OSPF. I connect my Cisco Router to DSL Modem and configure it so that it will take IP address through DHCP, as well as configure the inside and outside interface for NAT.

Lazy man access -list for NAT (This is not the perfect access list):

NAT Overload:

Originate the default route in OSPF:

Verify the last resort information on Cisco Router:

Check default route information on all routers 🙂

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:

python

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):

su 

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
./configure

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

make

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
ldconfig

Check the Python version now 🙂

python

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

easy_install-2.7greenlet


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:

exit
python

Hope this will help you!

Please Remember me in your prayers!

%d bloggers like this: