Thursday, October 28, 2010

Forgot to use sudo?

Has it happened to you before that - you run a command and forgot to 'sudo' - and hence the commnd fails and now you need to re-run the command all over again? Well in that case this is how you can save some time.

[debu@DebaTestBox ~]$ sudo !!

Forgot 'sudo' before editing a file:

Believe me this is the most frustrating one, and it happens to me a lot to me. You edited quite a few in the file and when try to save&xit( :wq!) you see an error as below

E212: Can't open file for writing
Press ENTER or type command to continue

Well, the below is a savior un this kind of scenario

:w !sudo tee %

this will ask your password the there in, and you are done. All your edits are now recorded by Vim editor.


Hope it helps!


Monday, October 25, 2010

ssh client for BlackBerry!

I have been using BlackBerry for quite sometime now - and recently someone asked whether I can have any ssh client there.

Yes! We can. I use MidpSSH, which is a ssh client for MIDP 1.0 / 2.0 (J2ME) devices such as Java capable cellphones and other mobile devices released and distributed under GPL.

So far no issues - and its cool. Here is the link to download -

You will need to convert .jar/.jad to .alx files


Sunday, October 24, 2010

\'el\ dot

$l. (To be read as \'el\dot )

This is a very infamous but handy and quick command which lists all the hidden files and folders in your current directory. Works both with RHEL4 and RHEL5 as well.

[Debu@DebuTestBox ~]# l.
. .bash_history .bash_profile .cshrc .redhat .swp .Trash .bash_logout .bashrc .ssh .viminfo

Now you probably don't have to use both your hands to press keystrokes for this task :P


telnet UDP port

Wondering how to telnet a UDP port? Use this -

[deba@prodWeb100 ~]$ nc -vvzu 1434

Connection to 1434 port [udp/ms-sql-m] succeeded!


Saturday, October 23, 2010

Start a new shell from Vi editor in emergency !!

Have you ever faced a situation where you unfortunately edited a Read-only file and later realized that either you need to start a duplication putty session to make that file chmod +w or come out from vi editor without saving the data.

If you know this probably you can handle this situation better that to very fast in efficiently!


While being on the bash Vim editor itself go to the command mode and type -


sh will look up the user's default shell (e.g. the Bourne shell or the C shell) and starts a new shell. In that shell change the permission of the file, type exit(ctrl+d), you will be in the same vi session; now save your file.


Reading passwords in shell script

Today One BE final year student just asked me this one on IM, for his benefit and anyone who might want to have a password wrapper(if at all!!) here it is how to do the same via a shell script,

###This is a simple bash screipt to read password###
######without echoing the same on console#####

while [ $failed -le 3 ]
read -s -p "Password: " userpasswd
echo ""
if [ "$userpasswd" == "$actual" ]
echo "Password accepted"
exit 1
echo "Sorry! Wrong password, Try again..!!"
failed=$(( $failed + 1 ))

Please remember - 'stty' can also do the trick as below:

stty -echo
read password
stty echo


'Script' utility to record your terminal session

Today I was installing something and the ask from my friend at the other end was to let him know how I was doing that. First I thought I will share my screen with him, but wait ! will not a recording of my bash session should suffice his request?

Yes, lets not forget that we have this cool freaking awesome UNIX tool which records and makes a typescript of everything printed on your terminal. Its very popular amongst project students as POC of what and how did they run and tested various scenario;and really helpful for students who need a hardcopy record of an interactive session.

Very easy to use, you can call it a no-brainer to use. When you are ready to record any I/O session just type 'script'.

[root@DebuTestBox ~]# script
[root@DebuTestBox ~]# script -a MyInstallSession_23Oct2010

Now that the recording has started, everything you type, as well as everything that returns as output, will be saved into the filename you chose to output to. If a name is not given, it will store all the I/O of that bash session in a default file viz. typescript on the current folder.

Once done, type ctrl+d or Exit to end your recording session.

[root@DebuTestBox ~]# exit
Script done, file is typescript

And your are done with the recording of the session!! Pass on the typescript whosoever is interested to know what you did in that bash session or rather how in installed that complicated software!! :P


Friday, October 22, 2010


Very catchy name ain't it ? :P Hold on, don't raise high expectation out if this post, its just a handy Linux command. Go on reading further....

Linux man page says: 'namei' - follow a path name until a terminal point is found.

This is a very useful commands I came across recently - which can definitly be of a great help if you have a very complex environment with "too many levels of symbolic links".
It has two switch:

namei -x : show mount points wit 'D' and dir with 'd'
namei -m : shopws mode bit

For ex:

[root@DebuTestBox ~]# namei -x python
f: python/

l python -> /usr/local/Python-2.5
d /
D usr
d local
d Python-2.5

[root@DebuTestBox ~]# namei -m python
f: python/
lrwxrwxrwx python -> /usr/local/Python-2.5
drwxr-xr-x /
drwxr-xr-x usr
drwxr-xr-x local
drwxr-xr-x Python-2.5


Wednesday, October 20, 2010

'ls' command alternatives

Just keep aside as a handy option, if at all your system has gone so bad and your ls command itself is not working - here is this crude method of displaying directory contents by using echo which is a shell built-in and not an executable:

[root@DebaTestBox /]# echo *
bin boot dev etc home lib lost+found media misc
mnt net opt proc root sbin selinux srv sys tmp usr var
cd too a shell built-in, that can also be used to display the same.

All the best -


Tuesday, October 12, 2010

Solaris: How to get global zone information from non-global zone

Due to a variety of reasons like integration with monitoring, asset management, some notion that knowing the real box name will make things better :-) or a need to do something from the global zone like run dtrace, adjust resource allocations etc. you might sometime would like to know what is the Global Zone' where this container resides or the physical servers's IP address where this virtual container resides.

Just see if you can do a 'prtdiag' ; if so you are on a physical server else you are on a non-global zone.

Step 1: Log into the virtual container or non-global zone in question

Step 2 : NonGZ02# arp -a | grep NonGZ02 (grep the hostname/ ip address)
e1000g0 NonGZ02 SPLA 00:14:4f:0e:9f:b8

step 3 : NonGZ02## arp -a | grep 00:14:4f:0e:9f:b8

It will list you a set of arp entries matching that MAC address.

After this to save time either naming convention/ experience with the environment usually help.

If it is in Veritas, I also do a -

cat /etc/VRTSvcs/.vcshost , to get somewhat closer.

step 4: I logged in to

And I find it in that list :

GlobalZone01# zoneadm list -iv | grep running
0 global running / native shared
1 NonGZ02 running /zones/NonGZ02 native shared
2 Proxy02 running /zones/Proxy02 native shared

And I see my non-global host running from there.

Hope it helps!!


Tuesday, October 5, 2010

My First Wedding Anniversary !!

Today October 5th 2010, is my very first wedding anniversary. I still can't quite believe it's been a whole year! Probably sign of a healthy and successful marriage! Ah! someone rightly said in office, probably it is too early to go for this bold declaration!

So, today’s blog post will be short and sweet it will be off the topic but I just want to take this opportunity to greet my lovely wife 'Nandita'. This is true in my case - she has been so caring, supportive all the way even in the time when I have no time to keep my wet towel out to dry, and I see that pleasing confident eyes in her which says “keep doing what you are doing, I am there beside you, and everything will be just fine!”. So my wife deserves all this recognition for being such a wonderful wife, she is my best buddy now. I am very blessed to have you as my wife and couldn’t ask for more I thank GOD for you again.

Yeah during this period I could learn some tricks as well. I felt wives needs a lot of your attention(at all time?!) As someone rightly said - 'you should be taller, older, heavier, uglier, hoarser than your wife' ! Yes, I am paying proper attention to her. And I must say, every husband should.

She also is very sweet. I thought, after marriage( our one was a arranged marriage!) she wont allow me to drink at all. But I somehow accumulated so much of courage one day, that around my 3rd month of marriage, I told her very clearly that - I need to drink at least 1 bottle of beer every week. :-) and yeah, she agreed. I was very confused though, whether she actually wanted me to do so or test , but nay! she actually meant it. That day and today, I never actually dared or felt like to take any more permission as the show must go on. Be your own mentor! Same will happen in tonight's dinner party as well, which begins in a short while from now, no more permission ;-)

Anyway, thanks to everyone who has been wishing me through out the day. Love you all. It really means a lot to me...


Sunday, October 3, 2010

Trouble Uninstalling IE9?

Just couple of days back I wrote a post on IE9 beta release. I saw it buggy and was wondering if some of you has problem uninstalling this buggy piece from your PC. Let me tell you that - you can't simply go to Add/Remove program and uninstall it easily, like you have been doing it for other piece of software. Well, here is how to do it -

  1. Start -> Run -> appwiz.cpl
  2. Here you won't see any entry for IE9 in the main program list. Click on the 'View installed updates link' in the sidebar to see the installed updates.
  3. Scroll down till you see a section for Microsoft Windows and find "Windows Internet Explorer 9" in it.
  4. Right click on the entry and click on the 'Uninstall' button.
  5. After the update is removed you will be reverted to the last installed version of Internet Explorer on your PC.

This above steps are what I tested in Windows 7 .

Enjoy your earlier favorite(!) version of IE browser!!


Saturday, October 2, 2010

Script written in Win is not working in *nix environment?

Have you ever copied a bash or any other script written your favorite windows editor to UNIX environment and saw it does not work?

Yeah? Well its a Line terminator issue between windows and Linux environment. The enter key, in windows appends a CR and LF code into the end of the line; where in *nix only CR is appended at the end of the line.

Check the script with cat -v, if it display something ^M at the end of the line, that means this text file was created under windows environment. And CR LF is causing the execution of bash script to fail.

$cat -v

Once identified, this issue can easily be fixed with the dos2unix command.

$chmod +x

That's it !!


Friday, October 1, 2010

du and df -h confusing stats?

Just now explained someone with example, thought to put it in my blogs as well -


If someone is running an application with a file open in a directory and the open file is removed, the du output reflects a reduced size for this directory. However, df does not show a reduced size.

..and the confusion begins becuase 'df' and 'du 'are showing contradictory stats.

We must know that - du reports the space used by files and folders--even this is more than the file size. df reports the space used by the file system. This includes the overhead for journals and inode tables and such.The difference is that whenever an application has an open file, but the file is already deleted, then it is counted in the df output (because the space is certainly not free) but not in du (because it is not being used by a file). All blocks in the file system remain allocated until the application that has the file open itself closes the file. And only after the file closure, df will show the reduced usage for the file system.

Below is the exercise to reproduce and understand it better -

[root@DebuTestBox ~]# dd if=/dev/zero of=/tmp/duTest.txt bs=1024 count=500000

When this is going on - from another terminal, remove the file duTest.txt

[root@DebuTestBox ~]# rm /tmp/duTest.txt
rm: remove regular file `/tmp/duTest.txt'? y

Now check -

[root@DebaTestBox ~]# lsof | grep "deleted"
java 4579 root 285u REG 253,0 0 3670130 /tmp/ (deleted)
dd 16516 root 1w REG 253,0 106242048 3670125 /tmp/dutest.txt (deleted)

Hope it helps.

Now to resolve this issue - we need to figure out what those files are, its importance and relevance in your work space and if found fit to delete them , go ahead and fire the following command -

#lsof | grep "deleted" | awk '{print $2}' | xargs kill -9


CICD Assessment

( A story on -  how we formulated a process around measuring and achieving CICD, and  how these journey lines has now become a means t...