Friday, July 29, 2011

Zip a folder in Linux

I keep forgetting the command to zip a folder in Linux (Red Hat Enterprise Linux 4). And I have even got all files in the folder got zipped individually when I typed the command wrongly, which looked funny to me. The correct command, to remind myself:

zip -9 -r

To zip a single file:

zip -9

Use "-9" for best compression. The compressed file works fine with Windows XP compression tool.

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.

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


[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

$ 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

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

Step 3: Replace the existing xorg.conf with the generated one, kindly don't forget to rename the 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.


Thursday, May 27, 2010

MySQL Monitoring Scirpt

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 = '';
my $frommail = '';

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";
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...


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