Vishal Lambe's Blog, page 2

December 24, 2015

[UNIX] apropos - Search all the man pages for a particular string.

Sometimes, you know what you wish to accomplish, but you don't know how to do it. Sounds philosophical eh..?

Well, the great masters who designed UNIX have a solution for this too. The 'apropos' command comes in handy when you wish to search for a particular string in all the man pages. And surprisingly, its pretty fast!

This is how you do it.
$ apropos "text-to-find"

apropos command [click on the image to enlarge]

There are many options available. You can try and experiment to suit your needs. 'man apropos' can help you.


Another command which comes handy ion such situations is man -k.
Lowercase k searches only the short description and is equivalent to apropos, but uppercase K searches the entire content of the man pages.
 •  0 comments  •  flag
Share on Twitter
Published on December 24, 2015 05:41

December 13, 2015

[Unix] Hardlinks vs Softlinks (Symlinks)

After reading a numerous blog posts and some articles, here is my understanding of hardlinks and softlinks.

Both the paradigms are closely tied together by the concept of "inode" numbers. Let us first try to understand inodes.

inodes are unique numbers allocated to each file/directory on the UNIX file system. They represent the file level attributes such as permissions, blocks allocated, location etc. To view the inode number of any file/directory, simply type "ls -li".
ls -li [click on the image to enlarge]

The first list of numbers denote inode number of the respective directories.


softlink (aka symlink)
If you are from a Windows background, you would be very similar to the concept of "shortcuts". Just like sortcuts, they refer to the orinigal files. They can point to either files or directories. Hence, both the symlink and the original file will have diffrent inode numbers. Also, as the symlink is just a shortcut, the size of the file/directory will not be same as the original file.

Once you delete the original file, the symlink stays orphan. It will not refer to any file. Any changes that you make to the contents of the file in symlink will be reflect in the original file, however the inode number and the size of the symlink will not change.

Creation of softlinks/symlinks
$ ln -s originalfilename symlinkname
softlinks/symlinks [click on the image to enlarge]Note that in the above screenshot, the inode numbers and size of both the files are different. Also, after deletion of the original file, the symlink becomes orphan (hence the red color). Hence, although both original file are logically same, physically, they are different as they occupy different inodes and different disk blocks. symlink is therefore, just a pointer to the original file.

hardlink
hardlinks are more of a UNIX only concept. As described earlier, inode is a unique number allocated to each file. The underlying difference between an symlink and a hardlink is that in case of hardlink, both the orginal file and the hardlink will have the same inode number and size.

Hence hardlinks are just "pointers" to the inodes which in turn are pointers to the data in the file.

Therefore, if you delete any one of the files, there will be no effect on the original file as the link from the filename to the inode number to the data in the file is still intact. There is no way to determine by looking at the file as to which is the orginal file and which is the hardlink. In fact, there is no such differentiation on the UNIX file system level.

Creation of hardlinks
$ ln originalfilename hardlinkname
hardlink [click on the image to enlarge]
 •  0 comments  •  flag
Share on Twitter
Published on December 13, 2015 10:44

December 7, 2015

[How To] Retrive Last Entered Command On IBM AIX

While once can directly view the last entered commands by pressing Up/Down arrow keys, IBM AIX does not support this.

There is, however, a quirky solution to this. One can type 'r' to run the immediately previous command.

$ r #runs the immediately previous command

Other options include

$ r -1 # to display the second last command
$ r -2 # to display the third last command

..and so on.

Additionally, we can view all the recently entered commands by just entering history command as below:

$ history #displays all the previously  entered commands

If you wish to know how to tweak the history command to customize the number of commands it stores, you can click here.
 •  0 comments  •  flag
Share on Twitter
Published on December 07, 2015 02:36

December 6, 2015

[How To] View and Set The Environment Variables In Unix

Each Unix flavor comes pre-loaded with a set of system defined environment variables such as $HOME, $PATH and $SHELL.

Environment varibales are system specific variables whose values can be changed by the user and are available globally throughout your terminal.

If one wishes to view the value of a specific variable, one can just echo the variable name. You can also find out all the available shell environment variables in following way:

 Viewing the environment variables The printenv command is used to view all the environment variables
$ printenv


 The above example is also illustrated by below screenshot:

printenv command (click on the image to enlarge).
 Setting an environment variableOne can set a new environment variable just like any other other variable. However, one must export the variable to make it globally available.

$ MYHOMEPATH=$HOME/vishal/home$ export MYHOMEPATH
To unset a variable, simply type unset variable_name, as shown in below example.
$ unset MYHOMEPATH
 •  0 comments  •  flag
Share on Twitter
Published on December 06, 2015 12:43

[How To] Change history settings in your Unix Terminal.

The history command in Unix comes in handy when you want to view the recently entered commands on the terminal.

According to the man page, history expansions introduce words from the history list into the input stream, making it easy to repeat commands, insert the arguments to a previous command into the current input line, or fix errors in previous commands quickly.


Hence history list is basically an array of the recently used commands.


Tweaking the history settings on your terminal.
Sometimes, you may want to tweak the settings on your Unix terminal to custom specify the number of history commands it saves. You may want to increase/decrease it. 

The HISTSIZE command can be used to increase/decrease the number of commands in the history to be saved.

Suppose you wish to set the history size to 100, you can type in below command:
$ HISTSIZE=100;

The below image illustrates the same:
Tweaking the history command options (click on the image to enlarge).









Comments / Views?

 •  0 comments  •  flag
Share on Twitter
Published on December 06, 2015 11:55

December 3, 2015

[How To] View Informatica License Key And Information

The following is simple step-by-step guide on how to view Informatica PowerCenter License Key and other related information.

For viewing these details you will be needing access to Informatica Admin console.

1. Open Informatica Admin console.
2. Under the Domain Navigator side window (left hand pane), look out for a "Key" symbol.
3. Click on the symbol and you would be able to see information similar to below screenshot..

Informatica - license Key information (click on the image to enlarge)



Also, you can assign/un-assign Integration and Repository services from "Assigned Services" link. Remember that before assigning or un-assigning the services you first need to stop/abort the services.
 •  0 comments  •  flag
Share on Twitter
Published on December 03, 2015 21:05

November 9, 2015

UNIX Termination Signals


 
SIGTERM
The SIGTERM signal is a generic signal used to cause program termination. Unlike SIGKILL, this signal can be blocked, handled, and ignored. It is the normal way to politely ask a program to terminate.
The shell command kill generates SIGTERM by default. 
 
SIGINT [control+c]
The SIGINT (“program interrupt”) signal is sent when the user types the INTR character (normally control+c).
 
SIGQUIT [control+\]
The SIGQUIT signal is similar to SIGINT, except that it’s controlled by a different key—the QUIT character, usually control+\ —and produces a core dump when it terminates the process, just like a program error signal. You can think of this as a program error condition “detected” by the user.
Certain kinds of cleanups are best omitted in handling SIGQUIT. For example, if the program creates temporary files, it should handle the other termination requests by deleting the temporary files. But it is better for SIGQUIT not to delete them, so that the user can examine them in conjunction with the core dump.
 
SIGKILL [kill -9]
The SIGKILL signal is used to cause immediate program termination. It cannot be handled or ignored, and is therefore always fatal. It is also not possible to block this signal. The "kill -9" command in Linux generates the same signal.
This signal is usually generated only by explicit request. Since it cannot be handled, you should generate it only as a last resort, after first trying a less drastic method such as control+c or SIGTERM. If a process does not respond to any other termination signals, sending it a SIGKILL signal will almost always cause it to go away.
 
SIGHUP [control+d]
The SIGHUP (“hang-up”) signal is used to report that the user’s terminal is disconnected, perhaps because a network or telephone connection was broken.
This signal is also used to report the termination of the controlling process on a terminal to jobs associated with that session; this termination effectively disconnects all processes in the session from the controlling terminal. For more information, see Termination Internals.
 •  0 comments  •  flag
Share on Twitter
Published on November 09, 2015 21:55

I had a black dog, it's name was depression

The black dog hounds each one of us. It is upon us to either tame it or let it tame you. Below is a brilliant transcript from the famous video ' I had a black dog, it's name was depression '.  I suggest you go and watch it.

"I had a black dog. His name was depression.

Whenever the black dog  made an appearance,  I felt empty and life seemed to slow down.

He could surprise me with a visit for no reason or occasion.

The black dog made me look and feel older than my years.

When the rest of the world seemed to be enjoying life, I could only see it through the black dog.

Activities that usually brought me pleasure, suddenly ceased to.

He liked to ruin my appetite.

He chewed up my memory and ability to concentrate.

Doing anything or going anywhere with the back dog required super human strength.

At social occasions, he would sniff out any confidence I had and chase it away.

My biggest fear was being found out. I worried that people would judge me.

Because of the shame and stigma of the black dog. I was constantly worried that I would be found out. So I invested vast amounts of energy into covering him up. Keeping up an emotional lie is exhausting.

Black dog could make me think and say negative things.

He could make me irritable and difficult to be around.

He would take my love and bury my intimacy.

He loved nothing more than to wake me with highly repetitive and negative thinking. He also liked to remind me how exhausted I was going to be the next day.

Having a black dog in your life isn’t so much about feeling a bit down, sad or blue…at it’s worst it’s about being devoid of feeling altogether.

As I got older the black dog got bigger and he started hanging around all the time.

I’d chase him off with whatever I thought may send him running.

But more often than not he’d come out on top. Going down became easier than getting up again.

So I became rather good at self medication…which never really helped.

Eventually I felt totally isolated from everything and everyone.

The black dog had finally succeeded in hijacking my life. When you lose all joy in life, you can begin to question what the point of it is.

Thankfully this was the time that I sought professional help. This was my first step towards recovery and a major turning in my life.

I learned that it doesn’t matter who you are, the black dog affects millions and millions of people. It is an equal opportunity mongrel.

I also learned that there was no silver bullet or magic pill. Medication can help some and others might need a different approach altogether.

I also learned that being emotionally genuine and authentic to those who are close to you, can be an absolute game changer.

Most importantly, I learn not to be afraid of the black dog and I taught him a few tricks of my own.

The more tired and stressed you are the louder he barks, so it’s important to learn how to quiet your mind.

It’s been clinically proven that regular exercise can be as effective for treating mild to moderate depression as antidepressants. So go for a walk or a run and leave the mutt behind.

Keep a mood journal, getting your thoughts on paper can be cathartic and often insightful. Also keep track of the things that you have to be grateful for.

The most important thing to remember is that no matter how bad it gets… if you take the right steps, talk to the right people, black dog days can and will pass.

I wouldn’t say that I’m grateful for the black dog but he has been an incredible teacher. He forced me to re-evaluate and simplify my life. I learned that rather than running away from my problems it’s better to embrace them.

The black dog may always be part of my life but he will never be the beast that he was. We have an understanding. I learned that through knowledge, patience, discipline and humor the worst black dog can be made to heal.

If you are in difficulty, never be afraid to ask for help. There is absolutely no shame in doing so. The only shame is missing out on life.

Depression. Get Help. Be Helped."

 •  0 comments  •  flag
Share on Twitter
Published on November 09, 2015 09:45

October 29, 2015

Carlo M. Cipolla's Laws of Stupidity

Zeroth LawThere is no upper bound on the amount of stupidity that can exist within any particular individual.
First LawWe always underestimate the number of stupid people. Not as obvious as it sounds, because: 1.     people we had thought to be rational and intelligent suddenly turn out to be unquestionably stupid; 2.     day after day we are hampered in whatever we do by stupid people who invariably turn up in the least appropriate places, and 3.     the underestimation is after the first law itself is already accounted for.
Second LawThe probability of a person being stupid is independent of any other characteristic of that person.
Third (and Golden) LawA stupid person is someone who causes damage to another person, or a group of people, without any advantage accruing to himself (or herself) — or even with some resultant self-damage.
Fourth LawNon-stupid people always underestimate the damaging power of stupid people.They constantly forget that at any moment, and in any circumstance, associating with stupid people invariably constitutes an expensive mistake.
Fifth LawA stupid person is the most dangerous person in existence.
 •  0 comments  •  flag
Share on Twitter
Published on October 29, 2015 01:41

September 3, 2015

Shall I wasting in despair - George Wither


Shall I wasting in despair
Die because a woman's fair?
Or make pale my cheeks with care
'Cause another's rosy are?
Be she fairer than the day,
Or the flow'ry meads in May—
   If she be not so to me,
   What care I how fair she be?

Shall my foolish heart be pined
'Cause I see a woman kind?
Or a well-disposed nature
Joinèd with a lovely feature?
Be she meeker, kinder, than
Turtle dove or pelican,
   If she be not so to me,
   What care I how kind she be?

Shall a woman's virtues move
Me to perish for her love?
Or her merits' value known
Make me quite forget mine own?
Be she with that goodness blest
Which may gain her name of Best;
   If she seem not such to me,
   What care I how good she be?

'Cause her fortune seems too high
Shall I play the fool and die?
Those that bear a noble mind
Where they want of riches find,
Think what with them they would do
That without them dare to woo;
   And unless that mind I see,
   What care I how great she be?

Great or good, or kind or fair,
I will ne'er the more despair:
If she love me, this believe,
I will die ere she shall grieve;
If she slight me when I woo,
I can scorn and let her go;
   For if she be not for me,
   What care I for whom she be?

- George Wither

 •  0 comments  •  flag
Share on Twitter
Published on September 03, 2015 21:06