Operating System - HP-UX
1833294 Members
2903 Online
110051 Solutions
New Discussion

Re: Favorite Little used commands

 
Todd McDaniel_1
Honored Contributor

Favorite Little used commands

Okay, I have run across a few commands that I have never used, but are very useful.

My goal on this thread is to post those commands which are little used but can be very useful... I will get us started.

Comparing files... ## All very nice for manipulating files with data.

diff
cmp
comm
uniq

-----------------------------------------------
getconf a VERY nice little command to pull data from your system...

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.

"vacation" is a great fun little one as well as "cal"

Good answers get 5 points... please only post once if possible.
Unix, the other white meat.
47 REPLIES 47
Sridhar Bhaskarla
Honored Contributor

Re: Favorite Little used commands

Hi,

Really 'comm' is a useful command that got me into mess yesterday because I used it so few times that I forgot it's syntax and misinterpreted the man page :-).

Some of the useful but seldom used commands are

xargs
basename
bdiff
dirname
tput
jobs

etc

Can really save a lot of scripting time.

However, this is dependent on each person. My little commands may be heavily used by others.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Chris Vail
Honored Contributor

Re: Favorite Little used commands

My favorite little-used command is sort. In system without Glance Plus, I use "ps -ef|sort -k 4nr,4|pg " to tell me which processes are using the most CPU resources. This is especially nice because these commands are all cross-platform--they work on HPUX, Solaris, FreeBSD, etc...

I also use pr a lot. A lot of older System V computers do not have the "wc" command, but they do have pr. So "cat FILE|pr -n -t|tail -1| awk '{ print $1 }'" does the same thing as "wc -l" but for only a gazillion more CPU clock cycles.

This command is also handy for numbering printed output: "pr -n FILE |lpr -d DESTINATION" give you a nicely formatted hardcopy output of your 200 line shell scripts.

Chris
Jeff Schussele
Honored Contributor

Re: Favorite Little used commands

Hi Chris,

I use them infrequently but split & csplit are nice little commands to break up huge files (logs?) into more manageable sizes. Saves a heck of a lot of coding. But Merijn could probably do a one-liner in a coupe of seconds...

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
RAC_1
Honored Contributor

Re: Favorite Little used commands

nl
rmnl
printf
type-shell in built command
resize
tput
strings
There is no substitute to HARDWORK
Robert Kerr
Advisor

Re: Favorite Little used commands

A couple nifty ones I use once in a while are tr & paste.
Mark Grant
Honored Contributor

Re: Favorite Little used commands

I like "expr" partly because nobody but me ever uses it and partly because it does completely different things depending on how you use it. E.g get substrings from strings or doing maths. Also, it makes maths portable to any variation of the bourne shell which is more than can be said of the "((.....))" syntax.

Another nice one is "units" partly because you can find out how many centimeters there are in light year but also because you can convert gallons to degree centigrade!

Special mention goes to "lint" but only because the man page used to be titled "removes bits of fluff from C programs"

Perhaps "file" is good too, particularly if you start playing with /etc/magic

Best unix command of all time, however, is "nethack"
Never preceed any demonstration with anything more predictive than "watch this"
Steven E. Protter
Exalted Contributor

Re: Favorite Little used commands

I see netstat -an and -rn used many times.

When I'm trying to get a look at traffic flow i use netstat -i 2

I rarely see it used or recommended.

2 is the 2 from lan2

SEP
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
Kent Ostby
Honored Contributor

Re: Favorite Little used commands

I use:

file
On executables, it will let you know if its 64-bit (including the kernel)

fold
fold -b -w 60 makes those editor files wrap nicely for email.

awk
I work with customers who can't boot systems past single user mode and who can't mount /usr. awk will allow you to do a lot of the functions of grep and sed (at least on a small scale) with a certain amount of ease.

Best regards,

Kent M. Ostby
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
sinhass
Regular Advisor

Re: Favorite Little used commands

modprpw
getprpw
tsconvert
Jeff Schussele
Honored Contributor

Re: Favorite Little used commands

Whoops - sorry...

Hi Todd,

Guess I didn't scroll up far enough when I checked the name. Ah heck - you purple pointy heads all look alike anyway ;~)) Or maybe I just need glasses 8^))

Cheers,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Leif Halvarsson_2
Honored Contributor

Re: Favorite Little used commands

Hi,
The command "join" is perhaps little known but very useful for scripting. It matches filds from two files and print out selected fields from both files. In difference to may other commands it also works in "one to many" relations.
Bill Hassell
Honored Contributor

Re: Favorite Little used commands

Just a note on some commands: they are not in the typical path and may not have a man page on your version of HP-UX. Specifically, modprpw, getprpw and tsconvert are located in /usr/lbin. And as has been mentioned here in the Forums before, the "lbin" directory contains undocumented commands that may change or even disappear. Luckily, there are man pages for modprpw and getprpw at 11.11 (and also found in docs.hp.com).

A similar useful command is usermod.sam which is in /usr/sam/lbin.

Here's a word processing command: adjust
Unlike fold which simply breaks at a column, adjust will break between words. I use adjust in vi to align paragraphs. Type this command:

!}exec adjust -m72

while vi is pointing to a bunch of text and the paragraph (words on multiple lines followed by a blank line) will be adjusted to 72 chars or less with all words intact.

One of my favorites is ps but not the standard behavior. I use the UNIX95 variable to enable special features such as a hierarchical listing of parent/child programs, or to search for a program WITHOUT grep, or design-a-ps with -o:

UNIX95= ps -eH
UNIX95= ps -C sh
UNIX95= ps -e -o pid,vsz,args


Bill Hassell, sysadmin
Michael Tully
Honored Contributor

Re: Favorite Little used commands

I hope this is not just for hpux commands. How about some omniback ones. I like to fiddle with the 'omnirpt' 'omnimm' and 'omnidb' commands. They provide some great detail information from the OB DB on media, backups and DB information. I also have a small document entitled "Complete Idiots Guide to OmniBack Command Lines" which is used by all us SA's when using dial-up.
Anyone for a Mutiny ?
Todd McDaniel_1
Honored Contributor

Re: Favorite Little used commands

Yes any commands are valid for HPUX for any tool or application...

keep em coming!


Unix, the other white meat.
doug mielke
Respected Contributor

Re: Favorite Little used commands

maybe not 'little known' but can be handy are:
killall
sometimes helps unmount a troublesome filesystem (although that's not much of a system left afterward.

which and whereis (I knew I left that file around here somewhere)

/etc/motd
for notices to users

..and the cute one, 'make love'
Ian Kidd_1
Trusted Contributor

Re: Favorite Little used commands

A couple that aren't mentioned too much:
ipcs - information of semaphores

ipcrm - great when an oracle DB did not clean up after itself when it was halted, and won't restart because of semaphore usage.

/usr/sam/lbin/usermod.sam -F -p "" root
I got this one from the HP forums long ago. If you have root priviledges (ex: sudo), but the root password is lost and you can't change it because passwd wants the old password, this command will help.
If at first you don't succeed, go to the ITRC
Michael Tully
Honored Contributor

Re: Favorite Little used commands

and for some humour ...

$ yes "I've got a bad boss"
Anyone for a Mutiny ?
Bill Hassell
Honored Contributor

Re: Favorite Little used commands

Continuing in a humor vein..

From the tunefs man page:

You can tune a file system, but you can't tune a fish.

(sorry, the humor doesn't translate easily into other languages)

This is a favorite for new computer students:

# make love
Make: Don't know how to make love. Stop.


Bill Hassell, sysadmin
Mic V.
Esteemed Contributor

Re: Favorite Little used commands

In C shell:

% got a light?
No match.

Seriously: dirs -l, pushd, popd for managing your cwd.

To reset a locked account (trusted system): /usr/lbin/modprpw -k username

Also: banner, dc, checknr, fixman, from, leave, lock, od, w
What kind of a name is 'Wolverine'?
Myles McManus
Frequent Advisor

Re: Favorite Little used commands

When you just can't remember the name of the backup:

omnidb -ses -det -last 2 | grep -i

When it's just gotta be safe:

scp -i Filename user@relay:user@targethost:/target_file_path

In case you're having a 'stupid' day:

alias rm='rm -i'

One of my favourite things:

set -o vi

Another of my favourite things:

cutview, have lots of cut and paste buffers, never struggle to remember all those long commands again ;-)(available from the porting asnd archive centers).

There's no place like $HOME.
H.Merijn Brand (procura
Honored Contributor

Re: Favorite Little used commands

Once they are favourite, they are probably not little-used anymore, now are they :)

As I know unix fron System III days, I'm still quite fond of 'lp'. The old, simple tty-based command is not easy to configure, but it's use is very transparant, and not as obscure as lps or AIX' printing system. One can have piggy-bag printers by defining a printer interface - which are simple shell scripts under lp in /etc/lp/interface - and have it's output not go to the device, but piped to another lp command.

By then only sh and csh existed and csh was much more user friendly than sh. Later came ksh, bash and other posix based and extended shells, but being fond of C and the csh, I switch to the tcsh quite early, and still use that on all my machines.

I also like pr, comm, sort, awk, sh, sed, uniq, pwd, ssh, ls, size, what (who else uses what these days?), sccs, ident (a bit like what, but for rcs files), and file.

wc is good, especially when used in a pipe, since it then doesn't show the filename, and the count can be used as a number without munging. cut and paste are fine too even when not used together.

Next to ps, I regularly use perl modules to seak program info, and lsof, chatr, model, getconf, adb, bc, cstm, odump, elfdump help me with system and process info a lot, as does the sw suite (swlist, swremove, swinstall). I use SAM only to extend and maintain logical volumes. And I've not seen fuser been mentioned yet. I often use it with -c to check the use of file systems I want to unmount.

I still use all the above commands, even though most of them get replaced with perl internal calls once they have to be used in a script. All scripts expected to be over three lines are written in Perl.

I am in love with elvis (the best vi clone around), and less (highly configurable more), and GNU grep (which in my ports has PCRE as default regex engine). Pass grep an extra argument of /dev/null if you only grep in one file to get the filename in front of the grepped pattern

The best internet related command is wget. By far. Use it once, use it twice, and you miss it on systems that did not install it. Next to wget, I use rsync a lot, and indirectly samba (or CiFS), which you seldom use from the active side (smbclient -M is a great way to annoy users), but mostly from the passive side (Win32 exploder) is a great way to share stuff. Ethereal is a util that needs time to understand (and I still don't), but wow, does it give a lot of information.

HP's diff is OK, GNU diff utils are good, but when examining changes to large files, xdiff is much better (if you have X11), but the best in this field is xxdiff, though you will need Qt, and it is a PITA to get it compiled.

xargs and find are buddies. find ... | xargs is a very useful combo

ttytpe is little used: only at logon, but it is so damned good, that I used trace programs like lsof, strings, adb, gdb, and tusc (once again a very good program that you only need once a year, but then proves very valuable) to rewrite it from scratch so I can use it on AIX and Linux. HP has done an awful good job here. (Even though JRF thinks it might send terminals to Lalaland :)

I hate emacs, GNU info related stuff, IE, OE, and OSF/1 based systems

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Mark Grant
Honored Contributor

Re: Favorite Little used commands

Can someone give Merijn ten points for that "grep" tip!!

I'm glad someone else hates GNU "info"!
Never preceed any demonstration with anything more predictive than "watch this"
John Strang
Regular Advisor

Re: Favorite Little used commands

Nobody has mentioned diff3 - 3-way differential file comparison.

From the man page
diff3 compares three versions of a file, and prints disagreeing ranges of text flagged with these codes:

==== all three files differ
====1 file1 is different
====2 file2 is different
====3 file3 is different

May not be useful every day, but in the past I have been glad of it!

And I also use expr, so Mark Grant is not the only one!

If you never make a mistake you'll never make anything.
H.Merijn Brand (procura
Honored Contributor

Re: Favorite Little used commands

No point here please

1. I also use expr, but perl is much more useful here, because IMHO the syntax of expr is a bit odd
2. diff3 is included in GNU diffutils, and both xdiff and xxdif that I mentioned as supreme understand and support diff3. And yes, it IS useful

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn