New to Linux? - Read this

I have seen a huge number of computer users shifting from Windows to Linux but they have no idea of how to start with Linux. Unless and until Window users put their hands on Linux, they consider Windows easy and reliable to work with.They find the command line boring and difficult to cope up.But once they start working on Linux, they never look back to Windows.

This article is for all new Linux users who are keen to know how to start with Linux.

For new users it is always difficult to know which distribution to start with.Today there are thousands of Linux distribution and everyone claim their own favourites.Red Hat is the popular Linux distribution in the market today.With Enterprise versions, Red Hat has gone commercial, ie you need to pay for Red Hat Enterprise Linux(RHEL) distributions in case you really want to try. While Fedora and CentOS being free to download and work which are almost similar to RHEL. In the other hand, Ubuntu has come forth as a second most popular distribution in the market. Its easy to install and lightweight.

I always recommend a new users to start with Fedora / CentOS as these are simple to use Operating System. The Commands which you can run on Fedora/ CentOS works in RHEL too.

OpenSUSE, Mandriva, FreeBSD and Debian are the other popular distributions which comes next in the popularity.

Once you decide on the distributions, I always recommend you to go through basic Linux commands. The Best way to start learning Linux is first setting up Virtualbox on top of your Linux/ Windows Machine. I have discussed about setting up Virtualbox on Fedora 14 in this link.Virtualbox is a powerful x86 and x86_64 virtualization product both for corporates enterprise and home users.You can run multiple operating systems on top of your underlying base OS.

Next step is to collect the commands is through man pages on Linux box. Just type #man < commandname> and you are ready to go with.

There are couple of website which talks about the Linux Commands for the newbie.
Few of them listed below:


We will discuss further with the Linux Installation and basic commands in the next article.
Till then, have a nice time and Happy New Year 2011.

Installing Apache with SSL Support

1. Download Apache from the URL http://www.apache.org/ as per project requirement

2. Extract the Downloaded tar to some temporary folder.

3. Change directory to extracted directory
4. Run the command:

[root@web /]#./configure --prefix=/opt/ --enable-so --enable-proxy --enable-ssl --enable-setenvif --enable-modules=all

[root@web /]# make

[root@web /]# make install

5. Add the lines in /opt/apache2/conf/httpd.conf file to configure virtual hosts.

6. Here two virtual hosts are configured, one is on port 80 and another on port 81.

ServerName webbuild
ProxyPass / http://webbuild:8080/
ProxyPreserveHost on

ServerName webbuild
ProxyPass / http://webbuild:8080/
ProxyPreserveHost on

7. Start the apache web server

[root@web /]# /opt/apache2/bin/apachectl start

8. To stop the apache web server use the command below.

[root@web /]# /opt/apache2/bin/apachectl stop

3 Configuration Changes for SSL to work

1. Edit ‘httpd.conf’ file to include the ‘httpd-ssl.conf’ file.

Include conf/extra/httpd-ssl.conf

2. In ‘httpd-ssl.conf’ file uncomment and edit the path for the ‘SSL Certificate’ file and ‘SSL Certificate Key’ file.

SSLCertificateFile "/opt/apachewithssl/conf/ssl.crt/ssl.crt"

SSLCertificateKeyFile "/opt/apachewithssl/conf/ssl.key/ssl.key"

3. Check the SSL Implementation by pointing the web browser to https://

Changing default logs and deploy path location in JBOSS Application Server

This article discusses the method to change the default logs and deploy path in JBOSS Application Server.
1.       In JBOSS default logs path will be ‘$JBOSS_HOME/server//log’
2.       Create the directory path where logs need to stored
          $ mkdir –p /logs/tep/test/jboss
3.       Go to ‘$JBOSS_HOME/server//conf’ folder
4.       Update the ‘jboss-log4j.xml’ file with below entries.
         < param name="File" value="/logs/tep/test/jboss/server.log" />
         < param name="File" value="/logs/tep/test/jboss/audit.log" />
5.       Restart the JBOSS Instance.
Changing default deploy path
1.       Default deploy path will be ‘$JBOSS_HOME/server//conf’
2.       Create the directory path where war/ear files will be deployed.
          $ mkdir –p /production/tep/
3.       Go to ‘$JBOSS_HOME/server//conf’ folder
4.       Edit ‘jboss-service.xml’ file
5.       Search for URLs in ‘jboss-service.xml’ and update the file as below
                        deploy/, /production/tep/

6.       Restart the JBOSS Instance.

Apache mod_jk configuration for Jboss application server

This article describes the steps to configure apache mod_jk module with JBoss application server.
Apache mod_jk is a "bridge" between the Apache web server and the Jboss application Server. "Normal" web requests over port 80 are handled by Apache and then java servlet and JSP are forwarded to the Application server(Example Jboss).

 Apache Configuration:

 1. Download Apache Tomcat connectors (mod_jk) binaries from below URL


 2. Copy 'mod_jk-<Version>.so' to '$APACHE_HOME/modules'

 3. Create a new folders 'run' and 'mod_jk' in  $APACHE_HOME location.

 4. Edit the '$APACHE_HOME/conf/httpd.conf' file with following entries to load 'mod_jk' and 'server name'.
                        Include mod_jk/mod_jk.conf
                        ServerName <Server name>:<Port number>

 5. Extract the attached mod_jk_conf.zip in '$APACHE_HOME/conf' location.
 6. Move mod_jk.conf from '$APACHE_HOME/conf' to '$APACHE_HOME/mod_jk'

 7. Edit workers.properties present in '$APACHE_HOME/conf' with the JBoss servername and corrosponding AJP port number.

 JBoss Configuration:

 In this section we configure the JBoss instances on all clustered nodes so that they can expect requests forwarded from the mod_jk load balancer

1. Edit the server.xml file present in  <JBOSS_HOME>/server/<site-Name>/deploy/jboss-web.deployer/ with the following entries

   <Connector port="8080" address="${jboss.bind.address}"
         maxThreads="250" maxHttpHeaderSize="8192"
         emptySessionPath="true" protocol="HTTP/1.1"
         enableLookups="false" redirectPort="8443" acceptCount="100"
         connectionTimeout="10000" disableUploadTimeout="true" URIEncoding="UTF-8"    />
<!-- These entries will be already present in the server.xml file, Just enter the worker name in jvmRoute value -->
      <Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1">

 2. Edit the jboss-service.xml under <JBOSS_HOME>/server/<site-name>/deploy/jboss-web.deployer/META-INF  with the following entry to enable JK module

       <attribute name="UseJK">true</attribute>

3. Restart the apache web server and JBoss application server.       


Missing xorg.conf file on Fedora 14?

Fedora 14 doesn't create /etc/X11/xorg.conf by default.For making manual changes to X configuration for any reason,one need to create a /etc/X11/xorg.conf file. You can follow these steps to change settings for Xorg.

Xorg -configure

Create a basic xorg.conf through these command:

#Xorg -configure

The above command will create the file /root/xorg.conf.new. You need to copy this file to xorg.conf through this step:

#cp /root/xorg.conf.new /etc/X11/xorg.conf

[Note that this will only work if no X server is currently running]
If in case the above stuff din't work, try tweaking through:

#system-config-display --noui

The above command creates a clean /etc/X11/xorg.conf file using the automatically detected driver for your video card.

To specify a particular driver for your card you can simply create a standard /etc/X11/xorg.conf file and then edit it by hand, but you can also do this directly with system-config-display.

For example, to specify the nv driver, you could do:

system-config-display --noui --set-driver=nv
When using the --set parameters, --noui is implied, so you do not really need to include it. For more information on ways you can use system-config-display, run system-config-display --help.

Hope it helps !!!

Which processes accessing which files?

Fuser is very powerful utility which identify process using files or sockets.It
lists the process numbers of local processes that use the local or remote files specified by the File parameter. For block special devices, the command
lists the processes that use any file on that device.

Sometimes you may want to know which process is accessing a particular file or filesystem — for example, if you get a "device is busy" error message. fuser will provide this information:

PID accessing the file

[root@localhost ~]# fuser /var/log/messages
/var/log/messages: 2255

Want to see which user is using it:

More Detail Info:

F indicates that the file is open file.
syslogd indicates command being used to access the file.

Which all processes accessing the file system?

The -m switch shows all process accessing the filesystem, which the file is on; or you can simply specify a filesystem rather than a file. So fuser -m /dev/sdb1 output looks like:

/dev/sdb1: 18647c 16875m 7122c 19579m 1606c 7258c 5760c 13644

To kill all processes accessing a particular file

Use fuser -k filename.txt

(add -i for a confirmation message before each kill).

You can also use fuser on network ports: fuser -n tcp 21. This will show which process is using port 21 (useful if you get a 'port busy' message).

Linux fuser command to forcefully unmount a disk partition:

Suppose you have /dev/sda1 mounted on /mnt directory then you can use fuser command as follows:

Type the command to unmount /mnt forcefully:
# fuser -km /mnt

How to mount floppy under Ubuntu 10.04?

Mounting floppy drive for newbies sometimes seems to be difficult task. Especially one who are not well aware of system administration. Normally a new Linux users are recommended to use Ubuntu as a startup OS as its easy and lightweight to use. One of my colleague who just shifted from Microsoft to Linux asked me and this is how I put this article for someone who finds difficult accessing the floppy.

To access the MS-DOS formatted floppy, create a directory and run the specific command to mount your floppy.

#mkdir /mnt/floppy

#mount -t msdos /dev/fd0 /mnt/floppy

In the above command, -t specify the filesystem type of the floppy. If you have formatted the floppy on Windows system, then you won't find difficult running this command.

/mnt/floppy is  a directory where you want to mount the device to access the contents.

How to un-mount the floppy?

#umount /dev/fd0

To forcefully unmount the floppy(though not recommended)

#umount -f /dev/fd0

To find out where your floppy mounted, you can run the following command:

#dmesg| grep fd


How to see open ports on Linux?

The Communication in between the two computers takes place via ports. Ports are application specific communication channel which has been divided into the ranges:-

1. Well-known Ports(from 0 to 1023)
2. Registered Ports (1024 to 49151)
3. Dynamic/Private Ports(49152 to 65535)

How to see the Open Ports on Linux?

# netstat -anp --tcp --udp | grep LISTEN

How to block incoming ports under Linux?

#iptables -A INPUT -p tcp --destination-port {PORT-NUMBER-HERE} -j DROP


Blocking HTTP Port 80

#iptables -A INPUT -p tcp --destination-port 80 -j DROP

#service iptables save

Block Incomming Port 80 except for IP Address

#iptables -A INPUT -p tcp -i eth1 -s ! --dport 80 -j DROP

Block Outgoing Port

#iptables -A OUTPUT -p tcp --dport {PORT-NUMBER-HERE} -j DROP

Blocking Port 25

#iptables -A OUTPUT -p tcp --dport 25 -j DROP

#service iptables save



rpm2cpio - How to List files under RPM?

rpm2cpio, as its name suggest, takes an RPM package file and convert it into cpio archive. The cpio is a binary file archiver and is a stream of files and directories in a single archive.

rpm2cpio takes only only one argument. The interesting part is its optional.
It is  the name of the package file to be converted. Under no filename specified o n the command line,  rpm2cpio will simply read from standard input and convert that to a cpio archive.

Let's download the subversion RPM (as an example) and see how rpm2cpio can be used to display the files.

How to install .tar.bz2 file under Linux?

TAR refers to TApe aRchive.It is used to create tape archives and add or extract files.A ".tar" file doesn't refer to a compressed files, it is actually a collection of files within a single file uncompressed.

A .tar file may be available suffixed with .tar.bz2 or .tar.bz or .tar.gz. To extract the following compressed files we follow different utility.

bzip2 or bunzip2 is a block-sorting file compressor, v1.0.2.If the files are available as bunzip2, then we need to uncompress it through bunzip2 as shown below:

# ls
website.tar.bz2 alpha.tar.bz
#bunzip2 website.tar.bz2
website.tar.bz2 alpha.tar.bz website.tar

#bunzio alpha.tar.bz
website.tar.bz2 alpha.tar.bz website.tar alpha.tar

Once uncompressed with bunzip2, we need to untar the file.

 website.tar.bz2 alpha.tar.bz website.tar

#tar xvf website.tar

Once the above command is run, it will untar the files under the folder website.

Now its time to follow the normal steps ahead:

#cd website
#make install

In case it shows any errror related to gcc or make it means gcc packages are not installed in your machine.

Fedora 14 Hangs with Linux Kernel

When I upgraded my Fedora 13 to Fedora 14 last night I found the system freezes at many points. For example, I am unable to open terminal while I am browsing through the firefox. I am unable to open Virtualbox with firefox open. My System hangs when I am  trying to play "Parole Media Player".

I raised a bug with bugzilla.redhat.com and they suggested to update the kernel to update the kernel to kernel that fixes that issue.

Things are pretty working now and it seems like seems to carry bug.

Browse through Fedora Build System at http://koji.fedoraproject.org/koji/packageinfo?packageID=8 and download the latest kernel. Refer http://linuxscoop.blogspot.com/2010/12/how-to-compile-linux-kernel.html to compile the kernel.

Be aware of this bug and enjoy Fedora  Box.

How to extend LVM partition online?

Logical Volume Management ( LVM) is a disk management utility which comes by default with Linux system nowadays. It is always recommended to use LVM as it is useful whenever disk space is needed to be extended without any interruption.

Though it extends the space but one must be careful while extending the partition of the production servers where numbers of sophisticated applications are running.A Utility ext2online helps in extending the LVM space without any disruption.Let us look at this utility in little details.

Say, we created our logical volumes alpha (40GB), beta (5GB), and gamma (1GB) in the volume group emission.


Say, if you want to extend the size of gamma from 1GB to 2GB, we need to follow the following steps:

ajeet:~#lvextend -L+1024M /dev/emission/gamma

Extending logical volume media to 2 GB
  Logical volume media successfully resized

ajeet:~#ext2online -d /dev/emission/gamma

The ext2online is useful as it extends the LVM partition without disturbing the overall process ongoing on the linux machine related to the particular partition.

How to install Nginx through source?

In our last session, we installed Nginx through yum utility which was very easy method. But generally it is recommended to install Nginx through source as it can becomes easy to tweak as per the project requirement. Installing Nginx through source tends to provide the user to dig deep into the server and customize it as per its hardware compatibility and resource management.

Let's compile the source from scratch and how really it goes.

Create a directory called "server" under /root. Download the nginx tar from http://sysoev.ru/nginx and untar it as shown:

Lets start compiling the source now.

If you encountered this error, then follow these steps:

#yum install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev

Start to compile it once again

$sudo make clean
$sudo ./configure --with-http_ssl_module
$sudo make
$sudo make install

Here it goes your Nginx server is ready.


How to setup Nginx on Linux?

Nginx is a free, open source web server. It is pronounced as "engine-X". Nginx server is popular due to its less resource consumption and its scalability.
Fedora 14 repository comes with nginx source code availability. Lets install nginx through yum utility.

First lets start with installing Nginx through yum as discussed below:

Press "yes" to confirm the installables:

Once yum reports successful installation, we need to restart the nginx service as shown:

#/etc/init.d/nginx restart

Thats it. Now you can confirm if nginx server is successfully installed or not through web browser.

A First Look at Git - A Version Control System

Git is a fast de-centralized version control system. Unlike Subversion, CVS, Perforce which are centralized version control syste, GIT stands uinique in fast speed, distributed approach and non-linear development.Git was written by Linus Torvalds 5 years back. Most of the large projects like Linux Kernel, Xorg, Perl, Android, Qt, Ruby, Debian, Eclipse,GNOME,Wine etc runs on Git.

Lets have a look at how Git works !!!

Git can run on Windows, Linux and Mac too. The Latest stable version is us start with installation of git on Linux (Fedora 14) as follow:

One can easily install Git through yum utility provided you have internet connectivity. For manual installation, we need to install dependent modules which is out of scope for this article.

Once git is readily installed, we go ahead creating a new project. Here we have a new website project by name "Website" which contains few files and folders in it. Lets see how to go ahead.

First we need to create global username for the git repository plus email registration. These are optional field but since we would require during git-hub(will explain later), lets create the one as shown

Next, we create a git repository as shown below:

#cd Website
#git init

Once repository gets initialized, then add the files to the repository as show

#git add .
#git commit -m "Initial Commit"

The above git add . will add up all the files/folders into Website repository.

Lets check the logs for whatever commit changes we have made to the repository:

 The above screenshot shows that Ajeet  is a user which has added the files and did the last commit.

Hence, we have created  a git repository with name "Website".

In next session, we will discuss further with git-hub and other advantages of git.


How to start/stop JBOSS at boot time?

There is always some point of confusion between /etc/rc.d/init.d and /etc/rc.x.
Basically, the first one contains the start and stop scripts while the second one contains just links to the start and stop scripts. The rc.x is prefixed by S(start) or K(kill).

Keeping this on mind yesterday I wrote a small script for JBOSS developers working in my firm. They had a requirement of starting Jboss automatically when a machine boots up, I passed them this code and they were happy getting their application running on their CentOS box.


How to setup cron on Linux?

Whenever you perform CentOS minimal installation, it might not have cron related packages installed on your box. I followed the following steps and had a quick cron running. Hope the screenshot might be useful for someone stuck with cron.

Missing xorg.conf on Red Hat Enterprise Linux 6

Last night I was playing around with RHEL 6. I was trying to change the screen resolution through the command-line.Suddenly I was surprised to see no xorg.conf under /etc/X11 directory. There was no file under the directory and that made me little annoying.

I tried running the normal X Windows configuration command:

#Xorg --configure

But it says there is already X session running on :0

Next, I tried installing X Window packages through:

But that din't bring up xorg.conf.

Finally, I had a RHEL 5 machine from where I took xorg.conf and placed it manually under /etc/X11 and it worked !!!

Snippet of my xorg.conf included:

After putting this file under /etc/X11, I was able to run the following command to change my screen resolution and depth.

This is how I got my xrandr utility work and xorg.conf in place.


How to install Apache through source?

All Linux distributions comes with Apache. However, it is recommended to download latest Apache source code, compile and install on Linux. This will make it easier to upgrade Apache on a ongoing basis immediately after a new patch or release is available for download from Apache. This article explains how to install Apache2 from source on Linux.

1. Download Apache

Download the latest version from Apache HTTP Server Project . Current stable release of Apache is 2.2.9. Move the source to /usr/local/src and extract it as shown below.

# cd /usr/local/src
# gzip -d httpd-2.2.9.tar.gz
# tar xvf httpd-2.2.9.tar

2. Install Apache

View all configuration options available for Apache using ./configure –help (two hyphen in front of help). The most commonly used option is –prefix={install-dir-name} to install Apache on a user defined directory.

# cd httpd-2.2.9
# ./configure --help

In the following example, Apache will be compiled and installed to the default location /usr/local/apache2 with the DSO capability. Using the –enable-so option, you can load modules to Apache at runtime via the Dynamic Shared Object (DSO) mechanism, rather than requiring a recompilation.

# ./configure --enable-so
# make
# make install

Note: During the ./configure, you may get the following error message.

# ./configure --enable-so
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
configure failed for srclib/apr

Install the gcc and the dependent modules as shown below and try ./configure again to fix the above issue.

3. Start Apache and verify installation

# cd /usr/local/apache2/bin
# ./apachectl start

Go to http://local-host, which should display the default message “It Works!”
4. Start Apache automatically during system startup

Modify the /etc/rc.d/init.d/httpd script and change apachectl and httpd variable to point to the appropriate new location as shown below. Please note that this httpd script was originally installed as part of the default Apache from the Linux distribution.


Now, you can perform the following to stop and start the Apache

# service httpd stop
# service httpd start

Setup the Apache to automatically startup during reboot as shown below.

# chkconfig --list httpd
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# chkconfig --level 2345 httpd on
# chkconfig --list httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Hope it helps !!!

389-DS Installation through Kickstart on Linux

389-DS ( earlier known to be Fedora DS) is a directory server owned by Red Hat Inc.  After purchasing from Netscape, Redhat promised to make it open source and hence today its popular and hold all those features which Microsoft Active Directory Server holds on its way.

This is a minimal Installation with just first CD of CentOS 5.4 and it went fine. Minimally it will install Linux OS with just < 700 MB.Though I tried it shrinking to 400 MB but I had a new venture to make 389-DS Ready.
Here is what I finished up with:

Setting up Fedora DS with just kickstart file:

Dont forget to include 389-ds.inf file (just copy paste for newer 389-DS Version).I am sure..it gonna work.

Here you go.
Now you have a complete CentOS 5.4 with Fedora DS Installed.

How to install VLC Player on Fedora?

By defaut, Fedora 14 comes with Parole Media Player. I din't like the player as it threw errors whenever I tried to run few rm and mp4 format files. I have been fan of vlc player since last 3 years and eager to install for my Laughlin box. I want to share the instalation process which may be useful for anyone who is music freak.Here goes the steps:

1. Install the RPM Fusion Repository. Confirm if it has been already installed in your Fedora machine.

2. Install vlc player through the yum utility

3. Once it finish up, browse to Start > Multimedia > VLC Player.

Your  VLC Player is now good to go.


How to run dd-command on Linux?- Part-I

dd stands for "Data Descriptor".It is a low-level copying and conversion of raw data. It is an application that will "convert and copy a file".  DD is used to copy a specified number of bytes or blocks, performing byte-order conversions.

Lets start with the basic understanding of dd-command with examples.


In the above syntax, source is the data being read, target is where the data gets written. if stands for input file and of for output file.
bs stands for blocksize.It is important to know the concept of blocksize.

Typically, a hard disk cannot read less than 512 bytes, if you want to read less, read 512 bytes and discard the rest. This is why dd reads one block à 512 bytes in the following example:

Every filesystem needs to split up a patition into blocks to store files and file parts. This is why there is a different block size for a file system as you can see here:

So, if you store a file in this file system, it will be stored in a 4096-byte-block, that means, even if your file only contains 5 bytes, it will take away 4096 bytes from your disk's capacity: 

Lets start with few basic examples before we dive deep into the ocean of dd-command.


Say we have a harddisk /dev/sda that we want to backup entirely (sector-by-sector) to a USB volume /dev/sdc1, mounted on /mnt/sdc1. We call this a dump or an image of /dev/sda. The dump shall be named backup.img. Here is the dd command:



To restore this backup, we boot from a live CD and do the command vice versa.



To clone a disk C to D, both disks need to have the same capacity. It is very convenient for USB disks. Say our USB disk source is called /dev/sdc and the target is called /dev/sdd.


To transfer a disk image over the network to a computer named recipient, use this command



To create an iso image of a CD, read it block-by-block and save the blocks to a file:

dd if=/dev/cdrom of=cdimage.iso


If your movie is no longer working due to corrupted file, you can use dd to ignore the corrupt part:


There are further several examples of dd-command which we will cover in the next part. Till then, play safe with dd.


How to compile linux kernel?

A Kernel is an interface which lets device drivers talk to the underlying hardware. Why we need to compile kernel? - is an important discussion to understand. Whenever a new hardware arrives in the market,the available kernel module might not support and you need to re-compile the kernel to make device driver communicate with the hardware.

Compiling the new kernel requires few pre-software modules to exist before you start with. Make sure you have gcc compilers development tools and libraries available in your Linux machine.  I am assuming Fedora 14 installed on your virtualbox. Follow up with the steps further to get a new kernel 2.6.37-rc4 installed with the existing kernel.

1. Download the linux kernel 2.6.37-rc6 from http://kernel.org as shown:

2. Make sure you have pre-requisite packages like gcc and make installed on your Fedora machine.

3. Untar the downloaded linux kernel-2.6.37-rc6 to /usr/src directory as shown in the figure.

4. Once you start the above command it will take around 1-1.5 minutes to untar the package.

5.Change the directory to /usr/src and run the make menuconfig to open the manual driver inlcusion window.

6.Once the menuconfig window opens up, you have option to select particular modules which you want to compile. Few modules related to vmware are shown below:

7.Once you are done with selecting the particular module, type ESC key repeatedly unless it ask for saving a .config file.
Press "YES" and a file .config gets created.
8.Run this command to start compilation of the new kernel


9.Next, run the command in the sequence:

#make modules
#make modules_install
#make install

10. Once you run make install it will add a new kernel to GRUB.

11.Edit /boot/grub/grub.conf and replace default=1 to default=0 to allow the new kernel to boot automatically whenever the reboot command is run.

12. Reboot the machine

13. Run the uname command to see if it has actually booted with new kernel.

14. Congrats !!!! You have just compiled a new linux kernel.