Wednesday, May 6, 2009

The Changing World- Azim Premji

While change and uncertainty have always been a part of life, what has been shocking over the last year has been both the quantum and suddenness of change.

For many people who were cruising along on placid waters, the wind was knocked out of their sails. The entire logic of doing business was turned on its head. Not only business, but also every aspect of human life has been impacted by the change. What lies ahead is even more dynamic and uncertain. I would like to use this opportunity to share with you some of our own guiding principles of staying afloat in a changing world. This is based on our experience in Wipro. I hope you find them useful.

First, be alert for the first signs of change. Change descends on everyone equally; it is just that some realize it faster. Some changes are sudden but many others are gradual. While sudden changes get attention because they are dramatic, it is the gradual changes that are ignored till it is too late. You must have all heard of story of the frog in boiling water. If the temperature of the water is suddenly increased, the frog realizes it and jumps out of the water. But if the temperature is very slowly increased, one degree at a time, the frog does not realize it till it boils to death. You must develop your own early warning system which warns you of changes and calls your attention to it. In case of change being forewarned is being forearmed.

Second, anticipate change even when things are going right. Most people wait for something to go wrong before they think of change. It is like going to the doctor for a check up only when you are seriously sick or thinking of maintaining your vehicle only when it breaks down. The biggest enemy of future success is past success. When you succeed, you feel that you must be doing something right for it to happen. But when the parameters for success change, doing the same things may or may not continue to lead to success. Guard against complacency all the time. Complacency makes you blind to the early signals from the environment that something is going wrong.

Third, always look at the opportunities that change represents. Managing change has a lot to go with our own attitude towards it. It is the proverbial half-full or half empty glass approach. For every problem that change represents, there is an opportunity lurking in disguise somewhere. It is up to you to spot it before someone else does

Fourth, do not allow routines to become chains. For many of us the routine we have got accustomed to obstructs change. Routines represent our own zones of comfort. There is a sense of predictability about them. They have structured our time and even our thought in a certain way. While routines are useful, do not let them enslave you. Deliberately break out of them from time to time

Fifth, realize that fear of the unknown is natural. With change comes a feeling of insecurity. Many people believe that brave people are not afflicted by this malady. The truth is different. Every one feels the fear of unknown. Courage is not the absence of fear but the ability to manage fear without getting paralyzed. Feel the fear, but move on regardless.

Sixth, keep renewing yourself. This prepares you to anticipate change and be ready for it when it comes. Constantly ask yourself what new skills and competencies will be needed. Begin working on them before it becomes necessary and you will have a natural advantage. The greatest benefit of your education lies not only in what you have learnt, but in working how to learn. Formal education is the beginning of the journey of learning. Yet I do meet youngsters who feel that they have already learnt all there is to learn. You have to constantly learn about people and how to interact effectively with them. In the world of tomorrow, only those individuals and organizations will succeed who have mastered the art of rapid and on-going learning.

Seventh, surround yourself with people who are open to change. If you are always in the company of cynics, you will soon find yourself becoming like them. A cynic knows all the reasons why something cannot be done. Instead, spend time with people who have a "can-do" approach. Choose your advisors and mentors correctly. Pessimism is contagious, but then so is enthusiasm. In fact, reasonable optimism can be an amazing force multiplier.

Eighth, play to win. I have said this many times in the past. Playing to win is not the same as cutting corners. When you play to win, you stretch yourself to your maximum and use all your potential. It also helps you to concentrate your energy on what you can influence instead of getting bogged down with the worry of what you cannot change. Do your best and leave the rest.

Ninth, respect yourself. The world will reward you on your successes. Success requires no explanation and failure permits none. But you need to respect yourself enough so that your self-confidence remains intact whether you succeed or fail. If you succeed 90 per cent of the time, you are doing fine. If you are succeeding all the time, you should ask yourself if you are taking enough risks. If you do not take enough risks, you may also be losing out on many opportunities. Think through but take the plunge. If some things do go wrong, learn from them.

I came across this interesting story some time ago: One day a farmer's donkey fell down into a well. The animal cried piteously for hours as the farmer tried to figure out what to do. Finally he decided the animal was old and the well needed to be covered up anyway it just wasn't worth it to retrieve the donkey. He invited all his neighbors to come over and help him. They all grabbed a shovel and begin to shovel dirt into the well. At first, the donkey realized what was happening and cried horribly. Then, to everyone's amazement he quieted down. A few shovel loads later, the farmer finally looked down the well and was astonished at! what he saw. With every shovel of dirt that fell on his back, the donkey was doing some thing amazing. He would shake it off and take a step up. As the farmer's neighbors continued to shovel dirt on top of the animal, he would shake it off and take a step up. Pretty soon, everyone was amazed as the donkey stepped up over the edge of the well and totted off! Life is going to shovel dirt on you, all kinds of dirt. The trick is too not to get bogged down by it. We can get out of the deepest wells by not stopping. And by never giving up! Shake it off and take a step up!

Tenth, in spite of all the change around you, decide upon what you will never change: your core values. Take your time to decide what they are but once you do, do not compromise on them for any reason. Integrity is one such value. These have contributed to our success, including our parents and others from our society. All of us have a responsibility to utilize our potential for making our nation a better place for others, who may not be as well endowed as us, or as fortunate in having the opportunities that we have got. Let us do our bit, because doing one good deed can have multiple benefits not only for us but also for many others. Let me end my talk with a small story I came across some time back, which illustrates this very well.

This is a story of a poor Scottish farmer whose name was Fleming. One day, while trying to make a living for his family, he heard a cry for help coming from a nearby bog. He dropped his tools and ran to the bog. There, mired to his waist in black muck, was a terrified boy, screaming and struggling to free himself. Farmer Fleming saved the boy from what could have been a slow and terrifying death. The next day, a fancy carriage pulled up to the Scotsman's sparse surroundings. An elegantly dressed nobleman stepped out and introduced himself as the father of the boy Farmer Fleming had saved. "I want to repay you, "said the nobleman.” Yes," the farmer replied proudly. "I'll make you a deal. Let me take your son and give him a good education. If he's anything like his father, he'll grow to be a man you can be proud of." And that he did. In time, Farmer Fleming's son graduated from St. Mary's Hospital Medical School in London, and went on to become known throughout the world as the noted Sir Alexander Fleming, the discoverer of Penicillin. Years afterward, the nobleman's son was stricken with pneumonia. What saved him? Penicillin. This is not the end. The nobleman's son also made a great contribution to society. For the nobleman was none other than Lord Randolph Churchill, and his son's name was Winston Churchill. Let us use all our talent, competence and energy for creating peace and happiness for the nation."

Reference:

http://www.managementparadise.com/forums/articles/2371-how-manage-change-speach-azim-premji-chairman-wipro-technologies.html

http://www.greencrosssociety.com/azim_prenji_speech.html

Friday, April 24, 2009

Oracle Export Backup Shell script

#!/bin/sh

# Name : Oracle Export Backup
# Writer : Mahendra Rajgude
# Date : 23 Oct 2007
# Version : 0.1
# Pupose : This script is written to take oracle export backup


# Exporting environmental variable. This will specific to server.

HOSTNAME=`hostname`
ORACLE_SID=ngs
ORAWEB_ADMIN=/u01/app/oracle/admin
ORAWEB_BASE=/u01/app/oracle
ORAWEB_HOME=/u01/app/oracle/products/9.2.0
ORACLE_BASE=/u01/app/oracle
ORACLE_TERM=vt100
ORACLE_HOME=/u01/app/oracle/products/9.2.0
ORACLE_PATH=/u01/app/oracle/products/9.2.0/rdbms/admin:/u01/app/oracle/products/9.2.0/sqlplus/admin:/u01/app/oracle/common/sql
BACKUP_DIR=/oraclebackup

export ORACLE_SID ORAWEB_ADMIN ORAWEB_BASE ORAWEB_HOME ORACLE_BASE ORACLE_TERM ORACLE_HOME ORACLE_PATH BACKUP_DIR HOSTNAME

# Export DATE format to add extention to backup file.

DATE=`date '+%d'`

#echo Logfile{$DATE}

# Remove any previous backup file

rm ${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE}.gz

# Actual backup starts here

${ORACLE_HOME}/bin/exp system/manager full=y file=${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE} statistics=none log=${BACKUP_DIR}/${HOSTNAME}_full.log.${DATE} buffer=2048000 compress=y consistent=y


# Compression done here to reduce the size of backup


/usr/bin/gzip ${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE}

# Removing uncompressed file..

rm ${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE}

#####################################################################################################
#####################################################################################################


# Change History

# V 1.0 Dated 23 Oct 2007 checked working fine.

Tuesday, March 17, 2009

How to Stay Young n Happy Always :-)

1. Throw out nonessential numbers. This includes age, weight, and height. Let the doctors worry about them.. That is why you pay them.

2. Keep only cheerful friends. The grouches pull you down. (Keep this in mind if you are one of those grouches!)

3. Keep learning: Learn more about the computer, crafts, gardening, whatever. Never let the brain get idle. 'An idle mind is the devil's workshop.' And the devil's name is Alzheimer's!

4. Enjoy the simple things

5. Laugh often, long and loud. Laugh until you gasp for breath. And if you have a friend who makes you laugh, spend lots and lots of time with him or her!

6. The tears happen: Endure, grieve, and move on. The only person who is with us our entire life, is ourself. LIVE while you are alive.

7 Surround yourself with what you love: Whether it's family, pets, keepsakes, music, plants, hobbies, whatever. Your home is your refuge.

8. Cherish your health: If it is good, preserve it. If it is unstable, improve it. If it is beyond what you can improve, get help.

9. Don't take guilt trips. Take a trip to the mall, even to a foreign country, but NOT to where the guilt is.

10. Tell the people you love that you love them, at every opportunity.

But do share this with someone

Know love, know LIFE...

" "No love, no LIFE...

" Love that heart, that hurts u.. But never hurt ,that heart that loves u..

Never Change your Originality – For the sake of others, because no one can play your role better than you …"So be your self


(Thanks to my TechMahindra friend for this article. )

Monday, February 9, 2009

Things to do on a money free Weekend

Things to do on a money free Weekend... (Taken from tachmate website of TechM)


1. Teach yourself how to change the oil in your car / bike. If you’re due for an oil change, just bring the oil you need home with you and teach yourself how to do it. All you really need is an old pan to catch the wasted oil and a funnel to pour the old oil back into the canisters for later disposal. Just use your car / bike manual as a guide for the procedure and you might just find that not only is it a lot easier than you thought, but it’s a useful skill to have and it’s cheaper than taking your car into Jiffy-Lube (or wherever you take your car for oil changes).

2. Meet your neighbors. Make an effort to introduce yourself to your neighbors if you don’t know them well. Invite any interesting ones over for a cup of coffee and a chat, just to get to know each other better. Your neighbors can not only become friends, but can also be a valuable resource - a friendly pair of eyes on your property when you’re away or a helpful set of hands when you’re trying to complete a challenging task.

3. Have a “cupboard potluck.” Go through your cupboards and find any items that might have slipped to the back over time. Invite some friends to do the same, then get together for a potluck dinner prepared from only these ingredients and whatever else you have on hand. It makes for a “free” meal and a lot of fun for everyone involved.

4. Organize a walking tour. Find out about the interesting historical and cultural sites in your town, then go on a walking tour of it. Pack a lunch in your backpack and have a picnic on the village green or in the park. You can easily turn this into a full day if you live in a compelling area.

5. Take some digital photographs. Take your digital camera out with you and take pictures of anything you find interesting. Take lots of them, then go home later and see if you’ve taken anything beautiful and compelling. Great images can make for the basics of homemade greeting cards (yep, keep going downwards for more on this), nice desktop wallpaper, screensavers, or many other interesting uses.

6. Start a blog on a topic that interests you. You can get a free blog at Wordpress or Blogger. Join the service and start a blog on a topic that interests you. Not only can it be a ton of fun, it also helps you improve your communication skills, reach out to others, and perhaps earn a bit of income as well.

7. Learn the basics of a new topic. Just go to MIT’s OpenCourseWare, find a topic you’re interested in, download a bunch of mp3s of lectures on the topic, and listen to them while you’re doing household chores. Some great suggested starting points: microeconomics, macroeconomics, basics of philosophy, western philosophy, and introductory physics. Another great option: fire up iTunes, then click on the “iTunes U” option on the left hand side. You’ll find tons of material there to teach you the basics of countless topics.

8. Cook some meals in advance. If you already have a bunch of basic food staples on hand, spend some time cooking some meals in advance to store in the freezer. It’s easy to prepare casseroles, soups, pasta meals, and many other items all at once, then store them in portion-sized containers in the freezer for eating later. Not only is this way cheaper than eating out or buying convenience foods, it’s also healthier and also far more social. Missing some ingredients but have an abundance of others? Team up with friends and make it a social event - share ingredients so that you can all take some casseroles or other dishes home for the freezer.

9. Build a basic net worth calculator for yourself. One great way to ensure that you’re consistently making financial progress is to build your own net worth calculator. Once you have it set up, updating it is easy, and it can provide a great snapshot of your financial situation as well as show off your progress.

10. Make a how-to video for YouTube. Share your knowledge! All you need is a digital camera that captures video and (optionally) some video editing software. Just create a video to demonstrate how to accomplish something interesting and useful. Start off by making a script to follow, then turn on the camera and follow it. When you’re done, upload it to YouTube and let others enjoy it. If it’s useful and entertaining, people will come.

11. Do a “bill reduction.” Spend a few hours trimming your monthly bills. Find ways to reduce your regular bills. Ask for credit card rate reductions. Think about what monthly bills you can completely eliminate, then do the footwork to get rid of them. This might be a boring task now, but if you can trim $50 from your monthly bills for free, your future self will be very happy.

12. Play football / soccer. All you need is a ball, some open space, and some friends. Designate whatever is available as goals, then kick the ball around. Don’t worry about being terrible at the game - as long as everyone’s just having fun, it really doesn’t matter how bad you are.

13. Scan your old pictures. If you have a digital scanner laying around somewhere, bust it out and scan in the piles of old prints you have laying around. If you have a screensaver of pictures, scanning in old prints and adding them to the rotation will make your screensaver all the more amazing. Plus, it becomes easy to just attach them to emails and send them to friends and family.

14. Have a film festival. Invite some friends over and have them each bring one of their favorite DVDs. Then just settle in with some snacks (whatever you have on hand) and burn a lazy afternoon and evening just watching movies together. It’s a ton of fun and it doesn’t cost anything at all.

15. Practice yoga - or try it for the first time. All you need is some floor space and a blanket to do most yoga poses. Try out a basic yoga session to see if you like it. It increases flexibility, improves concentration, and holding some of those positions for long periods can be a powerful workout.

16. Read an entertaining book. Look around your house for a fun book to read, perhaps something loaned to you by a friend or something you received as a gift, and curl up and let yourself be sucked into the story. I’m a sucker for Stephen King novels - I can just pick up any one and quickly be sucked straight into the plot for a fun afternoon’s read.

17. Call a family member or a friend you haven’t spoken to in a while. Not only does it provide you a chance to catch up and firm up a relationship with another person who is important to you, it can also be a very entertaining and enjoyable way to spend an hour or two.

18. Learn a foreign language. Doubt this can be free? There are a lot of ways to learn a foreign language online, from podcasts that teach language skills to YouTube videos and many other free language learning opportunities. Search around for resources for any language that you might want to learn - you’ll find tons of materials to help you.

19. Dig up your family tree. Take a peek at genealogy.com and see what you can find out about your ancestors. Try to assemble a family tree, and see if you can link to any distant cousins or long-lost family members. Doing this can give you a much clearer picture of your heritage and help you get in touch with your family roots.

20. Go on a wandering walk. Just head out your front door and go in whichever direction looks the most interesting. As long as you have some basic navigational skills, you won’t get lost, and you can turn around or backtrack whenever you get bored or hit a dead end. Along the way, who knows what kind of interesting stuff you might find?

21. Help out an elderly or disabled friend or neighbor. There’s always a person or two in your life that could use a helping hand, but often are too proud to ask. One great way to bridge this gap is to just stop in and visit and pay attention - if they need something, you’ll usually find out. Then just volunteer to do it and get started on the task. Quite often, you’ll find that it’s the simple things that really help - reaching something on a high shelf or managing a simple household task. And that little effort can make all the difference. Few things can make you feel more fulfilled than helping someone you care about in their moment of need.

22. Start a book club - or find one to join. If you like reading and know other friends that enjoy it, too, consider starting a book club with them where you all read the same book for a week then meet to talk about it. It can transform reading from a solitary activity into a more socially oriented one, and with a library at your disposal, it can be a free activity as well.

23. Have an “entertainment swap” with a friend. This one’s pretty easy. Just have a friend bring over a pile of their own DVDs, CDs, books, video games, etc. that they own that they think you’d like. When they get there, have a big temporary swap - swap them an item for an item. This not only will refresh your media collection for a while, but can provide a great opportunity for you to talk about your interests with a friend.

24. Do some amateur stargazing. Go outside on a clear evening, preferably away from city lights, and look up at the sky. Use some handy star maps to know what you’re looking at. Spread out some blankets on the ground, lay flat on your back, stare upwards, and realize how magnificent the universe is around you.

25. Go on a hike or a long walk. Go to the local hiking or walking trails and just take off. Let yourself get absorbed into nature and simply enjoy the journey. Go at your own speed - this is for your own personal enjoyment, after all.

26. Take a stab at writing poetry (or other forms of creative writing). The basics of poetry are easier than you might think - just try writing down what’s on your mind. Whatever you’re thinking about, just write it down. That can provide the basics of any poem. Then, just read through the stuff you’ve written down, choose the words that seem beautiful to you, and assemble them until the whole work means something. This can be a deeply enlightening and personal experience, actually, and one that really stirs the creative juices.

27. Go on a bike ride. If you’ve got a bicycle and a helmet in your garage or closet, you already have everything you need for some good exercise and some good fun. Head outside and bike away. Almost every town and every state park around here has an extensive array of bike trails, so you can almost always find somewhere new and interesting to ride, plus it’ll help get you into shape really quick.

Wednesday, November 26, 2008

Best Wishes for First Wedding Anniversary

Marriages are made in Heaven



"Remember that a successful marriage depends on two things: finding the right person and being the right person" quote.

Do we really know the actual definition of a successful marriage? If not than lets look for it and see what conclusion we can draw. We often say that someone somewhere is made for you and the day you come across that person you feel that that he or she is the one you have been waiting for. But later we see that due to lack of understanding and mental compatibility they move apart. So how can we say that they were the perfect match since they didn't gave any effort to understand each other. So it's important you know your partner. There are people who get physically attracted and fall for each other and eventually end up getting married. But later on when they see their wavelength not matching they easily get separated without a second thought. In today's generation we see these incidents more compare to earlier generation. And this is more due to the changing social scenario. With so many things to divert your attention you really don't know what to do.

Marriage is not just coming together of two individuals. There is much more to it. To sustain a marriage it is important that there is effort from both sides than only a marriage can carry on. A successful marriage is like a good recipe whose main ingredients are love, commitment, understanding, concern and togetherness. If you can include these aspects in your married life you can find happiness in your marriage. Andre Maurois once aptly said, "A happy marriage is a long conversation which always seems too short." which is so true. When we talk about mental compatibility between husband and wife we have seen that not only incase of arrange marriage this problem exist where both of them were unknown to each other before marriage but even after many years of courtship in love marriages this problem exist because when we meet before marriage we are at our best to impress the other person. And we start accepting each other the way we like to see each other. But gradually after marriage when we slip into our natural self that time we have to accept each other as we are. And in most of the cases the real self is not what we wanted to see and then begins the contradiction with the person whom we have loved and with whom I have to spend my life. So it's important that when you love a person love him or her the way he or she is and not the way you want him or her to be. Then only you can be happy. A happy married life calls for constant commitment and concern for each other. There are few small and minute aspects, which we tend to forget in our married life, as we get busy with the daily chores. So at times it is important to indulge in those minute details of a married life, which will constantly remind each other of the love and concern being present. We can conclude by the quote of Barnett Brickner, which says it, all that "Success in marriage does not come merely through finding the right mate, but through being the right mate."

First wedding anniversary is very important. It is one of evaluation point for life. Before marriage, we were sleeping under parents wings. After marriage, even though their blessings are there, our real life journey starts. We need to do lot of compromises against our wish. But still finding real happiness among it , is the real art. By Indian tradition, a woman has more responsibility in a family so it is applicable to you. I am sure; you will fulfill all the expectations of your family.



Have a Bright and Happy Day!

Happy anniversary to you both;
Have a bright and happy day.
Your marriage sets an example;
It shines in every way.

Time passes, and your bond is strong;
It lasts through sun and storm;
You’ll always have your love
To keep each other warm.



By Joanna Fuchs

Tuesday, October 14, 2008

Who is poor ? ( Good short story )

One day, the father of a very wealthy family took his son on a trip to the country with the express purpose of showing him how poor people live.

They spent a couple of days and nights on the farm of what would be considered a very poor family.

On their return from their trip, the father asked his son, 'How was the
trip?'

'It was great, Dad.'

'Did you see how poor people live?' the father asked.

'Oh yeah,' said the son.
'So, tell me, what did you learn from the trip?' asked the father

The son answered:
I saw that we have one dog and they had four.

We have a pool that reaches to the middle of our garden and they have a creek that has no end.

We have imported lanterns in our garden and they have the stars at night.

Our patio reaches to the front yard and they have the whole horizon.

We have a small piece of land to live on and they have fields that go beyond our sight.

We have servants who serve us, but they serve others.

We buy our food, but they grow theirs.

We have walls around our property to protect us, they have friends to protect them.'

The boy's father was speechless.

Then his son added, 'Thanks Dad for showing me how poor we are.'

Isn't perspective a wonderful thing?

Makes you wonder what would happen if we all gave thanks for everything we have, instead of worrying about what we don't have.

Appreciate every single thing you have, especially your friends!

'Life is too short and friends are too few.'


(I got this story on the mail . Published here for to get benefit to other. )

Wednesday, October 8, 2008

How to do root mirroring with SVM ?

This document explains how to do root mirroring using SVM.


Setup : root disk is dev/rdsk/c0t0d0
To be mirrored on dev/rdsk/c011d0

Create sama partition on both drive


1. prtvtoc /dev/rdsk/c0t0d0s2 > oldparttable

2. fmthard –s oldparttable /dev/rdsk/c0t11d0s2

Format all partion to be mirrored on. In this case

newfs /dev/rdsk/c0t11d0s0
newfs /dev/rdsk/c0t11d0s1
newfs /dev/rdsk/c0t11d0s3
newfs /dev/rdsk/c0t11d0s4
newfs /dev/rdsk/c0t11d0s5
newfs /dev/rdsk/c0t11d0s6
newfs /dev/rdsk/c0t11d0s7

Create replica databse.

metadb -a -c 3 -f c0t0d0s7 c0t11d0s7

Check meta database

bash-3.00# metadb
flags first blk block count
a u 16 8192 /dev/dsk/c0t0d0s7
a u 8208 8192 /dev/dsk/c0t0d0s7
a u 16400 8192 /dev/dsk/c0t0d0s7
a u 16 8192 /dev/dsk/c0t11d0s7
a u 8208 8192 /dev/dsk/c0t11d0s7
a u 16400 8192 /dev/dsk/c0t11d0s7


Create one way partition:


metainit -f d11 1 1 c0t0d0s0
metattach d10 -m d11
metainit d10 -m d11
metaroot d10

more /etc/vfstab

Create same for /var partition

metainit -f d21 1 1 c0t0d0s4
metainit d22 1 1 c0t11d0s4
metattach d20 -m d21

Check status

metastat -p

cp vfstab vfstab.bak
vi vfstab

more /etc/system

Check boot path

eeprom


boot-device=/pci@1f,4000/scsi@3/disk@0,0:a /pci@1f,4000/scsi@3/disk@b,0:a disk net


Note down boot slice path as follows:

bash-3.00# ls -al /dev/dsk/c0t0d0s0

lrwxrwxrwx 1 root root 41 Sep 15 00:26 /dev/dsk/c0t0d0s0 -> ../../devices/pci@1f,4000/scsi@3/sd@0,0:a

bash-3.00# ls -al /dev/dsk/c0t11d0s0

lrwxrwxrwx 1 root root 41 Sep 15 00:26 /dev/dsk/c0t11d0s0 -> ../../devices/pci@1f,4000/scsi@3/sd@b,0:a

Record the string that follows the /devices directory

i.e /pci@1f,4000/scsi@3/sd@b,0:a

ok> nvalias backup_root /pci@1f,4000/scsi@3/disk@b,0

ok> setenv boot-device disk backup-root net


/pci@1f,4000/scsi@3/sd@b,0:a


nvunalias backup_root /pci@1f,4000/scsi@3/sd@b,0:a ===> This is not working even though it is per SUn DOcument. ....

ok devalias
backup_root /pci@1f,4000/scsi@3/sd@b,0:a
disk5 /pci@1f,4000/scsi@3/disk@c,0
disk4 /pci@1f,4000/scsi@3/disk@b,0
disk3 /pci@1f,4000/scsi@3/disk@a,0
disk2 /pci@1f,4000/scsi@3/disk@9,0
disk1 /pci@1f,4000/scsi@3/disk@8,0
disk0 /pci@1f,4000/scsi@3/disk@0,0
disk /pci@1f,4000/scsi@3/disk@0,0
scsi /pci@1f,4000/scsi@3
cdrom /pci@1f,4000/scsi@3/disk@6,0:f
tape /pci@1f,4000/scsi@3/tape@4,0
pcia /pci@1f,2000
pcib /pci@1f,4000
pci0 /pci@1f,4000
flash /pci@1f,4000/ebus@1/flashprom@10,0
nvram /pci@1f,4000/ebus@1/eeprom@14,0
parallel /pci@1f,4000/ebus@1/ecpp@14,3043bc
net /pci@1f,4000/network@1,1
ebus /pci@1f,4000/ebus@1
i2c /pci@1f,4000/ebus@1/SUNW,envctrltwo
floppy /pci@1f,4000/ebus@1/fdthree
tty /pci@1f,4000/ebus@1/se@14,400000


ok> boot disk4


And this works for me. Hope you will make this working.

Monday, October 6, 2008

Mastani


Mastani was one of the most beautiful women in the history of India. It is said that Mastani was the daughter of the heroic king Maharaha Chhatrasal of Bundelkhand , through his Muslim mistress. Rana Chhatrasal was an exceptional prince in Indian history who took inspiration from Chhatrapati Shivaji of establishing independent kingdoms. Through 1727 and 1728, Mohammad Khan Bangash the Mughal, with an army of Afghans invaded Chattrasal’s kingdom, took Jaitpur and imprisoned him and his family within the Mughal camp. The eighty year old Chattrasal sent a distress message to Bajirao , who was on a military campaign in the vicinity, about his plight, in a poetic languange drawing a parallel with Gajendra Moksha Akhyan, a from Hindu mythology. Bajirao was the Peshwa of the Maratha kingdom. Bajirao and his mighty Maratha army helped Chhatrasal and his Bundela Rajput forces to retake Jaitpur. The old Bundela king re-entered his capital in full state, amidst the welcoming cheers of the citizens and the boom of the victorious Maratha cannons. In gratitude and as a token of his deep affection for Bajirao, whom he treated like a son-in-law, Chattrasal gave his young and beautiful daughter Mastani along with a third of his kingdom, including Jhansi, Sagar and Kalpi to Bajirao in May 1729. Chhatrasal's sons treated Bajirao as a blood-brother and later fought alongside him in many of his future campaigns. Bajirao was all of 31 years old. Mastani was the love of the young Peshwa's life and stayed devotedly by his side until his death. She resided with him at his Shaniwar Wada at Pune and rode stirrup to stirrup with him on his numerous military campaigns. Historical texts mention "People would gather on the road to see their brave king Bajirao and his beautiful mistress, Mastani." Mastani probably inspired the Peshwa Bajirao to succeed brilliantly, putting up one of the greatest contributions in building the Maratha Empire in North India and gaining total control over Mughals. She was his inspiration in battle, she bore him a valiant son and when Bajirao died, she fearlessly chose to perish in the flames of his funeral pyre. Their son, named Shamsher Bahadur , fought bravely in the Third Battle of Panipat in 1761 against Ahmed Shah Abdali , and died of serious wounds in Bharatpur after the Maratha forces lost the battle. The daughter of a Rajput father, Mastani was a skilled horse-rider, and accompanied Bajirao on all his campaigns. This often meant riding hundreds of miles over rugged country, living in camps under canvas and sharing his rough fare. She was said to be as good as any soldier in horsemanship, spear throwing and swordplay. She also had a talent for dancing and singing and Bajirao was infatuated with her. On one occasion the Peshwa went so far as to forget protocol and took her with him to Satara , when he went to pay his respects to his Shahu . This apparently drew an indignant reprimand from the Maratha monarch. The Brahmins of Pune, who had a strong influence on the Hindu rulers, could never accept Mastani as Bajirao's wife. She became the center point in Pune politics when Bajirao openly declared Mastani as his wife and their son a Brahmin. The couple faced severe resistance from Bajirao's mother, Radhabai, his wife Kashibai, his beloved brother Chimnaji Appa and the entire Brahmin community. The brahmins refused to carry out the sacred Upanayanam of Shamsher Bahadur. Later Bajirao had to take Mastani out of Shaniwar Wada. He built a separate residence for her at Kothrud, which was quite away from Kasbe Pune in those days. Separation was unfortunately inevitable. Bajirao never really recovered from this setback, and finally died of a flash fever in an army camp at Khargon, near Indore close to the banks of the Narmada , pining for Mastani. Bajirao's wife Kashibai, his brother Chimnaji and his son Balaji, came to Khargon and with them came Mastani. Bajirao's mortal remains were consigned to flames on 28th April 1740, at Raverkhed on the Narmada. At the cremation ceremony, Mastani suddenly broke through the crowd and walked into the flames. Before the stunned family could react or prevent her, the beautiful Mastani was gone. Had Bajirao's family supported the great warrior and the orthodox Brahmins accepted Mastani as a wife of Bajirao, Indian history may have gone differently. The stories of Bajirao-Mastani are amongst the few love stories in the world, between bravery and beauty.

Mastani was staying at Pabal , 70 km from Pune and had samadhi there.

Wednesday, September 24, 2008

Use of /etc/mail/aliases

We will see how to use /etc/mail/aliases efefctively ?

First find domainname of the server.

# domainname
xyz.com

Now in this case domainname of the server is xyz.com.

1. Forwarding mail to mail account rather than user. Add following lines in /etc/mail/aliases

user1: user.surname@domainname.com

Now you can send mail to user1@xyz.com and mail will distributed to user.surname@domainname.com

2. If no users are in To: field then ignore it. Add following lines in /etc/mail/aliases

undisclosed-recipients: /dev/null

3. Add following lines in /etc/mail/aliases for support

support: support@domainname.com

4. Forwarding mails to group of people

4.1 Create group called wishlist and add in /etc/mail/aliases

wishlist: :include:/admin/etc/wishlist.mail

4.2 Create file whose content looks like

# more /admin/etc/wishlist.mail

user1@domainname.com
user2@domainname.com
user3@domainname.com

Now you can send mail to wishlist@xyz.com and mail will distributed to user1@domainname.com, user2@domainname.com ,user3@domainname.com

Now you can send mails and you will receive it on new mail id. If you use effectviely your administration and support will much easier.

Script for Oracle export backup

Lot of time we need to have export backup of Oracle. Follwoing script will help to take export backup. You need to just change variable of your environment.I assumed that username password id system/manager

----------------------------------------------------------------------------------
#!/bin/sh

# Name : Oracle Export Backup
# Writer : Mahendra Rajgude
# Date : 23 Oct 2007
# Version : 0.1
# Pupose : This script is written to take oracle export backup


# Exporting environmental variable. This will specific to server.

HOSTNAME=`hostname`
ORACLE_SID=ngs
ORAWEB_ADMIN=/u01/app/oracle/admin
ORAWEB_BASE=/u01/app/oracle
ORAWEB_HOME=/u01/app/oracle/products/9.2.0
ORACLE_BASE=/u01/app/oracle
ORACLE_TERM=vt100
ORACLE_HOME=/u01/app/oracle/products/9.2.0
ORACLE_PATH=/u01/app/oracle/products/9.2.0/rdbms/admin:/u01/app/oracle/products/9.2.0/sqlplus/admin:/u01/app/oracle/common/sql
BACKUP_DIR=/oraclebackup

export ORACLE_SID ORAWEB_ADMIN ORAWEB_BASE ORAWEB_HOME ORACLE_BASE ORACLE_TERM ORACLE_HOME ORACLE_PATH BACKUP_DIR HOSTNAME

# Export DATE format to add extention to backup file.

DATE=`date '+%d'`

#echo Logfile{$DATE}

# Remove any previous backup file

rm ${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE}.gz

# Actual backup starts here

${ORACLE_HOME}/bin/exp system/manager full=y file=${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE} statistics=none log=${BACKUP_DIR}/${HOSTNAME}_full.log.${DATE} buffer=2048000 compress=y consistent=y


# Compression done here to reduce the size of backup


/usr/bin/gzip ${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE}

# Removing uncompressed file..

rm ${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE}

#####################################################################################

# Change History

# V 1.0 Dated 23 Oct 2007 checked working fine.

Monday, September 22, 2008

Good quotes about Heart



















If GOD wants to speak to you, he will speak to through your heart. Heart then tries to tell you. You should listen to your heart if wants GOD's message for you. Mahendra Rajgude



A memory is a photograph taken by the heart
to make a special moment last forever....Unknown.

Let your heart guide you. It whispers,
so listen closely....Land Before Time.

You may hold my hand for a while,
but you hold my heart forever....Unknown.

As the ocean is never full of water,
so is the heart never full of love....Unknown.

What the heart gives away is never gone...
It is kept in the hearts of others....Robin St. John.

Love is blind only to the eyes.
The heart sees everything clearly....Unknown.

A person's actions depict the heart,
not the words they say....Brian Lee.

To get a woman's heart a man must first use his own....Unknown.

Sometimes we make love with our eyes. Sometimes we
love with our hands...Sometimes with our bodies.
Always we make love with our hearts....Unknown.

It is not the size of a man but the size of
his heart that matters....Evander Holyfield.

Follow your heart, but be quiet for a while
first. Ask questions, then feel the answer.
Learn to trust your heart....Unknown.

Precious gifts of friendship...knowing the heart of
another, sharing one's heart with another....Unknown
.

Never close your lips to those whom
you have opened your heart....Unknown.

It is only with the heart that one
can see rightly; what is essential is
invisible to the eye....Antoine De Saint-Exupery.

For it was not into my ear you whispered
but into my heart, it was not my lips
you kissed, but my soul....Judy Garland.

The best and most beautiful things in this
world cannot be seen or even heard, but must
be felt with the heart....Helen Keller.


A friend is one to whom one can pour out all the
contents of one's heart, chaff and grain together,
knowing that the gentlest of hands will take and
sift it, keeping what is worth keeping, and, with the
breath of kindness, blow the rest away....Arabian Proverb.

If you find it in your heart to care for somebody
else, you will have succeeded....Maya Angelou.

t is the heart that makes a man rich.
He is rich according to what he is,
not according to what he has....Henry Ward Beecher.

Great is the human who has not lost his childlike heart....Mencius.

Find the seed at the bottom of your heart
and bring forth a flower....Shigenori Kameoka.

Everyone should carefully observe which way
his heart draws him, and then choose that
way with all his strength....Hasidic Saying.

The heart already knows
What the mind can only dream of.
Trust your heart....Unknown.

You can admire a woman for her beauty, but you
can only respect a woman for her heart....Unknown.


Friendship is like a rainbow between two hearts....Unknown.

Follow your mind and be smart,
follow your heart and be happy....Unknown.

Wednesday, September 17, 2008

How to set password-less ssh login ?

















( The image above is from Rohit Sharma's stock photography website http://opticverse.com. Thanks to Rohit for allowing me to publish.)

It is important to note that, since the SSH protocol is a highly secure one, it does not accept just the traditonal .rhosts on the users login for accepting a remote connection without password verification.

The implementation of SSH1 and SS2 are slightly diferent, and from OpenSSH to SSH2 vary too. Since most of the Linux machines are running OpenSSH2, we will describe here how to make the "trick" for avoiding a password everytime when running openssh2 on both client and server.
For detailed information about the class of key verification and encription that ssh uses, see the ssh and related man pages or online documentation at http://www.openssh.com/manual.html

The basic idea is, however, that in the cryptosystem that ssh uses (RSA or/and DSA) the encription and decription are done using diferent keys
Basically, what the user (client) needs is to generate a public/private key pair. The server will know the public key, but only the client will know the private key.
When the client connects to the server, it tells its own public key. If this key is allowed (if it is between the know public keys list on the server), the server will send a randomic number to the client. This encripted number can only be decripted if the appropiate decription key is used, and this decription key is the client's private one. The client then uses then its own private key and decript the number. If this is done correctly, the server will grant the acces with no more questions. As you can see the system is safe, because the client never tells anybody about its private key; and this key cannot be inferred using the public one.

What must be done, then , is to generate a public/private key pair, and copy the public part into the appropiate place on the server side.
For doing this, on the user's home directory, on the client machine, type

local> ssh-keygen -t dsa -f .ssh/id_dsa

-t tells the type of encription
-f tells where to store the public/private key pairs. In this case, the .ssh directory on home is being used

A password will be asked; leave this part blank, just pressing
Now, go the .ssh directory, and you will find two new files: id_dsa and id_dsa.pub. The last one is the public part. Now, copy the public key to the server machine

local> cd .ssh
local> scp id_dsa.pub user@remote:~/.ssh/id_dsa.pub

Of course, this time you will need to enter the password.
Now, login into the server machine and go to the .ssh directory on the server side

local> ssh user@remote
remote> cd .ssh

Now, add the client's public key to the know public keys on the server

remote> cat id_dsa.pub >> authorized_keys2
remote> chmod 640 authorized_keys2
remote> rm id_dsa.pub
remote> exit

and that's all.

Next time you log into the remote server, no password will be asked.

Note that this sytem will work while none of the machines change its IP address and for the specific user, so it is still safe.

-------------------------------------------------------------------------------------

sala:~$ ssh-keygen -t dsa -f .ssh/id_dsa
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in .ssh/id_dsa.
Your public key has been saved in .ssh/id_dsa.pub.
The key fingerprint is:
26:10:4b:b5:ae:c0:89:5f:d5:d1:ce:e9:5c:49:a3:63 rajgudm@sala
sala:~$ cd .ssh
sala:~/.ssh$ ls
id_dsa id_dsa.pub known_hosts


nandi:~/.ssh$ cat id_dsa.pub >> authorized_keys2
nandi:~/.ssh$ chmod 640 authorized_keys2
nandi:~/.ssh$ rm id_dsa.pub
nandi:~/.ssh$ exit
logout
Connection to nandi closed.
sala:~/.ssh$ hostname
sala

And just check if it is working ... It should work ...

sala:~/.ssh$ ssh nandi

Otherwise now find the reason for not working. Nothing fully readymade in this world. :)

Sunday, September 14, 2008

How to recover root password of Sun Server ?

















Step−by−Step Procedure



If the system is not halted, then halt the system by pressing Stop−A. This will bring you to the OK prompt.

Place the installation CD−ROM in the CD−ROM drive. Boot the system to single user mode using the CD−ROM drive.

Type : boot cdrom −s ======> If you are booting from -ROM
Type : boot net -s ======> If you are booting from Network Jump Start Server.

( For u need to server configure. That procedure is not included here)


It may take awhile, but you will automatically be logged in as root in single user mode running the OS from the CD−ROM.

1. If you had to force halt the system, by pressing Stop−A for instance, then the partitions on the hard disk will not be marked as being shutdown cleanly. If this happens, run fsck on the root partition. It is used to check and repair the file system. In this case it won't ask for the root password as it is in single
user mode. Type: fsck −y /dev/dsk/c0t3d0s0

2. Now c0t3d0s0 is just the root partition in this example. Verify your boot disk.

4. Remove root's password using your editor and edit /a/etc/shadow. Find root's entry in the file and make the second field null. Colons are the field delimeters. So your entry, after changes, should look something like:

root::10565::::::

Various fields will be used if certain parameters have been set for the OS.

5. Boot to single user mode using the hard disk.

Type: reboot −− −s

Note: That is, reboot space hyphen hyphen space hyphen s.

6.You can log in as root without a password and set root's password using the passwd command.

7. Exit single user mode and let the system continue booting to multi−user mode.

Wednesday, September 10, 2008

How extend soft partition?

Objective :

1. To extend soft partition by keeping data intact.
2. To extend meta partition by keeping data intact

Audience :
Audience of the document should be well aware of Solaris commands. They should have proper knowledge of SVM concept and commands. I am assuming that the users are aware of impact of the commands and for safer side , I recommends to take backup before starting exercise.

Setup :

1. Slice used to meta database c0t0d0s7 and size is 100 Mb
2. c0t0d0s7 is 2.7 GB
3. c0t9d0s0 10 Gb

Steps :

1. Create database

bash-3.00# metadb -f -a -c 3 c0t0d0s7
bash-3.00# metadb
flags first blk block count
a u 16 8192 /dev/dsk/c0t0d0s7
a u 8208 8192 /dev/dsk/c0t0d0s7
a u 16400 8192 /dev/dsk/c0t0d0s7

2. Create meta device d10

bash-3.00# metainit d10 1 1 c0t0d0s4

d10: Concat/Stripe is setup
bash-3.00# metastat
d10: Concat/Stripe
Size: 3986352 blocks (1.9 GB)
Stripe 0:
Device Start Block Dbase Reloc
c0t0d0s4 0 No Yes

Device Relocation Information:
Device Reloc Device ID
c0t0d0 Yes id1,sd@SFUJITSU_MAG3182L_SUN18G_01585615____

3. Create new soft partition

bash-3.00# metainit d31 -p d10 1g
d31: Soft Partition is setup
bash-3.00# metastat
d31: Soft Partition
Device: d10
State: Okay
Size: 2097152 blocks (1.0 GB)
Extent Start Block Block count
0 32 2097152

d10: Concat/Stripe
Size: 3986352 blocks (1.9 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0t0d0s4 0 No Okay Yes

Device Relocation Information:
Device Reloc Device ID
c0t0d0 Yes id1,sd@SFUJITSU_MAG3182L_SUN18G_01585615____

4. Format the newly created soft partition and mount it

# newfs /dev/md/dsk/d31

newfs: construct a new file system /dev/md/rdsk/d31: (y/n)? yes
Warning: 4400 sector(s) in last cylinder unallocated
/dev/md/rdsk/d31: 2097152 sectors in 446 cylinders of 19 tracks, 248 secto
rs
1024.0MB in 28 cyl groups (16 c/g, 36.81MB/g, 17664 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 75680, 151328, 226976, 302624, 378272, 453920, 529568, 605216, 680864,
1361696, 1437344, 1512992, 1588640, 1664288, 1739936, 1815584, 1891232,
1966880, 2042528

bash-3.00# mkdir /test1
bash-3.00# mount /dev/md/dsk/d32 /test1

bash-3.00# df –h /test
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d31 963M 1.0M 904M 1% /test

5. Addition of more space in d10

bash-3.00# metattach d10 c0t9d0s0
d10: component is attached

bash-3.00# metastat
d32: Soft Partition
Device: d10
State: Okay
Size: 1024000 blocks (500 MB)
Extent Start Block Block count
0 2097216 1024000

d10: Concat/Stripe
Size: 39533680 blocks (18 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0t0d0s4 0 No Okay Yes
Stripe 1:
Device Start Block Dbase State Reloc Hot Spare
c0t9d0s0 5080 No Okay Yes

d31: Soft Partition
Device: d10
State: Okay
Size: 2097152 blocks (1.0 GB)
Extent Start Block Block count
0 32 2097152

Device Relocation Information:
Device Reloc Device ID
c0t0d0 Yes id1,sd@SFUJITSU_MAG3182L_SUN18G_01585615____
c0t9d0 Yes id1,sd@x002037fffebcf385


6. Copy some data make partition full so that we can test it late for extension.

bash-3.00# df -h /test
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d31 963M 960M 0K 100% /test


7. Add 2 Gb space in partition d31

bash-3.00# metattach d31 2g
d31: Soft Partition has been grown

bash-3.00# df -h /test
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d31 963M 960M 0K 100% /test

( Please note partition size is still not grown.)

8. Now final step that will make partition grow without destroying data.

bash-3.00# growfs -M /test /dev/md/rdsk/d31
Warning: 3776 sector(s) in last cylinder unallocated
/dev/md/rdsk/d31: 6291456 sectors in 1336 cylinders of 19 tracks, 248 sectors
3072.0MB in 84 cyl groups (16 c/g, 36.81MB/g, 17664 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 75680, 151328, 226976, 302624, 378272, 453920, 529568, 605216, 680864,
5581600, 5657248, 5732896, 5808544, 5884192, 5959840, 6035488, 6111136,
6186784, 6262432

bash-3.00# df -h
Filesystem size used avail capacity Mounted on

/dev/md/dsk/d31 2.8G 962M 1.8G 34% /test

That’s it.

Wednesday, September 3, 2008

Animal Sketches

On one fine Saturday while in UK around Aug 2008 , I was very bored. I took pen ,paper and started drawing animal faces. In the first attempt , I think I made it. It is definately not best but surely not bad also.



Life and relationship


“Life is all about hit & misses".


The same is true for relationships. Some time it works out, Sometimes not.
It hurts & hurts terribly when expectations are belied, when emotions are trampled & you feel ignored & cheated.
The only way to make a relationship work is determination to ensure it works. However Fear of getting hurt can put you off the relationship.
I need a relationship in which I don’t have to keep explaining myself. I'm searching for that relationship in which I can enjoy freedom of trust.
I need a relationship in which I won’t be held up against myself. I have my strengths & I have my weaknesses.
The search is for that one relationship in which my lesser side wont be provoked & instigated constantly.
I want someone who will always relate to my better side.
I want a relationship in which my positives will always be brought to the fore.
I need a relationship in which my today is not viewed with the mistakes I made yesterday.
I need a relationship where tomorrow’s misery isn’t already confirmed, for the mistake i've made today.
As a human I'm bound to err occasionally. I want someone who won’t maintain a database of my mistakes.
The search is for that one relationship where yesterday's fight doesn't intrude into today's intimacy, where yesterday's argument doesn't halt today's communication.
I need a relationship in which it isn't me who has to take initiative all the time. I need a relationship where I can afford to be transparent.
I need a relationship in which I don’t have to alter my likes & dislikes in order to gain & retain the relationship. I need a relationship in which my self image is not scratched.I need a relationship in which I'm not asked to be anyone other that who I am.. what I am. I need a relationship in which I feel completely myself.
I need that one relationship in which I feel as though I am once again in my mother's womb. A relationship in which my heart always feels... just born.

If you already have one such relationship.. please go down on your knees in gratitude, for there cannot be greater gift from life. Such a relationship is life's greatest gift.

(This article is not written by me. I like it so I posted here. Thanks to genius who written this.)

Monday, August 25, 2008

Regret ( Heart touching short story)

I entered a small room of ten by ten in the middle of the slum. An old man was sitting there. The moment he saw me, his eyes sparkled and a smile spread across his face. He stood up and taking my hand in his, said “Please welcome, my child ...“. He started asking eagerly about how I am doing and all about me.



After I became a computer engineer, I went to meet him after quite a long time. He was very old by now. Few years ago, he had taken early retirement and thought about enjoying life. Unfortunately, he got sick and spent most of his money on medical expenses. As his son was not earning anything, he was forced to spend his remaining life in a slum.



He had spent his life very lavishly while he was young. After seeing him, I bowed and touched his feet for blessings. He was so happy while blessing me.



My mind went back fifteen years when I was in first year of college. At that time, my college decided to start graduation in Electronics announcing a fee of 1500/- rupees. As my father was very poor; he could not afford even this fee. I was very sad and as a final resort; had approached the same old man for help. Even he was in a financial crisis at that time; but he helped me because of which I got admission to Electronics. Years passed, I got nice marks and life moved further and finally got good job as a computer engineer.



He was utmost happy to see me. His expressions were enough to tell what was going inside his heart. He was proud of his investment of Rs 1500. After initial chatting, I got some clue that he is in a financial problem. I tried to offer him some money but he was not ready to accept. After lot of efforts, he accepted the small amount. He said that he doesn’t need money and he will manage somehow.



After half an hour, I bade him fare well. He suggested that I come again to meet him. I was so happy that I could help the person who had helped me.



A month passed. One day, a relative of the old man called on my mobile and informed me about the bad news. The old man had committed suicide by throwing himself in front of running train because he didn’t have money to purchase medicine.



I was speechless. My help to the old man was not enough. His money had turned my life but my money could not

Friday, August 22, 2008

Simple start with ZFS

Here is very simple steps to start with zfs


1. Create ZFS filesystem wih single disk.

bash-3.00# zpool create tank c0t9d0s0
invalid vdev specification
use '-f' to override the following errors:
/dev/dsk/c0t9d0s0 contains a ufs filesystem.
/dev/dsk/c0t9d0s0 overlaps with /dev/dsk/c0t9d0s3

If you face above error just add -f option as following.

bash-3.00# zpool create -f tank c0t9d0s0

2. How see zfs details?

Following command shows details of pool fs we just created.

bash-3.00# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
tank 16.9G 83.5K 16.9G 0% ONLINE

3. Now we need to create partitions in it. Let's create 5 Gb parttion.

bash-3.00# zfs set quota=5G tank/vol1
bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
tank 104K 16.6G 25.5K /tank
tank/vol1 24.5K 5.00G 24.5K /tank/vol1

4. How can extend it ?

Very simple. See fire following command.

bash-3.00# zfs set quota=10G tank/vol1

5. Again do zfs list see what is happended.

bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
tank 104K 16.6G 25.5K /tank
tank/vol1 24.5K 10.0G 24.5K /tank/vol1


bash-3.00# df -h
Filesystem size used avail capacity Mounted on

tank 17G 25K 17G 1% /tank
tank/vol1 13G 24K 13G 1% /tank/vol1

bash-3.00#

6. How to see statistics ?

bash-3.00# zpool iostat tank

capacity operations bandwidth
pool used avail read write read write
---------- ----- ----- ----- ----- ----- -----
tank 108K 16.9G 0 0 0 10

7. How to mount zfs partition at your desired mountpoint?

#
# zfs set mountpoint=/export/zfs tank/vol1

Effect will be shown as following if df -h command

tank/vol1 10G 24K 10G 1% /export/zfs


8. Finding zfs status


bash-3.00# zpool status
pool: tank
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
tank ONLINE 0 0 0
c0t9d0s0 ONLINE 0 0 0

errors: No known data errors

=====================================================================================

For further study visit here:

1. http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide
2. http://docs.sun.com/app/docs/doc/819-5461

Friday, August 8, 2008

How to restrict sudo -s or su ?

It is very difficult to restrict sudo -s or su -. After struggling a lot , I found way to restrict it.

I am assuming that you have sudo implementation knowledge.


The Impact of sudo on Unix System Security
1) `sudo` improves on `su` in several ways:
2) `sudo` allows you to give privileged access to only some commands, instead of all commands.
3) `sudo` allows you to log all commands (and their arguments) executed as the privileged user.
4) `sudo` does not require the administrator to share the root password.
5) `sudo` allows you to limit the users who can use it by editing the sudoers file.
6) `sudo` times out after 5 minutes (by default).

Tips:

1. How to restrict sudo -s
If username is user1 then add following configuration in sudoers file

user1 ALL=(root) NOPASSWD:/usr/sbin/a*,(root)NOPASSWD:/usr/sbin/[c-r]*,(root) NOPASSWD:/usr/sbin/[t-z]*,(root) NOPASSWD:/usr/bin/a*,(root) NOPASSWD:/usr/bin/[c-r]*,(root) NOPASSWD:/usr/bin/[tuwxyz]*,(root) NOPASSWD:/bin/a*,(root) NOPASSWD:/bin/[c-r]*,(root) NOPASSWD:/bin/[tuvwxyz]*

Above file

1) Restrict any command in /usr/sbin , /bin and /bin/bin who alphabet starts from b,v,s ( i.e bash,vi,sudo and su etc )
2) It will not ask for password

2) How to log the usage ?

Add following line to sudoers files.

Defaults logfile=/var/adm/sudolog

Monday, July 21, 2008

How to use sed ? Practicle use of sed

1. To find and remove perticular word
sed 's/root/mahendra/g' file1.txt
2. Write the statement to remove '/' from df -k using sed df -k sed 's/\// /g'
3. sed work fine with regular expression df -k sed 's/$/EOL/' -> This will add EOL at the end of line.
4. How to find blank line
sed 's/^$/this used to be a blank line/' file1.txt grep " used t" wc -l
5. . means any character more /var/adm/messagessed 's/Jan .. ..:..:../Jan 2008/g' more
6. The '*' character means "any number of the previous character". This applies both to literal characters and to characters that are a result of using "[]" or '.'. For example, sed 's/ *$//' filename
deletes all trailing spaces from each line, while
sed 's/[ ]*$//' filename
deletes any sequence of trailing tabs and spaces. It also works when using "[^]":
sed 's/[ ][^ ]*$//' filename
deletes the last word (sequence of non-spaces) on each line.
7. It is important to know that '*' will match zero occurences. If you need to match an integer, for example,
sed 's/ [0-9]* / integer /g' filename
will turn " " into " integer ", which is not what you want. In this case, you should use
sed 's/ [0-9][0-9]* / integer /g' filename
which will demand at least one digit.
8. Removing perticuler string.
df -k sed 's/[e-o][mn]/YES/g' This will find all letters ending with m or n and any letter from e to o to their previous position.
9. sed 1d ==> delete row 1 sed 2d ==> delete row 2 sed 1,2d ==> delete row 1,2
-------------------------------------------------------------------------
FILE SPACING:
# double space a file sed G
# double space a file which already has blank lines in it. Output file # should contain no more than one blank line between lines of text. sed '/^$/d;G'
# triple space a file sed 'G;G'
# undo double-spacing (assumes even-numbered lines are always blank) sed 'n;d'
# insert a blank line above every line which matches "regex" sed '/regex/{x;p;x;}'
# insert a blank line below every line which matches "regex" sed '/regex/G'
# insert a blank line above and below every line which matches "regex" sed '/regex/{x;p;x;G;}'
NUMBERING:
# number each line of a file (simple left alignment). Using a tab (see # note on '\t' at end of file) instead of space will preserve margins. sed = filename sed 'N;s/\n/\t/'
# number each line of a file (number on left, right-aligned) sed = filename sed 'N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /'
# number each line of file, but only print numbers if line is not blank sed '/./=' filename sed '/./N; s/\n/ /'
# count lines (emulates "wc -l") sed -n '$='
TEXT CONVERSION AND SUBSTITUTION:
# IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format sed 's/.$//' # assumes that all lines end with CR/LF sed 's/^M$//' # in bash/tcsh, press Ctrl-V then Ctrl-M sed 's/\x0D$//' # gsed 3.02.80, but top script is easier
# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format sed "s/$/`echo -e \\\r`/" # command line under ksh sed 's/$'"/`echo \\\r`/" # command line under bash sed "s/$/`echo \\\r`/" # command line under zsh sed 's/$/\r/' # gsed 3.02.80
# IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format sed "s/$//" # method 1 sed -n p # method 2
# IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format # Can only be done with UnxUtils sed, version 4.0.7 or higher. # Cannot be done with other DOS versions of sed. Use "tr" instead. sed "s/\r//" infile >outfile # UnxUtils sed v4.0.7 or higher tr -d \r outfile # GNU tr version 1.22 or higher
# delete leading whitespace (spaces, tabs) from front of each line # aligns all text flush left sed 's/^[ \t]*//' # see note on '\t' at end of file
# delete trailing whitespace (spaces, tabs) from end of each line sed 's/[ \t]*$//' # see note on '\t' at end of file
# delete BOTH leading and trailing whitespace from each line sed 's/^[ \t]*//;s/[ \t]*$//'
# insert 5 blank spaces at beginning of each line (make page offset) sed 's/^/ /'
# align all text flush right on a 79-column width sed -e :a -e 's/^.\{1,78\}$/ &/;ta' # set at 78 plus 1 space
# center all text in the middle of 79-column width. In method 1, # spaces at the beginning of the line are significant, and trailing # spaces are appended at the end of the line. In method 2, spaces at # the beginning of the line are discarded in centering the line, and # no trailing spaces appear at the end of lines. sed -e :a -e 's/^.\{1,77\}$/ & /;ta' # method 1 sed -e :a -e 's/^.\{1,77\}$/ &/;ta' -e 's/\( *\)\1/\1/' # method 2
# substitute (find and replace) "foo" with "bar" on each line sed 's/foo/bar/' # replaces only 1st instance in a line sed 's/foo/bar/4' # replaces only 4th instance in a line sed 's/foo/bar/g' # replaces ALL instances in a line sed 's/\(.*\)foo\(.*foo\)/\1bar\2/' # replace the next-to-last case sed 's/\(.*\)foo/\1bar/' # replace only the last case
# substitute "foo" with "bar" ONLY for lines which contain "baz" sed '/baz/s/foo/bar/g'
# substitute "foo" with "bar" EXCEPT for lines which contain "baz" sed '/baz/!s/foo/bar/g'
# change "scarlet" or "ruby" or "puce" to "red" sed 's/scarlet/red/g;s/ruby/red/g;s/puce/red/g' # most seds gsed 's/scarlet\ruby\puce/red/g' # GNU sed only
# reverse order of lines (emulates "tac") # bug/feature in HHsed v1.5 causes blank lines to be deleted sed '1!G;h;$!d' # method 1 sed -n '1!G;h;$p' # method 2
# reverse each character on the line (emulates "rev") sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'
# join pairs of lines side-by-side (like "paste") sed '$!N;s/\n/ /'
# if a line ends with a backslash, append the next line to it sed -e :a -e '/\\$/N; s/\\\n//; ta'
# if a line begins with an equal sign, append it to the previous line # and replace the "=" with a single space sed -e :a -e '$!N;s/\n=/ /;ta' -e 'P;D'
# add commas to numeric strings, changing "1234567" to "1,234,567" gsed ':a;s/\B[0-9]\{3\}\>/,&/;ta' # GNU sed sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta' # other seds
# add commas to numbers with decimal points and minus signs (GNU sed) gsed ':a;s/\(^\[^0-9.]\)\([0-9]\+\)\([0-9]\{3\}\)/\1\2,\3/g;ta'
# add a blank line every 5 lines (after lines 5, 10, 15, 20, etc.) gsed '0~5G' # GNU sed only sed 'n;n;n;n;G;' # other seds
SELECTIVE PRINTING OF CERTAIN LINES:
# print first 10 lines of file (emulates behavior of "head") sed 10q
# print first line of file (emulates "head -1") sed q
# print the last 10 lines of a file (emulates "tail") sed -e :a -e '$q;N;11,$D;ba'
# print the last 2 lines of a file (emulates "tail -2") sed '$!N;$!D'
# print the last line of a file (emulates "tail -1") sed '$!d' # method 1 sed -n '$p' # method 2
# print only lines which match regular expression (emulates "grep") sed -n '/regexp/p' # method 1 sed '/regexp/!d' # method 2
# print only lines which do NOT match regexp (emulates "grep -v") sed -n '/regexp/!p' # method 1, corresponds to above sed '/regexp/d' # method 2, simpler syntax
# print the line immediately before a regexp, but not the line # containing the regexp sed -n '/regexp/{g;1!p;};h'
# print the line immediately after a regexp, but not the line # containing the regexp sed -n '/regexp/{n;p;}'
# print 1 line of context before and after regexp, with line number # indicating where the regexp occurred (similar to "grep -A1 -B1") sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h
# grep for AAA and BBB and CCC (in any order) sed '/AAA/!d; /BBB/!d; /CCC/!d'
# grep for AAA and BBB and CCC (in that order) sed '/AAA.*BBB.*CCC/!d'
# grep for AAA or BBB or CCC (emulates "egrep") sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d # most seds gsed '/AAA\BBB\CCC/!d' # GNU sed only
# print paragraph if it contains AAA (blank lines separate paragraphs) # HHsed v1.5 must insert a 'G;' after 'x;' in the next 3 scripts below sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;'
# print paragraph if it contains AAA and BBB and CCC (in any order) sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;/BBB/!d;/CCC/!d'
# print paragraph if it contains AAA or BBB or CCC sed -e '/./{H;$!d;}' -e 'x;/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d gsed '/./{H;$!d;};x;/AAA\BBB\CCC/b;d' # GNU sed only
# print only lines of 65 characters or longer sed -n '/^.\{65\}/p'
# print only lines of less than 65 characters sed -n '/^.\{65\}/!p' # method 1, corresponds to above sed '/^.\{65\}/d' # method 2, simpler syntax
# print section of file from regular expression to end of file sed -n '/regexp/,$p'
# print section of file based on line numbers (lines 8-12, inclusive) sed -n '8,12p' # method 1 sed '8,12!d' # method 2
# print line number 52 sed -n '52p' # method 1 sed '52!d' # method 2 sed '52q;d' # method 3, efficient on large files
# beginning at line 3, print every 7th line gsed -n '3~7p' # GNU sed only sed -n '3,${p;n;n;n;n;n;n;}' # other seds
# print section of file between two regular expressions (inclusive) sed -n '/Iowa/,/Montana/p' # case sensitive
SELECTIVE DELETION OF CERTAIN LINES:
# print all of file EXCEPT section between 2 regular expressions sed '/Iowa/,/Montana/d'
# delete duplicate, consecutive lines from a file (emulates "uniq"). # First line in a set of duplicate lines is kept, rest are deleted. sed '$!N; /^\(.*\)\n\1$/!P; D'
# delete duplicate, nonconsecutive lines from a file. Beware not to # overflow the buffer size of the hold space, or else use GNU sed. sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P'
# delete all lines except duplicate lines (emulates "uniq -d"). sed '$!N; s/^\(.*\)\n\1$/\1/; t; D'
# delete the first 10 lines of a file sed '1,10d'
# delete the last line of a file sed '$d'
# delete the last 2 lines of a file sed 'N;$!P;$!D;$d'
# delete the last 10 lines of a file sed -e :a -e '$d;N;2,10ba' -e 'P;D' # method 1 sed -n -e :a -e '1,10!{P;N;D;};N;ba' # method 2
# delete every 8th line gsed '0~8d' # GNU sed only sed 'n;n;n;n;n;n;n;d;' # other seds
# delete ALL blank lines from a file (same as "grep '.' ") sed '/^$/d' # method 1 sed '/./!d' # method 2
# delete all CONSECUTIVE blank lines from file except the first; also # deletes all blank lines from top and end of file (emulates "cat -s") sed '/./,/^$/!d' # method 1, allows 0 blanks at top, 1 at EOF sed '/^$/N;/\n$/D' # method 2, allows 1 blank at top, 0 at EOF
# delete all CONSECUTIVE blank lines from file except the first 2: sed '/^$/N;/\n$/N;//D'
# delete all leading blank lines at top of file sed '/./,$!d'
# delete all trailing blank lines at end of file sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' # works on all seds sed -e :a -e '/^\n*$/N;/\n$/ba' # ditto, except for gsed 3.02*
# delete the last line of each paragraph sed -n '/^$/{p;h;};/./{x;/./p;}'
SPECIAL APPLICATIONS:
# remove nroff overstrikes (char, backspace) from man pages. The 'echo' # command may need an -e switch if you use Unix System V or bash shell. sed "s/.`echo \\\b`//g" # double quotes required for Unix environment sed 's/.^H//g' # in bash/tcsh, press Ctrl-V and then Ctrl-H sed 's/.\x08//g' # hex expression for sed v1.5
# get Usenet/e-mail message header sed '/^$/q' # deletes everything after first blank line
# get Usenet/e-mail message body sed '1,/^$/d' # deletes everything up to first blank line
# get Subject header, but remove initial "Subject: " portion sed '/^Subject: */!d; s///;q'
# get return address header sed '/^Reply-To:/q; /^From:/h; /./d;g;q'
# parse out the address proper. Pulls out the e-mail address by itself # from the 1-line return address header (see preceding script) sed 's/ *(.*)//; s/>.*//; s/.*[:<] *//'
# add a leading angle bracket and space to each line (quote a message) sed 's/^/> /'
# delete leading angle bracket & space from each line (unquote a message) sed 's/^> //'
# remove most HTML tags (accommodates multiple-line tags) sed -e :a -e 's/<[^>]*>//g;/ # extract multi-part uuencoded binaries, removing extraneous header # info, so that only the uuencoded portion remains. Files passed to # sed must be passed in the proper order. Version 1 can be entered # from the command line; version 2 can be made into an executable # Unix shell script. (Modified from a script by Rahul Dhesi.) sed '/^end/,/^begin/d' file1 file2 ... fileX uudecode # vers. 1 sed '/^end/,/^begin/d' "$@" uudecode # vers. 2
# zip up each .TXT file individually, deleting the source file and # setting the name of each .ZIP file to the basename of the .TXT file # (under DOS: the "dir /b" switch returns bare filenames in all caps). echo @echo off >zipup.bat dir /b *.txt sed "s/^\(.*\)\.TXT/pkzip -mo \1 \1.TXT/" >>zipup.bat
TYPICAL USE: Sed takes one or more editing commands and applies all ofthem, in sequence, to each line of input. After all the commands havebeen applied to the first input line, that line is output and a secondinput line is taken for processing, and the cycle repeats. Thepreceding examples assume that input comes from the standard inputdevice (i.e, the console, normally this will be piped input). One ormore filenames can be appended to the command line if the input doesnot come from stdin. Output is sent to stdout (the screen). Thus:
cat filename sed '10q' # uses piped input sed '10q' filename # same effect, avoids a useless "cat" sed '10q' filename > newfile # redirects output to disk
For additional syntax instructions, including the way to apply editingcommands from a disk file instead of the command line, consult "sed &awk, 2nd Edition," by Dale Dougherty and Arnold Robbins (O'Reilly,1997; http://www.ora.com), "UNIX Text Processing," by Dale Doughertyand Tim O'Reilly (Hayden Books, 1987) or the tutorials by Mike Arstdistributed in U-SEDIT2.ZIP (many sites). To fully exploit the powerof sed, one must understand "regular expressions." For this, see"Mastering Regular Expressions" by Jeffrey Friedl (O'Reilly, 1997).The manual ("man") pages on Unix systems may be helpful (try "mansed", "man regexp", or the subsection on regular expressions in "maned"), but man pages are notoriously difficult. They are not written toteach sed use or regexps to first-time users, but as a reference textfor those already acquainted with these tools.
QUOTING SYNTAX: The preceding examples use single quotes ('...')instead of double quotes ("...") to enclose editing commands, sincesed is typically used on a Unix platform. Single quotes prevent theUnix shell from intrepreting the dollar sign ($) and backquotes(`...`), which are expanded by the shell if they are enclosed indouble quotes. Users of the "csh" shell and derivatives will also needto quote the exclamation mark (!) with the backslash (i.e., \!) toproperly run the examples listed above, even within single quotes.Versions of sed written for DOS invariably require double quotes("...") instead of single quotes to enclose editing commands.
USE OF '\t' IN SED SCRIPTS: For clarity in documentation, we have usedthe expression '\t' to indicate a tab character (0x09) in the scripts.However, most versions of sed do not recognize the '\t' abbreviation,so when typing these scripts from the command line, you should pressthe TAB key instead. '\t' is supported as a regular expressionmetacharacter in awk, perl, and HHsed, sedmod, and GNU sed v3.02.80.
VERSIONS OF SED: Versions of sed do differ, and some slight syntaxvariation is to be expected. In particular, most do not support theuse of labels (:name) or branch instructions (b,t) within editingcommands, except at the end of those commands. We have used the syntaxwhich will be portable to most users of sed, even though the popularGNU versions of sed allow a more succinct syntax. When the reader seesa fairly long command such as this:
sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d
it is heartening to know that GNU sed will let you reduce it to:
sed '/AAA/b;/BBB/b;/CCC/b;d' # or even sed '/AAA\BBB\CCC/b;d'
In addition, remember that while many versions of sed accept a commandlike "/one/ s/RE1/RE2/", some do NOT allow "/one/! s/RE1/RE2/", whichcontains space before the 's'. Omit the space when typing the command.
OPTIMIZING FOR SPEED: If execution speed needs to be increased (due tolarge input files or slow processors or hard disks), substitution willbe executed more quickly if the "find" expression is specified beforegiving the "s/.../.../" instruction. Thus:
sed 's/foo/bar/g' filename # standard replace command sed '/foo/ s/foo/bar/g' filename # executes more quickly sed '/foo/ s//bar/g' filename # shorthand sed syntax
On line selection or deletion in which you only need to output linesfrom the first part of the file, a "quit" command (q) in the scriptwill drastically reduce processing time for large files. Thus:
sed -n '45,50p' filename # print line nos. 45-50 of a file sed -n '51q;45,50p' filename # same, but executes much faster
If you have any additional scripts to contribute or if you find errorsin this document, please send e-mail to the compiler. Indicate theversion of sed you used, the operating system it was compiled for, andthe nature of the problem. Various scripts in this file were writtenor contributed by:
Al Aab <af137@freenet.toronto.on.ca> # "seders" list moderator Edgar Allen <era@sky.net> # various Yiorgos Adamopoulos <adamo@softlab.ece.ntua.gr> Dale Dougherty <dale@songline.com> # author of "sed & awk" Carlos Duarte <cdua@algos.inesc.pt> # author of "do it with sed" Eric Pement <pemente@northpark.edu> # author of this document Ken Pizzini <ken@halcyon.com> # author of GNU sed v3.02 S.G. Ravenhall <stew.ravenhall@totalise.co.uk> # great de-html script Greg Ubben <gsu@romulus.ncsc.mil> # many contributions & much help-------------------------------------------------------------------------

The combination ".*" means any number of any character. So, sed 's/col.*lapse/collapse/g' filename
will act on any line which contains the letters "col" and then "lapse", no matter what is in between. The '*' character is greedy: it takes as many characters as it can. So, the above script would turn
a b col d e f lapse h i j k lapse m n
into a b collapse m n
instead of a b collapse h i j k lapse m n
back to the top Substitution and SavingUp to this point, we have concentrated on deleting things that we match with "[]" and '.'. That's because we had no way of saving what we matched. The "\(" and "\)" operators will save whatever is found between them. Notice that these parentheses must be preceded by a backslash, while the characters ^$[].*\ don't need a backslash to act in a non-literal fashion. The first pair of "\(\)" saves into a place called "\1", and the second pair into "\2", and so on. sed 's/^\([A-Z][A-Za-z]*\), \([A-Z][A-Za-z]*\)/\2 \1/' filename
will turn "Lastname, Firstname" into "Firstname Lastname". Notice how the comma is placed outside the first pair of "\(\)" so it doesn't get inclued in the last name. Otherwise, the result would be "Firstname Lastname,".
Sometimes you will want to apply a substitution only to lines that meet some criteria that you can't specify in the string to be replaced. You do this using something called an "address". It comes before the "s" command. You can limit the command to a range of lines:
sed '1,20s/foobar/fubar/g' filename
The line count is cumulative across files, and starts at 1.
You might want to apply a change only to lines that contain a string:
sed '/^Aug/s/Mon /Monday /g' filename
Or to lines that don't contain a string:
using sh or ksh or bash,
sed '/^Aug/!s/Mon /Monday /g' filename
using csh or tcsh,
sed '/^Aug/\!s/Mon /Monday /g' filename
You can also apply the command to all lines between (and including) a start string and a stop string: sed '/^Aug/,/^Oct/s/Mon /Monday /g' filename
Normally sed reads a line, processes it, and prints it out. If you only want to see the lines that your command acted upon, then you don't want it to print out everyting. The "-n" flag will stop sed from printing after processing. So,
sed -n 's/fubar/foobar/g' filename
will print nothing at all. You must use the 'p' flag to the 's' command to make it print out what it has processed:
sed -n 's/fubar/foobar/gp' filename
Sed from a fileIf your sed script is getting long, you can put it into a file, like so: # This file is named "sample.sed" # comments can only appear in a block at the beginning s/color/colour/g s/flavor/flavour/g s/theater/theatre/g
Then call sed with the "-f" flag: sed -f sample.sed filename
Or, you can make an executable sed script:
#!/usr/bin/sed -f # This file is named "sample2.sed" s/color/colour/g s/flavor/flavour/g s/theater/theatre/g
then give it execute permissions: chmod u+x sample2.sed
and then call it like so:
./sample2.sed filename