Operating System - HP-UX
1832957 Members
2387 Online
110048 Solutions
New Discussion

Re: Favorite Little used commands

 
MarkSyder
Honored Contributor

Re: Favorite Little used commands

To return to the last directory you were working in:

cd -

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Chris Wilshaw
Honored Contributor

Re: Favorite Little used commands

fold : very useful when report don't line-wrap properly on your printer

dumpmsg : use with the files in /usr/lib/nls/C to get exit codes etc for some commands.

od : it may be a bit of a headache at times, but od -c can occasionally get you more info on a non-text file than strings.

which/whence : helpful if you want to know where you're running things from.

adjust : basic text formatting.

dirname/basename : path/file details - useful in scripts.

line : like read, but with a timeout.
Bill Hassell
Honored Contributor

Re: Favorite Little used commands

Some favorites by category:

Listing binary or special characters:
--
- xd (better than od which is octal), the best listing option (looks like a mainfram dump) is: xd -xc
- cat -v (quicky to show special chars)
- ll -b (see special chars in a filename)

What did the shell run? which and whereis are deprecated (I love that word) as far as determining exactly what will happen when you type a command. whereis looks in common places but overlooks /opt and /sbin completely. which looks in the current PATH but knows nothing about shell builtins. The best command is type which is an alias to whence -v. If you type pwd, you are not seeing what which and whereis are reporting. pwd is first a built-in and it produces a different result from /usr/bin/pwd.

# cd /usr/spool/lp
# pwd
/usr/spool/lp

# /usr/bin/pwd
/var/spool/lp

# whereis pwd
pwd: /usr/bin/pwd /usr/share/man/man1.Z/pwd.1
# which pwd
/usr/bin/pwd
# type pwd
pwd is a shell builtin.

So you can see that which and whereis are giving differnt results than type (whence -v) and most important: /usr/bin/pwd gives the true PWD while the shell built-in just reports on $PWD.

Another example is aliases:

# which rm
/usr/bin/rm
# whereis rm
rm: /sbin/rm /usr/bin/rm /usr/share/man/man1.Z/rm.1
# type rm
rm is an alias for /usr/bin/rm -i

And just to emphasize that the shell determines what will happen:

# which let
let:

# whereis let
no let in /usr/bin /usr/ccs/bin /usr/contrib/bin /opt/mx/bin /opt/hparray/bin /opt/nettladm/bin /opt/upgrade/bin /opt/fcms/bin /opt/resmon/bin /opt/pd/bin /usr/bin/X11 /usr/contrib/bin/X11 /opt/scr/bin /opt/perf/bin //opt/perl/bin /opt/prm/bin /usr/sbin/diag/contrib /opt/wlm/bin /opt/ignite/bin /opt/hpnpl//bin /opt/graphics/common/bin /opt/sec_mgmt/spc/bin /opt/sec_mgmt/bastille/bin /sbin /usr/sbin

# type let
let is a shell builtin.

Shell math
---

$(( math stuff ))
expr math-stuff
let

Of the above, let seems to be the most intuitive with expr fairly cryptic and $(( )) similarly tricky to use. And since the shells do not know anything about fractions (integer only), the tool of choice is bc:

# echo "scale=4 \n 25.4/36.6" | bc
.6939


Bill Hassell, sysadmin
Mark Greene_1
Honored Contributor

Re: Favorite Little used commands

In addition to much of what has been mentioned, I often use the following:

"select" for building instant menus of dynamic length

"deroff" and "fold" on systems where printing a man page is a bit challenging; i.e., man pwd|deroff|fold|lp -d [printer]

"case" when I'm shell scripting and I've got more than two options which makes using "if" combersome quickly

'exec 1>[filename]' to reroute standard out inside a shell script.

'while read -u4 VARIABLE; do' to read from standard input directly to a variable

"banner" from back in the day when a printer was a 132 column printronix or other similar impact printer

"at" for testing processes I want to put into cron without having to edit the crontab multiple times

"look" in combination with "sort" for locating strings in large files, especially files with line-lengths larger than vi likes to deal with

"od" to peak into binary files

and "make", which I want to use more often so I can learn it better, but unfortunately seldom have enough data and script or program files to justify the effort to build a makefile.

mark
the future will be a lot like now, only later
Cole L.
Advisor

Re: Favorite Little used commands

Did not see this listed

cpio is useful with find and other things...

find . -depth -print | cpio -dumpvA /dest/path

pslp
Chris Watkins_1
Respected Contributor

Re: Favorite Little used commands

One of my favorites that I see used rarely is:
leave

Not without 2 backups and an Ignite image!
Chris Vail
Honored Contributor

Re: Favorite Little used commands

Yo Jeff.....

Thats "Coneheads" not "pointyheads". At least get the planet right ....



Chris
James Brand
Frequent Advisor

Re: Favorite Little used commands

Todd,

Not thread related but didn't know how else to contact you. I saw you had posted a while ago on an LVM striping question and that you were doing so on EMC. We also will be using EMC striped on the back end (meta volumes) and hardware mirrored. EMC is telling us to user LVM striping at the OS level but I'm not sold on the idea. I've read on the ITRC that this is beneficial if your data is sequential, most of ours is not. EMC has given us bad info in the past, what are your impressions of LVM striping on EMC disks?

Thanks,
Jim Brand
Union Pacific RR
St. Louis, MO
Geoff Wild
Honored Contributor

Re: Favorite Little used commands

I use this to get the sendmail version on my hosts - it's almost a script - but it is a fav and not used too often:

echo \$Z | /usr/sbin/sendmail -bt -d


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Todd McDaniel_1
Honored Contributor

Re: Favorite Little used commands

James Brand,

I dont see any reason to fret over striping... My EMC storage is h/w mirrored on the backend and I stripe it on the host side.

My data is not sequential, to the best of my knowledge with a >1TB DB for production. it is spread out over at least 15-27 filesystems of 70GB each, room is left for growth of course. Total of 1.9TB for production about 1.2 is actually used.

My systems are exclusively striped for Oracle DBs... with 128mb stripe size. I also use the advanced caching, largefiles, and delaylog for my filesystem definitions.

------------------------------------------------------
delaylog,largefiles,nodatainlog,mincache=direct,convosync=direct
------------------------------------------------------


We used to have raw DB spaces waaay back when, but when we went to mounted DBs. We chose to do striping for faster readability. Sure we suffer a bit on writes, but resposiveness of the DB is of higher importance.

I have over 6TB of total space dedicated to my DBS on production/test/development boxes. and I will be adding another 5TB for future growth. All of that will be striped.

Someone else may have issues with striping, but not me. Mine is a very mature DB, which we have been running since May 2002 on my 48-way Superdome.



PS: Of course, I have my disks spread out across several HBAs with dual pathing and Powerpath as well. So that will make a difference on I/O bandwidth.

What issues have you heard about?
Unix, the other white meat.
Geoff Wild
Honored Contributor

Re: Favorite Little used commands

As far as striping goes - we stripe on the EMC side - NOT LVM. Our frames (DMX 1000's)are wide - 105 disks - and mirrored/striped.

We are also now implementing PowerPath - instead of manually load balancing at the LVM level.

Whatever you do - do NOT allow EMC to sell you on Parity RAID - performance just plain sucks on it...

Mirroring/striping is only way to go :)

My 2 cents.

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
James Brand
Frequent Advisor

Re: Favorite Little used commands

Todd,

Actually I believe that Oracle had recommended against it several years ago when we were configuring some new servers. Not quite sure why. Other than that just what I mentioned about striping being more beneficial with sequential data, which I got from a rather old document on the ITRC:

http://www2.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000062686228

Glad to see you are having no problems. Sounds like your configuration is similar to ours except we are using rp's instead of superdomes. And yes, we also quit using raw space years ago.

Jim
Todd McDaniel_1
Honored Contributor

Re: Favorite Little used commands

I think our lastest greatest hardware helps too. I think back then the i/o was limited and by older slower cpus and older h/w like Kboxes... of course they were fast back then.

Now with our faster network, 100FD from my host, extremely fast CPU(875), using SD/RPs, and faster HBAs, switches, et al. I think it is more reasonable now than it used to be

My total env for DB are 1 SD, 2 Keystones, 3 Nclass and 5 N-class for my web-tier, no DB on them.
Unix, the other white meat.
Gary L. Paveza, Jr.
Trusted Contributor

Re: Favorite Little used commands

I personally like patch. A lot of people use diff to compare files, but if you redirect the diff output to a file, you actually create a file that you can then use patch with to patch your original file with the patch to create the new file. Very handy. You only need to distribute (or store) the diff (patch) file.
Laurent Menase
Honored Contributor

Re: Favorite Little used commands

You said:
getconf HW_CPU_SUPP_BITS

## This tells you whether you are running 32 or 64 bit OS. There are a plethora of criteria in the man page.

$$ NO it is what your hardware is capable.
For newer platform it is the same as
getconf KERNEL_BITS

Just try on a narrow kernel on a D380 for instance:
# getconf HW_CPU_SUPP_BITS
32/64
# getconf KERNEL_BITS
32
On a Wide K460:
# getconf HW_CPU_SUPP_BITS
32/64
# getconf KERNEL_BITS
64
On a L class
# getconf HW_CPU_SUPP_BITS
64


Else for the usefull commands:
adb to modify any binary file, modify kernel
as a simple calculator (Hex, octal, dec)
to search a patern in a file

strings -a display every strings from an
object or executable file
what
Laurent Menase
Honored Contributor

Re: Favorite Little used commands

Some shell things:

the coprocess:
for instance open a socket on a port in shell
(posix or ksh)
telnet |&
exec 4>&p 3<&p
echo open targetsystem targetport >&4
while read a
do
echo $a
done <&3 &
echo "^]" >&4
echo "close" >&4

Naveej.K.A
Honored Contributor

Re: Favorite Little used commands

last
lastb

both indicate last logins of users and ttys

fuser - list and kill processes.

finger - gives information of a login(user) in the system

With Best Wishes
Naveej
practice makes a man perfect!!!
lawrenzo
Trusted Contributor

Re: Favorite Little used commands

a few more:

nslookup
traceroute
history
umask
uname -a
strings
elm
pg

the list goes on
hello
Elmar P. Kolkman
Honored Contributor

Re: Favorite Little used commands

Nice commands I rarely use:
pax - reads/writes files in tar AND cpio format. Really handy if you don't know what someone gave you. And pax has a nice syntax if you need to copy directory structures across filesystems.

nl - mentioned before, handy to use in combination with other commands.

/usr/bin/cd - I never knew it existed till the recent post, but still think it can come in handy

fold and pr - can come in handy for printing, but also viewing files with long lines. They get truncated on blanks.

troff - especially for printing manual pages in a nice format: troff -man /usr/man/man1/ls.1 | lp (for instance).

Problem with this thread is of course to remember the commands even though you use them little... And nice commands you use often should not be mentioned, like the 'cut' command, which I use very often. Or the '!!' command in vi:
!!env | grep ^PATH
replaces the current line with your current PATH setting in the file you're editting... Very handy for cron scripts...

Just some things that came to my mind...
Every problem has at least one solution. Only some solutions are harder to find.
Jdamian
Respected Contributor

Re: Favorite Little used commands

rmnl and ssp
adjust
fold
getip
vis and inv

Re: Favorite Little used commands

Everyone loves command line history functions in the POSIX and Korn shells (escape k). But did you know you can use it in many other interactive command line environments by using the 'ied' command - just stick ied in front of the command you want to run - here's some examples:

ied ftp

ied sqlplus

ied cstm

etc...

I am an HPE Employee
Accept or Kudo
Ernesto Cappello
Trusted Contributor

Re: Favorite Little used commands

Hi ...

export DISPLAY=name_client:0.0
resize
bdf
ls -al
find . -name *text*
elm
rm rf name_dir

etc etc


Regards Ernesto
Keith Bevan_1
Trusted Contributor

Re: Favorite Little used commands

Hi,

print_manifest - ignite tape_recovery &
system information

diff - for comparing two files

tr - translating characters
from string to string

pwck - integrity of passwd file
grpck - integrity of group file

Keith

You are either part of the solution or part of the problem