Monday, November 1, 2010

mkdir -p

To create the hierarchy of directory we can use the mkdir command with the -p option. For eg. check the below mentioned directory structure we have three different level of directories.

os
|-- linux
| |-- debian
| |-- fedora
| `-- ubuntu
`-- unix
|-- aix
|-- bsd
`-- mac

The command to create the above mentioned directory structure as follows.

$ mkdir -p os/{linux/{debian,fedora,ubuntu},unix/{aix,bsd,mac}}

Changing the user login shell

To change the user login shell permentently, we can use chsh command.

Example:

[ravi@localhost ~]$ chsh
Changing shell for ravi.
New shell [/bin/bash]: /bin/ksh
Shell changed.

Password less login.

Just like to windows, the linux users want to login to the box with out entering the password every time they login. This could be accomplished by removing the password for the user. Do login to the box as the root and remove the password for the user.

$ passwd -d

Example:
$ password -d ravi #this would remove the password for the user ravi.

X Server Configuring

It was a week before I thought of tweaking the X's configuration in the netbook with the Fedora installation, I was trying out the xrandr command ended up corrupting my X settings.

The netbook started loading with default vesa driver, Its fails to detected the projector and I was getting more and more troubles as the day passes. I want to put it straight, by setting it back to the original configuration. It took almost a week to figure it out what was the fix. The solution was damn simple probe for the devices and write an new xorg.conf file and replace the old one with the default [vesa] driver, it was that's simple.

Following steps helped me in deriving the solution.

Step 1: Boot the box in the Runlevel 3

Step 2: probe for devices and write an new xorg.conf
$ X -configure

here:
-configure probe for devices and write an xorg.conf
The above command would generate a new xorg.conf file in the name xorg.conf.new

Step 3: Replace the existing xorg.conf with the generated one, kindly don't forget to rename the xorg.conf.new to xorg.conf while you copy to /etc filesystem.

Step 4: Restart the box or change the runlevel to 5 and the check the X system again it would load with the best resolution available for your configuration.

Thanks.

Thursday, May 27, 2010

MySQL Monitoring Scirpt

#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(strftime);

#unix command to check the mysql service
my $status = `lsof -i | grep mysql | tr -s ' ' | cut -f 1 -d ' '`;

my $mailprog ='/usr/sbin/sendmail';
my $adminmail = 'user@domain.com';
my $frommail = 'user@domain.com';

my $timestamp = localtime;
my $subject = "WARNING! UNABLE TO CONNECT TO MySQL SERVER AT $timestamp";
my $logfile = 'file';
my $current_time = strftime("%Y-%m-%d %H:%M:%S", localtime());

open (LOGFILE, ">>$logfile");


chomp $status;
if($status eq "mysqld"){
print $status;
print LOGFILE "$current_time, Connection successful\n";
}else{
print "error";
print LOGFILE "$current_time\tConnection failed.";

# code to send the mail
open( MAIL, "|$mailprog -t" );
print MAIL "Subject: WARNING MySQL Server is not responding\n";
print MAIL "From: $frommail\n";
print MAIL "To: $adminmail\n";
print MAIL "Reply-to: $frommail\n\n";
print MAIL "$subject";
print MAIL "\n\n";
close MAIL;
}
close LOGFILE;

Friday, February 19, 2010

Andriod my first hand xprience...


hi,

I don't have much to write about at this moment other than a screenshot shows Andriod emulator accessing gmail in it :)

Monday, January 11, 2010

Bootchart - Boot Process Performance Visualization

Bootchart is a tool for performance analysis and visualization of the GNU/Linux boot process. Resource Utilization and process information are collected during the boot process and are later rendered in a PNG, SVG or EPS encoded chart.

i, Installation in the Fedora core could be done using yum package manager.

# yum install bootchart

ii, GRUB entry

The boot logger bootchartd will be in the path /sbin need to be started by the kernel instead of init script. This can be achieved by modifying the GURB or LILO kernel command line.

Note: Login as a root, open the /boot/grub/menu.lst with a text editor and add init=/sbin/bootchartd to kernel command line as shown below. Once you are done with that save the /boot/grub/menu.lst and reboot your Linux box.
title Fedora (2.6.29.4-167.fc11.i686.PAE)
root (hd0,1)
kernel /vmlinuz-2.6.29.4-167.fc11.i686.PAE ro root=/dev/mapper/VolGroup-LogVol01 rhgb quiet init=/sbin/bootchartd
initrd /initrd-2.6.29.4-167.fc11.i686.PAE.img

iii, Visualizing the Boot log with the Bootchart

Once the Linux box is up, the Bootchart is ready with log information which is logged in /var/log/bootchart.tgz. Now its time to visualize the Bootchart. Execute the following command as a root user.
# bootchart /var/log/bootchart.tgz

The above command would generate image file named as bootchart.svgz in the current working directory. The default image format is svg if you like to generate the boot chart as png file then you need to specify the switch -f with the image format.
# bootchart -f png /var/log/bootchart.tgz