Skip to content

Posts from the ‘Linux’ Category


Increase semaphores count in Linux

Semaphores can be thought of as simple counters that indicate the status of a resource. This counter is a protected variable and cannot be accessed by the user directly. The shield to this variable is provided by none other than the kernel. The usage of this semaphore variable is simple. If counter is greater that 0, then the resource is available, and if the counter is 0 or less, then that resource is busy or being used by someone else. This simple mechanism helps in synchronizing multithreaded and multiprocess based applications. Semaphores were invented and proposed by Edsger Dijkstra, and still used in operating systems today for synchronization purposes. The same mechanism is now available for application developers too. Its one of the most important aspects of inter-process communication.

Increase the maximum amount of semaphores

Before increasing the Semaphore value, check whats the current value using by the system.

[l3admins@localhost ~]# /sbin/sysctl -a | grep sem
kernel.sem = 250        32000   32      128
[root@l3admins ~]#

How much IPC resources are used can be found using ‘ipcs’ command:

# ipcs -a
------ Semaphore Arrays --------
key        semid      owner      perms      nsems
0x00000000 201293824  Exim    600            1

To increase the semaphores execute the following command and after that update the same vale in /etc/sysctl.conf file to reflect the same after the reboot

/sbin/sysctl -w kernel.sem=250

See ‘man ipcrm for more information.


How to clear out the cache being used

Linux has a good memory management feature that will use up any “extra” RAM you have to cache stuff. This section of the memory being used is SUPPOSED to be freely available to be taken over by any other process that actually needs it. This will eventually reduce the performance of your system. Following command will help you.

[root@l3admins]# free -m
total       used       free     shared    buffers     cached
Mem:          3990       3181        809          0        448       2228
-/+ buffers/cache:        503       3486
Swap:         9452          0       9452

Use the following command as root to clear cache from your machine.

sync; echo 3 > /proc/sys/vm/drop_caches
This will only support Kernels 2.6.16 and newer.

The above command will cleared out the cache in your machine.


Convert deb package to rpm

DEB packages are the installers for Debian and Ubuntu like RPM for Linux.

Converting of  DEB to RPM is simple one step  process with  “alien” command in Ubuntu/Debain, for this one first we need to install alien.

Install alien command on Debian / Ubuntu

To install alien package you need root privilege.

# apt-get install alien

Once the alien package is installed we can start the converting of DEB to RPM.

# alien your-DEB-to-convert.deb

your-DEB-to-convert.rpm generated

Now you can start the installation of the RPM.


Convert rpm packages to deb

DEB packages are the installers for Debian and Ubuntu like RPM for Linux, if we need to install one RPM on Ubuntu/Debian we need to convert as DEB package.

Converting of RPM to DEB is simple one step process with “alien” command in Ubuntu/Debain, for this one first we need to install alien.

Install alien command on Debian / Ubuntu

To install alien package you need root privilege.
# apt-get install alien

Once the alien package is installed we can start the converting of RPM to DEB

# alien your-RPM-to-convert.rpm
 your-RPM-to-convert.deb generated

Now the .deb package is created, now you can install it in Ubuntu/Debain.


Bugzilla installation on Linux

Bugzilla is one of the best open source bug tracking system. Very simple to use with lot of features. Bugzilla allows you to track the bugs and collaborate with developers and send automated alerts and mails to the users.

Before going to the installation of Buzilla need to make sure that following components are installed in the server.

1. Perl Version

# perl -v

 Make sure your perl version is >= 5.8.1 as shown below.

2. MySQL Database

Make sure your MySQL version is >= 4.1.2 as shown below.

# mysql -V

mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (i686) using readline 5.1

3. Apache

Make sure that Apache installed and running in the server.

4. Download latest Bugzilla tar ball

Download the latest stable release from bugzilla download page. Extract the bugzilla*.tar.gz file to the apache document root directory as shown below.

# cd ~

# wget

# cd /var/www/html

# tar xvfz /usr/save/bugzilla-3.4.6.tar.gz

5. Use

Bugzilla program will verify whether all the required perl modules are installed. This will also display a list of all missing perl modules that bugzilla requires for the installation.

You can run the program as many times as you like until you’ve verified all the required perl modules are installed.

Login to the directory where you downloaded the Bugzilla and do a scan with

Here I am excluding the list of the out. It will make a sense that this is a risky and complex Job. You can run the as many times you required until all the required components are installed.

After completing the installation of perl modules start the localconfig file configuration

6.Create localconfig

This file will automatically generated by Bugzilla we only need to add the DB user name and the password.

Make sure that the Mysql is running in the server, then only localconfig file will take and write data to the Mysql DB.

7. Modify the localconfig file.

Open the localconfig and search for the following term “db_pass”

# vi ./localconfig
$db_pass = 'yourpassword';

You can increase the Bugzilla attachment size in Bugzilla by updating the upload limit in /etc/my.cnf, if required only.

After modifying the Mysql restart the Mysql service

service mysqld restart

8.Create Mysql user

Add bugzilla user (bugs) to the mysql database as shown below.

# mysql -u root -p

TO bugs@localhost IDENTIFIED BY 'Bugs4All';


9. Create the bugzilla database

Execute the (without any arguments) again to create the mysql bugzilla database. Since the localconfig file already exist, the second time when you execute the, it will create the mysql database based on the information from localconfig file.

# ./

Creating database bugs...

Building Schema object from database...
Adding new table bz_schema ...
Initializing the new Schema storage...
Adding new table attach_data ...
Adding new table attachments ...
Adding new table bug_group_map ...
Adding new table bug_see_also ...
Adding new table bug_severity ...
Adding new table bug_status ...

Inserting values into the 'priority' table:
Inserting values into the 'bug_status' table:
Inserting values into the 'rep_platform' table:

10.Configure apache for mod_perl

Remove the version number and rename it as Bugzilla

# cd /var/www/html

# mv bugzilla-3.4.6/ bugzilla

Add the following two lines to httpd.conf

# tail -2 /etc/httpd/conf/httpd.conf
PerlSwitches -I/var/www/html/bugzilla -I/var/www/html/bugzilla/lib -w -T
PerlConfigRequire /var/www/html/bugzilla/

Verify the Group in httpd.conf matches the webservergroup in localconfig

# cd /var/www/html/bugzilla/

# grep webservergroup localconfig
$webservergroup = 'apache';

# grep Group /etc/httpd/conf/httpd.conf
Group apache


executionthe again.

# ./
Reading ./localconfig...

Removing existing compiled templates...
Precompiling templates...done.
Fixing file permissions...

Now that you have installed Bugzilla, you should visit the 'Parameters'
page (linked in the footer of the Administrator account) to ensure it
is set up as you wish - this includes setting the 'urlbase' option to
the correct URL.

12.Login to Bugzilla and complete initial setup.

Start the apache, go to http://{your-ip-address}/bugzilla and login using the administrator account you created above.
From the bugzilla UI, at the footer -> Administration -> Parameters -> ‘Required Settings’ section -> Fill-out following information:

urlbase: http://{your-ip-address}/

Note: Depending on your setup, go to -> User Authentication -> and you might want to change requiredlogin and emailregexp parameter.


Check SELINUX status on Linux

The Linux command example below show the example on how to check SELinux status on Linux Fedora system. This step by step example on how to check SELinux status on Linux Fedora system is tested on Linux Fedora 10 system.

 1.  Check SELinux status on Linux Fedora system.

[root@l3admins ~]# cat /etc/sysconfig/selinux


# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#       enforcing - SELinux security policy is enforced.

#       permissive - SELinux prints warnings instead of enforcing.

#       disabled - No SELinux policy is loaded.


# SELINUXTYPE= can take one of these two values:

#       targeted - Targeted processes are protected,

#       mls - Multi Level Security protection.

[root@l3admins ~]

or execute the sestatus command to view SELinux status

[root@l3admins]# sestatus

SELinux status:                 enabled

SELinuxfs mount:                /selinux

Current mode:                   enforcing

Mode from config file:          enforcing

Policy version:                 23

Policy from config file:        targeted


You can also check the same in Linux machines using the command system-config-securitylevel


Integrate Gmail with Bugzilla

Gmail is using SMTP::TLS for authentication purpose so before starting the work we

need to install the SMTP::TLS ( Transport Layer Security ).

SMTP::TLS This is a perl module we can download the same from the cpan site.

Make sure that the SMTP::TLS module successfully installed after that we need to do the settings in the Bugzilla.

We can install the SMTP::TLS module using the CPAN shell itself.

Launch the CPAN shell as follows

        perl -MCPAN -e shell

        Execute following command  on CPAN Shell

	cpan> install Email::Send::SMTP::TLS

At the time of this installation CPAN might ask you to install some other dependency modules according to the prior modules installed, and install them.

If you are failing to install the Email::Send::SMTP::TLS through CPAN shell then install the same from the source code.

Download the same from CPAN site and execute the commands.

tar zxvf Email-Send-SMTP-TLS-0.03.tar.gz

cd Email-Send-SMTP-TLS-0.0	



make install

After completing the installation of Email-Send-SMTP-TLS modules this should reflect in the Bugzilla. This can be verified by login in to Buzilla Administration -> Parameters -> Email.

Now select the SMTP-TLS from the Drop down menu.

New section is the tweaking of Bugzilla codes, to work the SMTP-TLS with Bugzilla.

Go to the Bugzilla installation directory and do the following commands.

Cd Bugzilla

Open with your favorite editor and search for the following line

I think this should be in Line #57

sub MessageToMTA {

Add the line after that

my ($smtp_server,$smtp_port);

Now search for the “if” block

if ($method eq "SMTP") {

And change the following code ad below (need to add this code)

if ($method eq "SMTP" || $method eq "SMTP::TLS") {
    ($smtp_server,$smtp_port) = split /:/,Bugzilla->params->{"smtpserver"};
    push @args,
    Host  => $smtp_server,
    User => Bugzilla->params->{"smtp_username"},
    Password => Bugzilla->params->{"smtp_password"},
    Hello => $hostname,
		Debug => Bugzilla->params->{'smtp_debug'};
		push @args, Port => $smtp_port if($smtp_port);

Now we need to do some more settings in the Bugzilla.

1)	Select the SMTP:TLS as Mail delivery method.

2. Enter your gmail address in mail-from

3. Enter in smtpserver

4. Enter in smtp_username

5. Enter gmail password in smtp_password

6. Click on save changes

After completing this session check the ownership of the Apache and the permissions.


MACID duplication in Centos

If you are getting the errors like duplicate Mac ID found, then you can use the following python script to change the Mac ID for your machine. Save the script with .py extension.

# script to generate a MAC address for Red Hat Virtualization guests
import random
def randomMAC():
	mac = [ 0x00, 0x16, 0x3e,
		random.randint(0x00, 0x7f),
		random.randint(0x00, 0xff),
		random.randint(0x00, 0xff) ]
	return ':'.join(map(lambda x: "%02x" % x, mac))
print randomMAC()

After completing the same check your Mac ID.


Disk Space monitoring

Some times we need to monitor the hard disk-space usage like how much percentage its usage and send automated mail to admins and things are included in my script.

# Shell script to monitor or watch the disk space
# set alert level above 90% is default
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
  #echo $output
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 }' )
  if [ $usep -ge $ALERT ]; then
    echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
     mail -s "Alert: Almost out of disk space $usep" $ADMIN

Update the email ID according to you.


backup and scp script

cd /root/
tar -cvf /root/svn_backup/svn_`date +%d-%m-%Y-%H-%M`.tar svn
gzip /root/svn_backup/svn_`date +%d-%m-%Y-%H-%M`.tar

scp /root/svn_backup/svn_`date +%d-%m-%Y-%H-%M`.tar.gz root@
set root_pass "poi123"
sleep 10
expect "password: "
send "$root_pass\r"
expect "# "