1837526 Members
3498 Online
110117 Solutions
New Discussion

Tips & Tricks

 
SOLVED
Go to solution
U.SivaKumar_2
Honored Contributor

Tips & Tricks

Hi all ,

Unix is a thrilling experience and everyday we discover new tips and tricks for problem solving.

Please post your discoveries here, for they shall throw light for others and reach eternity.

regards,
U.SivaKumar

"Expert is one who learns more and more about less and less" - forgot author's name :-)


Innovations are made when conventions are broken
11 REPLIES 11
Ravi_8
Honored Contributor
Solution

Re: Tips & Tricks

Hi,

last week we had a build to be performed by our developement team on Tru64 V5.0(particularly)

In our lab we have implemented AFS, we are not using NIS due to security reasons.

There is no AFS client s/w for Tru64 5.0
It was a tough task thrown to me. I had installed AFS client s/w for Tru64 v5.1 on Tru64 v 5.0. I could start AFS daemons and able to mount AFS directories, but no users are not able to authenticate using AFS id.

After a long R&D with AFS server and Tru64 i came to a conclusion to craete local users and simulate usesr AFS home directories.
for this in usesr profile file we need to add two lines

klog -password
cd /

(klog will authenticate user to AFS server)
this solved my problem.

This soultion is implemented across all our Labs at UK and US

( In fact i got appreciation for this)
never give up
Stefan Farrelly
Honored Contributor

Re: Tips & Tricks

Got a nice little program here (attached)from someone on the itrc a while back. It basically can be used as a benchmark program. Run it as;
time ./string
where number is something like 1000000

Gives you a time in seconds for it to do the 1000000 string manipulations and when you run it on different cpu speed servers, or different flavours of unix you get a nice benchmark. One thing to note - linux runs this a lot faster (on same speed intel cpu) than HP-UX - and any cpu with level3 cache (Mac OS X or Xeon processors) runs it tons faster!

vert interesting.
Im from Palmerston North, New Zealand, but somehow ended up in London...
H.Merijn Brand (procura
Honored Contributor

Re: Tips & Tricks

Stefan, there's a very good perl module for that: Benchmark. It's a core module, so all perl distributions have it. Invaluable for time related tasks. It has options to run a tast as X times, or run a task for minimal X cpu seconds.

Now for the tips-n-tricks, I posted a script a few days ago, that shows about everything asked in the FAQ in one single line. I've attached the greatly improved version here. Optimizations can still be done (e.g. use options to uname instead of uname -a)

It gives me great insight in what systems my customers have, because they often don't even know themselves. [ On HP-UX you need root permission to get *all* info ]
Enjoy, Have FUN! H.Merijn
Stefan Farrelly
Honored Contributor

Re: Tips & Tricks

Hi Procura,

trying this perl benchmark module but keep getting an error about a later version of benchmark needed. Even after I downloaded and tried your Perl 5.8.0 same problem;

Benchmark 3 required--this is only version 1.04 (/opt/perl/lib/5.8.0/Benchmark.pm) at /usr/local/bin/b.pl line 3

Where can I get Benchmark 3 ?
Im from Palmerston North, New Zealand, but somehow ended up in London...
Chris Wilshaw
Honored Contributor

Re: Tips & Tricks

I wonder if there's enough disk space left for everyone to post everything that they've managed to learn

For myself, this is a small subset of what I've picked up from the Forums since signing up last year (in no particular order)

- various little tweaks to scripting, increasing my sed/awk skills. Too numerous to cover in depth.

- the usage of the -k option on lvreduce (only had to use it once [SO FAR], but it saved me a lot of pain)

- the introduction to perl!! I have to admit that I've only played around with it so far, but I can see the potential in there.

- the telnetd options of -TCP_DELAY, or -s/-z used in combination. This fixed a major performance issue that we had when we started upgrading to HP-UX 11


One suggestion I would offer to others - set up a text document on your Windoze desktop, and just paste anything into it that you see on the Forums and other sources that you think is useful/interesting. I've done this for quite some time (starting in my pre-forums days), and you quite quickly build up a repository of valuable information (that's available even when you can't get onto the web).
H.Merijn Brand (procura
Honored Contributor

Re: Tips & Tricks

Hmmm, did it find an old version in `the other' perl installation?

Here's my example script:

--8<--- bench.pl
use Benchmark;
$string = $string = 'all that glitters ';
timethese (-0.40, {
'cont' => ' $foo = $string; ',
'plus' => '($foo = $string) =~ s/\s+$//; ',
'star' => '($foo = $string) =~ s/\s*$//; ',
'^pls' => '($foo = $string) =~ s/^(.*)\s+$//; ',
'^str' => '($foo = $string) =~ s/^(.*)\s*$//; ',
'^*?+' => '($foo = $string) =~ s/^(.*?)\s+$/$1/; ',
'^*?*' => '($foo = $string) =~ s/^(.*?)\s*$/$1/; ',
});
timethese (50_000, {
'cont' => ' $foo = $string; ',
'plus' => '($foo = $string) =~ s/\s+$//; ',
'star' => '($foo = $string) =~ s/\s*$//; ',
'^pls' => '($foo = $string) =~ s/^(.*)\s+$//; ',
'^str' => '($foo = $string) =~ s/^(.*)\s*$//; ',
'^*?+' => '($foo = $string) =~ s/^(.*?)\s+$/$1/; ',
'^*?*' => '($foo = $string) =~ s/^(.*?)\s*$/$1/; ',
});
-->8---

And it's output:

Benchmark: running ^*?*, ^*?+, ^pls, ^str, cont, plus, star for at least 0.4 CPU seconds...
^*?*: 1 wallclock secs ( 0.42 usr + 0.00 sys = 0.42 CPU) @ 27304.76/s (n=11468)
^*?+: 1 wallclock secs ( 0.41 usr + 0.00 sys = 0.41 CPU) @ 32275.61/s (n=13233)
^pls: 0 wallclock secs ( 0.46 usr + 0.00 sys = 0.46 CPU) @ 93493.48/s (n=43007)
^str: 2 wallclock secs ( 0.43 usr + 0.00 sys = 0.43 CPU) @ 100016.28/s (n=43007)
cont: 3 wallclock secs ( 0.43 usr + 0.00 sys = 0.43 CPU) @ 800146.51/s (n=344063)
plus: 1 wallclock secs ( 0.43 usr + 0.00 sys = 0.43 CPU) @ 168451.16/s (n=72434)
star: -1 wallclock secs ( 0.44 usr + 0.00 sys = 0.44 CPU) @ 60150.00/s (n=26466)
Benchmark: timing 50000 iterations of ^*?*, ^*?+, ^pls, ^str, cont, plus, star...
^*?*: 3 wallclock secs ( 1.84 usr + 0.00 sys = 1.84 CPU) @ 27173.91/s (n=50000)
^*?+: 3 wallclock secs ( 1.60 usr + 0.00 sys = 1.60 CPU) @ 31250.00/s (n=50000)
^pls: 1 wallclock secs ( 0.53 usr + 0.00 sys = 0.53 CPU) @ 94339.62/s (n=50000)
^str: 1 wallclock secs ( 0.50 usr + 0.00 sys = 0.50 CPU) @ 100000.00/s (n=50000)
cont: 0 wallclock secs ( 0.06 usr + 0.00 sys = 0.06 CPU) @ 833333.33/s (n=50000)
(warning: too few iterations for a reliable count)
plus: 1 wallclock secs ( 0.30 usr + 0.01 sys = 0.31 CPU) @ 161290.32/s (n=50000)
(warning: too few iterations for a reliable count)
star: 2 wallclock secs ( 0.84 usr + 0.00 sys = 0.84 CPU) @ 59523.81/s (n=50000)


l1:/pro/3gl/CPAN 128 > grep VERSION /pro/lib/perl5/*/Benchmark.pm
/pro/lib/perl5/5.6.1/Benchmark.pm:$VERSION = 1.00;
/pro/lib/perl5/5.8.0/Benchmark.pm:$VERSION = 1.04;
/pro/lib/perl5/5.9.0/Benchmark.pm:$VERSION = 1.0501;
l1:/pro/3gl/CPAN 129 >

Did you (by accident) do something like:

use Benchmark 3;

which would require Benchmark version 3 :)
Enjoy, Have FUN! H.Merijn
Stefan Farrelly
Honored Contributor

Re: Tips & Tricks

Thanks Procura,

your example works fine. I was using the example from the manpage which caused the error.

Cheers,

Stefan
Im from Palmerston North, New Zealand, but somehow ended up in London...
Pete Randall
Outstanding Contributor

Re: Tips & Tricks

The "one" most useful thing I've picked up from the Forums would have to be the -s option of vgexport/vgimport.

Pete

"Reality is just an illusion, albeit a rather persistent one"

Albert Einstein

Pete
H.Merijn Brand (procura
Honored Contributor

Re: Tips & Tricks

FYI

?? FAQ script now available on https://www.beepz.com/personal/merijn/ or http://www.cmve.net/~merijn/
?? HP FAQ page is alive again (http://faqs.org/faqs/hp/hpux-faq/)
Enjoy, Have FUN! H.Merijn
Shannon Petry
Honored Contributor

Re: Tips & Tricks

Some of the tips/tricks I teach people are more basic.

I.E. I use a functions file on all systems, and have added many other functions to it. By pre-building things, it is a huge shortcut, and saves re-inventing the wheel.

Command monitoring:
Many times using commands you will run them repeatedly to either monitor the system, or to reproduce errors.

Loop in ksh/POSIX/sh
set -i
I=1
while [ $I -lt 2 ] ; do

done

Loop in csh
set I=1
while ( $I < 2 )

end

Alot of sysadmins dont realize you can fill these loops with all kinds of goodies.

Checking for empty AND non-existant variables can be a pain in the butt on some OS's. To check for these variables, use a descriptive attachment which catches both.

if [ "${somevar}x" = "x" ] ; then
echo "it's empty or not set"
fi


One of the biggest things I teach people is that most Unices are very much alike. I.E. HP-UX uses /sbin/init.d for boot/init scripts. This is also true for Irix. Solaris, and Linux use /etc/init.d. Other than the directory difference, the scripts work just the same.

In my opinion, the more you can use UNIX and not a "SAM", "Smit", "Admintool", etc.. the more you can walk to another type of Unix and do a job. You will always be specialized in 1 or 2 flavors, but Admins should be able to perform basic tasts in any Unix.

I.E. use "useradd" over Sam. While Solaris uses a shadow file, and does things a bit differently "useradd" works as it should on any Unix.



Regards,
Shannon

ps. Steffan, you made the comment that linux runs your program faster. This will be true for most non-floating point operations, of which string manipulation is. RISC shines most brightly in I/O performance, Floating point, and Multitasking.
Microsoft. When do you want a virus today?
Steven E. Protter
Exalted Contributor

Re: Tips & Tricks

Eternity what a concept.

I have found two problem solving techniques quite useful. One is the search itrc forums for the error message method. I used it twice yesterday to refresh my memory on how to use some commands I use only once or twice a year.

The second is what I call "playing computer"

That involves getting away from the computer and mapping out how a complex process works. How does the system do the job. You sometimes need to look at scripts for reference, but it helps fill in the gaps.

Example: We couldn't figure out why a connection via a wan was dropping out during the middle of the day.

Everybody else was staying connected to our system so we knew it was solid. So we got in a room with a whiteboard and basically pretended to be an IP packet. We did a virtual traceroute and someone in Network administration pointed out we were missing a step.

An old, forgotten Cisco router that hadn't had an ios update in four or five years. We also discovered that that very same router was not on an unprotected circuit and was suffering low voltage when some part of the external LAN's heating and cooling plant kicked on.

The router was replaced, put on a UPS and the problem went away.

P
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com