Sunday, May 28, 2006

Dragging windows in linux

On many occasions in linux , I have come across the situation where the window size is bigger thatn the screen size so in effect , i can't see the ok or apply buttons at the bottom .
In such cases , you can use the alt + mouse left click combination and press the arrow keys to drag the window up and down .
Hope it helps

Monday, May 22, 2006

Brainbench Job role

I didn't notice till recently that Brainbench had job role certifications that was given if a selected set of papers was cleared.Well, I set my sights on three of the available ones.
Network Administrator, Linux Administrator, Unix Administrator.
Finally cleared Network Administrator.The other two are still pending.Need to clear an elective from C , Bash , Perl , Python .
I think Bash or C might be my choice.
If that is also cleared , I will get the latter two job roles also.
I hope I can do it before the Games ends this 31st.

Wednesday, May 17, 2006

Some more games with Awk

To rename all files in current directory (append .bak to all of them):
ls -l | awk '{print "mv "$1" "$1".new"}' | sh

Thats doing an ls of all files , passing each name to awk as argument , renaming the awk input and passing the whole formatted output to shell

1. Renaming within the name:
ls -1 *name1* | awk '{print "mv "$1" "$1}' | sed s/name1/name2/2 | sh

2. remove only files:
ls -l * | grep -v drwx | awk '{print "rm "$9}' | sh
or with awk alone:
ls -l|awk '$1!~/^drwx/{print $9}'|xargs rm
Be careful when trying this out in your home directory. We remove files!

3. remove only directories
ls -l | grep '^d' | awk '{print "rm -r "$9}' | sh
or
ls -p | grep /$ | wk '{print "rm -r "$1}'
or with awk alone:
ls -l|awk '$1~/^d.*x/{print $9}'|xargs rm -r
Be careful when trying this out in your home directory. We remove things!

4. killing processes by name (in this example we kill the process called netscape):
kill `ps auxww | grep netscape | egrep -v grep | awk '{print $2}'`
or with awk alone:
ps auxww | awk '$0~/netscape/&&$0!~/awk/{print $2}' |xargs kill
It has to be adjusted to fit the ps command on whatever unix system you are on. Basically it is: "If the process is called netscape and it is not called 'grep netscape' (or awk) then print the pid"

Tuesday, May 16, 2006

Today's catch

I was busy most of the day with some networking issue at office. But I took some time out later at night to write at least one exam .So the catch of the day is

Networking Concepts.

I have set my sights on few others.Will have to wait till tomorrow for that.....

Monday, May 15, 2006

Brainbench games

Well ,Happy news for those who are looking out for a certification to add to your resume...
the famous online certification site Brainbench.com has started their brainbench games for this year.Its the best opportunity to write their exams for free online.Normally you get to write only a few for free and for the rest you need to pay.
I attempted the following today and cleared them
1)Information Technology Security Fundamentals
2)Network Technical Support
3)Internet Technology Fundamentals
4)Linux Administration - Redhat

That takes my Brainbench tally to 8 certifications.
Well it seems there is a prize for each country that has the most no. of certificate earners.
Check out www.brainbench.com for more...........

My younger brother receiving a prize


Thats him shaking hands with the principal

Pronouncing "Linux"

I've seen many people pronouncing Linux in many different ways.
Some say it with li as in liar
some with the li as in limit
some with the nu as in nook
Well going by what Torvalds says
http://www.paul.sladen.org/pronunciation/torvalds-says-linux.wav

I'll go by that

Thursday, May 11, 2006

What Shorewall could and Nortel Contivity couldn't

I happened to have a strange issue.I had an IP to which I had done a layer of NATting so that an IP w.x.y.z would see to my network users as a.b.c.d. I used Nortel Contivity CSF/NAT software for this.
But whenever we did an FTP to the natted IP , the initial connection got established but after that the data connection was never established.It dropped connection whenever a data connection or passive mode was requested.I checked the rules at my end thoroughly , opened up the required ports , ensured that at the other end also everything was open.But nothing worked.Finally I decided to do a packet capture and set an ethereal capture with the filter on ftp port alone.
To my wonder the PORT raw FTP command was giving the ip a.b.c.d to the ftp server at w.x.y.z which the server was not aware since I was doing a NAT.
The problem was detected, but earlier this used to work when I did the same using Shorewall.
I read the documentation of Shorewall and understood that Linux was aware of this issue and hence there was a kernel module ip_nat_ftp which took care of modifying PORT and PASV commands in case of a nat.Shorewall automatically loads this module .Thats why it used to work earlier.
When contacted Nortel said its a known bug with their firmware version which they will fix in their next update.
Perhaps if their code was open, it might have got noticed a long back .................
Am I right????????

Wednesday, May 10, 2006

A few cool vim tips

The "*" key will search for the word from the current cursor position to EOF
The "#" key will search for the word from the current cursor position to the top of the file.

/^[A-M]\+/ : search for lines beginning with one or more A-M
/you\|me : search for YOU OR ME

/\<\d\d\d\d\> : Search for exactly 4 digit numbers
/\<\d\{4}\> : same thing

:s%/,/\r/gc : To find and replace all commas with a new line

/^\n\{3} : find 3 empty lines
:%s/^\n\{3}// : delete blocks of 3 empty lines

:%s/^\(.*\)\n\1$/\1/ : delete duplicate lines

" Recording (BEST TIP of ALL)
qq # record to q
your complex series of commands
q # end recording
@q to execute
@@ to Repeat
5@@ to Repeat 5 times

Thats it for now.Rest later

Tuesday, May 09, 2006

Connection drops when TTL changes!!!

I had a very strange issue today.There was a linux server that had been working for some time and suddenly the developer team suddenly started facing connection drops.they also noticed that whenever the ping ttl was 63 it was working fine. When it switched to 127 it started dropping.
I was left clueless because in /proc/sys/net/ipv4/ip_default_ttl was 64 only and there was no reason why it showed 127 in the ping .
Well finally the problem was somebody else had given a new windows machine the same ip .Whenever traffic hit the windows machine it was returning 127 as the TTL and hence all connections to services on the linux server was dropping.
The ip was then changed on the new machine and then the services connected happily ever after...............................

At work



Sunday, May 07, 2006

Some occasions where you can replace awk with cut

Let me tell you first that I love awk and its my favourite scripting language.But in case you just have a one time simple requirement for column processing and you don't know awk , in some cases you can fulfil the requirement with cat and cut

cat inputfile | cut -f 6 -d ' '
where the sixth column would be output when space is the delimiter.

the awk equivalent would be
awk -F ' { print $6 } ' inputfile

"And yet they said awk is difficult
But Awk is a wonderful tool"

Saturday, May 06, 2006

A new great link

I got this one from my favourite linux support forum
linuxquestions.org

This guy has put up a large no of wonderful howto's .Probably if I had got this five months back I could have avoided my company having to pay Redmond a huge amount for M$ Exchange.Well in case there is anyone else right now in my situation its all right here.Have a look.Great work Paul
http://www.yourhowto.org

And one new thing that i learnt
If you are pretty irritated by the password prompt every time you type sudo
add an option NOPASSWD: ALL this to the visudo config file line where you have specified your user rights .The ALL above is for all commands you can restrict it according to your needs

Thursday, May 04, 2006

Some M$ stuff

I am not suppose to be posting Redmond stuff here, but I feel this might be helpful to those *nix users who are used to configuring everything from the command line when they are forced to do something on a M$ system
To use a command line to set IP address information on a Windows NIC :-
Windows Server 2003 and Windows XP provide the Netsh utility, which, among its many capabilities, can configure the IP properties of NICs. To set a static IP address, use this format:
netsh interface ip set address local static
as in the following example:
netsh interface ip set address local static 192.168.1.15 255.255.255.0 192.168.1.1 1
(Some command lines wrap to two lines here because of space constraints.)
To set a client's NIC DNS settings, run this command:
netsh interface ip set dns local static 192.168.1.150 primary
To set a client back to DHCP, run these commands:
netsh interface ip set address local source=dhcp
netsh interface ip set dns local source=dhcp

Tuesday, May 02, 2006

Partition deletion and grub problems

I recently deleted some partitions from my disk using fdisk , and they had nothing to do with my active OS , but at my next reboot , my system started giving kernel panic.
The problem was that the deleted partitions were like hda5, hda6 etc and the partition where my OS was loaded was something like hda10,hda11 etc.Once the others were deleted , the partitions got renamed while menu.lst and fstab was as per the old numbering of the partitions.
I went into single user mode , edited grub and fstab , and rebooted , but then on it got stuck at grub prompt.
When i entered the parameters for root, kernel and initrd in grub and gave boot , it worked , but again at reboot it stood at grub.I tried rebooting after ensuring all changes were properly affected in grub.conf , menu.lst and in fstab(I use SUSE at home) but it still got stuck at grub.every time I entered the parameters and gave the boot command it worked ,but when the same thing was written in menu.lst it did not accept it.
Finally I reinstalled grub from the normal prompt after booting from grub and rebooted and things were back to normal.
Now my system works fine.

SELinux (t)errors

One of my friends had a strange experience.He had a script stored inside the Apache document root and it could not be executed when the script was called directly using " ./script ".The executable permissions and all were fine but there was no way to run it there.But when the same script was called with "bash script "
It worked fine. Again if the script was copied somewhere else outside the Apache doc root it would work when directly executed also. The strace showed that open(/dev/tty) was returning a failure return code only when executed from the apache doc root. The strace o/p of both successful and unsuccessful executions of the script were put to diff and all the troubles seemed to begin from there.A lot of head scratching later we saw that Selinux was enabled on the box and that was the cause for all this.It was putting the Apache doc root in a chroot jail and was not allowing any script to be executed there.
Then changed the setting in /etc/selinux/config from enforcing to disabled and
echo 0 > /selinux/enforce
and lo things were back to normal