Wednesday, January 4, 2012

After a long break

Its been more than an year since I have blogged on something. Life has changed a lot in the last year. So far it has been the most eventful year in my career. It is an year in which I had put an end to my life as a techie and started a new one as business man. Yes, I always felt that "Money is the mother of all sins" :).

    Living in Saudi Arabia is one among the worst things that you could do to make money. As Pinky's dad use to tell "It is an open jail". But yes, you make big money here. I always feel sorry for pinky for all the suffering she takes to be with me.

   Time to catchup with some Linux, Else I may loose it all..







Wednesday, November 3, 2010

Up and running on Fedora14

In suzie's words .. "bashmonk is a bleeding edge user of Fedora".. Yup! I proved it again. I got Fedora 14 on my TP before anyone else in IBM :) India Labs..

Monday, July 26, 2010

The new bundle from Heaven has arrived

Yup! she is finally there. The lil one.. :). After the long wait of 9 months she has made her way to our life. Our new gift from God.. She has made our home to grow by ~1.5 fts and 3.2 Kgs.


Monday, March 8, 2010

Test from Blogilo

Yup !! It works!!

=-=-=-=-=
Powered by Blogilo

Thursday, February 11, 2010

Linux Process States

The Linux kernel stores the list of processes in a circular doubly linked list of structures task_struct, called the task list. The process descriptor (task_struct) contains all the information about a specific process.Each task_struct structure has a state enry which describes the current state of the process. At any time on a Linux machine the processes running on it are in exactly one of five different states. The struct task_struct and the five states are defined in linux/sched.h.

TASK_RUNNING - runnable; The task is either running or ready to run and waiting in the runqueue.

TASK_INTERRUPTIBLE - sleeping or blocked; In this state the process is waiting for some event to complete. When it completes, the kernel puts back the process to the runqueue and make it runnable by changing the state to TASK_RUNNING. The process can also respond to a signal in this state.

TASK_UNINTERRUPTIBLE - Uninterrupted sleep; This is exactly the same state as TASK_INTERRUPTIBLE but it cannot be interrupted by any signals to make it runnable. This happens typically with the IO operation. This is used when the process must wait without interruption or when the event is expected to occur quite quickly like an IO operation. They are unkillable as the task will not respond to signals(SIGKILL wont work). These are the D state process that you will find with the ps command. Its not advised to attempt a kill on this process (by killing the parent), as the task may be in the middle of some important operation and may be holding some resources.

TASK_ZOMBIE - Zombie; A special case when the task has completed but its parent has not yet reaped it, by issuing a wait4() system call. A zombie process just occupies an entry in the process table. This entry exists because in case the parent wants to access it, the descriptor should be available. When the parent calls wait4() a zombie disappears.

TASK_STOPPED - All is well :) and is stopped; The task is not running and will not be scheduled.May be killed or caught by other signals.

Sunday, November 22, 2009

Google Chrome on Fedora

Yes, Now its available on Linux. The much waited Google Chrome on Linux. Its still an unstable version available on Linux, but is worth a try.


Create a file /etc/yum.repos.d/google-chrome.repo with the contents below

[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/rpm/stable/i386
enabled=1
gpgcheck=0


Install chrome

yum install google-chrome

Enjoy

Saturday, November 21, 2009

I'm There with FC12 (Fedora Core 12) and IBM desktop apps :)

Well it was a journey of a Linux freak . I lost the data in my entire TP. Thank heavens, I had my backup done in my USB HDD.

It all started up with FC12 The installation went fine, I didn't take a chance with putting ext4 file system on /boot partition as it was not working on FC11. The installation went fine and I got the IBM layer installed on it. Thanks to Grant Williamson for making appropriate packages available in the IBM yum repo. He was too good with his support. I was happy except that the mouse pointer was slow after the installation of the IBM layer. I tuned it through the Gnome preferences. Thanks Srini for the autoten repo to make the nonfree stuff working . Everything was set up and I was ready to click the Lotus notes icon. To my surprise nothing really happened. I tried the command line notes85.sh and it failed telling that the libnotes.so is not able to create a stack.

Phew!! the entire work has gone on a toss. I checked the logs and it showed that the Selinux is giving some permission errors. I turned the Selinux policy to permissive and then restarted notes. It worked like a charm!! :).

Now came the next issue. The Clearcase client which was running fine on FC11 has started giving me some errors. It started telling me that the libswt-mozilla-gtk-3236.so has some undefined symbol _ZN4nsID5ParseEPKc. Hmm.. I know what it means :-P. I got the xulrunner-devel package installed and made clearcase happy.

I haven't tried KDE yet. I want to keep up suspense and excitement, and gift me a surprise.

Here are my favourite apps, Being a hardcore KDE fan some of the apps below may not work well with Gnome.

Chat/IM - empathy/pidgin/sametime
IRC - Konversation
Password management - Kwallet
Personal Finance - kmymoney
Email - Lotus Notes / thunderbird
Twitter Microblogging - choqok
Notes - Tomboy/Kjots
Editor - vim/gedit/kate
Browser - Firefox/chrome/seamonkey
Music - amarok/rhythmbox
Other tools- rsibreak,digikam,gimp,picasa
IDE - Rational Application Developer/Eclipse

Using DVD as your Yum repo - FC12

Its as simple as this

vi /etc/yum.repos.d/dvd.repo

Put the following entries

[dvd]
name=Fedora DVD
baseurl=file:///media/Fedora\ 12\ i386\ DVD/
enabled=1
gpgcheck=0


Save and start using it :).

If you have a DVD image, them loop mount it to some location and modify the dvd.repo file as below

To Loop mount

mount -o loop /path/of/DVD.iso_file /path/to/your/mount_poin
t

dvd.repo file

[dvd]
name=Fedora DVD
baseurl=file:///path/to/your/mountpoint
enabled=1
gpgcheck=0

Friday, March 6, 2009

A beautiful thought!

This was a fortune tumbled down by my /usr/bin/fortune at my bash prompt. I liked it very much

The highest good is like water.
Water give life to the ten thousand things and does not strive.
It flows in places men reject and so is like the Tao.
In dwelling, be close to the land.
In meditation, go deep in the heart.
In dealing with others, be gentle and kind.
In speech, be true.
In ruling, be just.
In daily life, be competent.
In action, be aware of the time and the season.
No fight: No blame.

Monday, January 5, 2009

Positional Paramters at bash

The positional parameters or command line parameters are those which are passed as arguments to the script

eg: #myscript.sh arg1 arg2 arg3 arg4

Here arg1, arg2, arg3, and arg4 are positional or command line parameters. Now lets look at how these command line parameters can be used in the script. Bash keeps some internal variables in which the positional parameters are saved. They are as below

$0 Filename of script
$1 - $n Positional parameters #1 - #n
$# Number of positional parameters
"$*" All the positional parameters
"$@" All the positional parameters (why two of them ???)
${#*} Number of command-line parameters passed to script
${#@} Number of command-line parameters passed to script

Now let us see some examples using the positional parameters.

Check the script below


#!/bin/bash
if [[ $# != 11 ]]
then
echo "Usage `basename $0` arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 arg10 arg11"
exit 1
fi
echo -e "first argument is $1"
echo -e "second argument is $2"
echo -e "Third arguement is $3"
echo -e "Fourth argument is $4"
echo -e "Fifth argument is $5"
echo -e "Sixth argument is $6"
echo -e "Seventh argument is $7"
echo -e "Eighth argument is $8"
echo -e "Nineth argument is $9"
echo -e "Tenth argument is $10"
echo -e "Eleventh argument is $11"
echo -e "The complete list of arguments are $*"
echo -e "The complete list of arguments are $@"
echo -e "The number of command line parameters are ${#*}"
echo -e "The number of command line parameters are ${#@}"


Executing the above scripts gives the following output.

[sijo@CyBerJiNX bash]$ ./posparams.sh 1 2 3 4 5 6 7 8 9 10 11
first argument is 1
second argument is 2
Third arguement is 3
Fourth argument is 4
Fifth argument is 5
Sixth argument is 6
Seventh argument is 7
Eighth argument is 8
Nineth argument is 9
Tenth argument is 10
Eleventh argument is 11
The complete list of arguments are 1 2 3 4 5 6 7 8 9 10 11
The complete list of arguments are 1 2 3 4 5 6 7 8 9 10 11
The number of command line parameters are 11
The number of command line parameters are 11
[sijo@CyBerJiNX bash]$


Now rerun script as below.

[sijo@CyBerJiNX bash]$ ./posparams.sh one two three four five six seven eight nine ten eleven
first argument is one
second argument is two
Third arguement is three
Fourth argument is four
Fifth argument is five
Sixth argument is six
Seventh argument is seven
Eighth argument is eight
Nineth argument is nine
Tenth argument is one0
Eleventh argument is one1
The complete list of arguments are one two three four five six seven eight nine ten eleven
The complete list of arguments are one two three four five six seven eight nine ten eleven
The number of command line parameters are 11
The number of command line parameters are 11
[sijo@CyBerJiNX bash]$


See the way in which the tenth and eleventh argument is printed. Is this a bug.. No, so what is wrong with the script. Let us recheck the lines which prints tenth and eleventh args.

echo -e "Tenth argument is $10"
echo -e "Eleventh argument is $11"

The bash prints them as $1 followed by a 0 and $1 followed by a 1.So how to print the arguments $10 and $11. Rewrite the lines as

echo -e "Tenth argument is ${10}"
echo -e "Eleventh argument is ${11}"

The curly braces {} acts as the delimiter for the variable name to be printed. This is the right way in which any variables in a shell script should be printed.

Now check the lines

echo -e "The complete list of arguments are $*"
echo -e "The complete list of arguments are $@"

Are these lines one and the same?... No, they are not

The first line $* will store the entire command line parameters as a single string where as the second one $@ stores the elements in an array.


}}}

Wednesday, September 10, 2008

Compress and uncompress the files in Linux with tar

To compress folder myfolder to myfolder.tar.gz

tar czfv myfolder.tar.gz myfolder/
czfv = "compress gzip file archive with verbose output"

If you want bzip files, use ‘j’ instead of ‘z’.

tar cjfv myfolder.tar.gz myfolder
cjfv = "compress bzip file archive with verbose output"


Uncompress myfolder.tar.gz to folder myfolder/

tar -xzf Test.tar.gz
xzf = ‘extract gzipped file archive’

Again, if you want bzip files, use ‘j’ instead of ‘z’.

tar -xzf Test.tar.gz
xjf = ‘extract bzipped file archive’

Tuesday, August 19, 2008

Setting the inital file permissions using umask

umask command is used to set the default permission modes for newly created files in the current shell and its child processes.

umasks are calculated as the AND of the unary complement of the argument (NOT) and the full access mode.

The full access mode is 666 in the case of files, and 777 in the case of directories

A common umask value is 022 (masking out the write permission for the group and others), which ensures that new files are only writable for the owner (i.e. the user who created them). Another common value is 002, which leaves the write permission for the file's group enabled. This can be used for files in shared workspaces, where several users work with the same files.

Example usage of setting umask

Assuming the umask has the value 163, any new file will be created with the permissions 604 and any new directory will have permissions 614 because:

666 AND NOT(174) = 604
666=110 110 110
163 = 001 110 011
NOT(001 110 011) = (110 001 100)
(110 110 110) AND (110 001 100) = (110 000 100)
777 NOT (163) = 604
while

777 AND NOT(163) = 614

777 = 111 111 111
163 = 001 110 011
NOT(001 110 011) = (110 001 100)
(111 111 111) AND (110 001 100) = (110 001 100)
777 NOT (163) = 614

Monday, August 11, 2008

Attaching serial console on a Linux box

Step # 1: Setup Serial redirection

By default, grub output does not appear on the remote console; it only appears on the local terminal. However, you can configure your grub.conf file to redirect all grub output to the remote console. Redirection will display the grub output on the remote console, but not on the local terminal. To redirect grub output, make the following changes to your /etc/grub.conf file:


# vi /boot/grub/grub.conf
Append the following lines in the file

serial --unit=1 --speed=19200 --word=8 --parity=no --stop=1
terminal --timeout=8 console serial

* The first line tells GRUB to use the first serial port at a baud rate of 19200
* The second line gives the user 9 seconds to decide where GRUB should output it's information.
* Please adjust port number and speed as per your setup.

Next make sure splashimage options is disabled as graphics can't be displayed across the serial port. Remove splashimage line or just comment it out by prefixing # symbol:
#splashimage=(hd0,0)/grub/splash.xpm.gz

Also please comment out the hiddenmenu option ( We had some issues at times when tried using this, so to be on safer side,disable it )


Step # 2: Enabling serial output from the Linux kernel


Find the kernel line (grub config file) which corresponds to your currently running kernel. Add the following at the end of that line - console=tty0 console=ttyS0,9600n8:

title Red Hat Enterprise Linux ES (2.6.9-42.0.10.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-42.0.10.ELsmp ro root=LABEL=/ console=tty0 console=ttyS1,19200n8
initrd /initrd-2.6.9-42.0.10.ELsmp.img


On Red Hat EL nodes, please make the following changes

* Set SAFE=YES in /etc/sysconfig/kudzu

Remote installation of OpenSuse-11 on an IBM PPC

1. Setup the DHCP/BOOTP/PXE/TFTP server to boot from network
3. Boot from network
4. The yaboot prompt will appear. Please enter
install vnc=1 ssh=1
to start the installation on vnc and to enable ssh connections.
5. You'll be asked to enter the vnc and ssh password. Please enter a password of your choice here.
Enter your VNC password>
Enter your temporary SSH password>
6. You'll be asked to choose the network interface you want to use.
Choose the network device.
1) eth1 : Broadcom NetXtreme BCM5704S Gigabit Ethern
2) eth0 : Broadcom NetXtreme BCM5704S Gigabit Ethern
Automatic configuration via DHCP?
1) Yes
2) No

7 Opensuse now starts the installer, Connect to the VNC server with a viewer of your choice
vncviewer :1

Saturday, July 19, 2008

Special character ; at bashprompt

; is used as a command separator and to terminate a case statement at bash

#!/bin/bash

# This script is to explain the usage of the ; as a special character in bash.
# Sijo George
#--------------------------START-------------------------------
echo "Hello world,"; echo "How are you?"; # Execute two commands in a line using a ; delimiter
case $1 in
[a-z] ) echo " The input is an alphabet " ;; # Terminator in the case option
[0-9] ) echo " The input is a number" ;;
* ) echo " The input is neither an alpabet or a number ";;
esac

Thursday, July 17, 2008

Usage of Special character '#' at bash

Read through the script below. This better explains the usage

#!/bin/bash
# This script is to explain the special char #
# Sijo George sijo.george@gmail.com
#------------------START------------------------#
#This is a comment
echo "This is #not a comment"
echo 'This also # is not a comment'
echo But ...This is a #comment
echo However This \# is not a comment
echo "Parameter sub is not a comment"
echo ${PATH}
echo ${PATH#*:};# Cuts of the shortest string of pattern after the # from the front
echo ${PATH##*:};# Cuts of the longest string of pattern after the # from the front
echo "Base conversion is not a comment "
echo $((2#1010)) # Convers binary 1010 to decimal
echo $((16#ABCD)) # Converts hex ABCD to decimal
string="this is a string"
echo ${#string} # Gives the number of characters in the string
array=(1 test a 10)
echo ${#array} # Gives the length of first element of the array
echo ${#array[*]} # Gives the number of elements in the array
echo ${#array[@]} # Gives the number of elements in the array
echo ${#} # Gives the number of command line parameters.
echo ${#*} #Gives the number of command line parameters.
echo ${#@} #Gives the number of command line parameters.

Thursday, February 21, 2008

Keyboard shortcuts at bash prompt

Alt + < - Move to the first line in the history
Alt + > - Move to the last line in the history
Alt + ? - Show current completion list
Alt + * - Insert all possible completions
Alt + / - Attempt to complete filename
Alt + . - Yank last argument to previous command
Alt + b - Move backward
Alt + c - Capitalize the word
Alt + d - Delete word
Alt + f - Move forward
Alt + l - Make word lowercase
Alt + n - Search the history forwards non-incremental
Alt + p - Search the history backwards non-incremental
Alt + r - Recall command
Alt + t - Move words around
Alt + u - Make word uppercase
Alt + backspace - Delete backward from cursor
Ctrl + a - Jump to the start of the line
Ctrl + b - Move back a char
Ctrl + c - Terminate the command
Ctrl + d - Delete from under the cursor
Ctrl + e - Jump to the end of the line
Ctrl + f - Move forward a char
Ctrl + k - Delete to EOL
Ctrl + l - Clear the screen
Ctrl + r - Search the history backwards
Ctrl + R - Search the history backwards with multi occurrence
Ctrl + u - Delete backward from cursor
Ctrl + xx - Move between EOL and current cursor position
Ctrl + x @ - Show possible hostname completions
Ctrl + z - Suspend/ Stop the command

Fun with bash - Addition at bash prompt

Addition at bash prompt can be done in many ways. I have managed to collate some of them in the script below. The script below counts from 1 to 14 in 14 different ways. Its fun isn't it. It shows how powerful and feature-rich this simple scripting language is.

#!/bin/bash
n=1;
echo -n "$n, "
let "n = $n + 1"
echo -n "$n, "
: $((n = $n + 1))
echo -n "$n, "
(( n = n + 1 ))
echo -n "$n, "
n=$(($n + 1))
echo -n "$n, "
: $[ n = $n + 1 ]
echo -n "$n, "
n=$[ $n + 1 ]
echo -n "$n, "
let "n++"
echo -n "$n, "
(( n++ ))
echo -n "$n, "
: $(( n++ ))
echo -n "$n, "
: $[ n++ ]
echo -n "$n, "
n=`echo "$n + 1" | bc`
echo -n "$n, "
n=`echo "$n + 1" | bc -l`
echo -n "$n, "
n=`expr $n + 1`
echo "$n"

Wednesday, February 20, 2008

Adaruvan Vayya

I love this poem written by ONV recited by Madhusoodanan Nair, specially the last three lines


Irulin mahaanidrayil ninnunarthi nee niramulla jeevitha peeli thannu
ente chirakinaakashavum nee thannu ninn aathma shikirathil oru koodu thannu

Oru kunju poovilum thalirkaatilum ninne neeyayi manakunnathengu vere...
jeevanozhukumbol oruthulli ozhiyathe neethanne nirayunna puzhayengu vere...
kanavinte ithalaayi ninne padarthi nee viriyichoraakashamengu vere...

Oru kochu raapadi karayumbozhum nerthoraruvi than thaarattu thalarumbozhum
kaniviloru kallu kanimadhuramavumbozhum kaalamidarumpozhum ninte -
hridayathil njanente hridayam koruthirikunnu...
ninill abhayam thiranju pokunnu...

Adaruvan vayya..... nin hridayathil ninnenikethu swargam vilichaalum
uruki nin aathmaavin aazhangalil veenu poliyumbozhaanente swargam
ninnil adiyunnathee nitya sathyam

See the video of the song from the film Daivathinte Vikrithikal

The opening ceremony

Well.. I'm here ..
Lemme open this with a note to my sweetheart..

You're my best friend in the good times
and my rock in times of sorrow.
You're the reason for sweet yesterdays
and my promise for tomorrow.

My love, The sea nor land, nor death itself can extinguish or lessen toward you, most endearedly visits you with eternal embraces, and will abide with you for ever: and may the God of my life watch over you, and bless you, and do you good in this world, and for ever.