Operating System - HP-UX
1832074 Members
3027 Online
110035 Solutions
New Discussion

Re: little used favorite commands...

 
Todd McDaniel_1
Honored Contributor

little used favorite commands...

Okay, I am curious once more to find out what little used commands you have that are interesting and handy...

Basically my goal is to make us all aware of great little commands that most of us don't use on a daily basis...

I recently took a Posix coding class and learned of a few...


One I found very useful strangely interesting is "getopts" used in managing script command options and for formatting error messages for usage and such.

Unix, the other white meat.
22 REPLIES 22
Jeff Schussele
Honored Contributor

Re: little used favorite commands...

I frequently use getprpw & modprpw to deal with expired/locked out accounts.
The biggest pain with these is the lack of man entries in the OS itself - although you can get man pages online a www.docs.hp.com

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

Re: little used favorite commands...

the rad command.

useful for looking at hardware information.

Geoff Wild
Honored Contributor

Re: little used favorite commands...

Bind version:

dig CHAOS TXT version.bind @some.dns.server

But you can change it in named.conf in the options section:

version "Wild DNS 1.0";

Sendmail version:

sendmail -v -d0.1 < /dev/null

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.
RAC_1
Honored Contributor

Re: little used favorite commands...

getip, grget, pwget, pwstat
quot, expand_alias, sendmail -v
df -g
UNIX95= ps -C
may more there.
There is no substitute to HARDWORK
Simon Hargrave
Honored Contributor

Re: little used favorite commands...

The old favourite to find the size of processes:

UNIX95= ps -e -o vsz=Kbytes -o ruser -o pid,args=Command-Line | sort -rnk1 | grep -v Kbytes
Simon Hargrave
Honored Contributor

Re: little used favorite commands...

Also tput, useful for making "pretty" output.

eg: -

clear
tput cup 5 10
tput smso
echo "Main Menu"
tput cup 6 10
tput sgr0
echo "Option 1"
Gavin Clarke
Trusted Contributor

Re: little used favorite commands...

Not really a command this:

man tunefs

Which I'm sure you're all aware of already.

I like it.
Cem Tugrul
Esteemed Contributor

Re: little used favorite commands...

To checking machine status for whole day;

usr/sbin/sar -u -M > /logging/perf/`date +%b%Y`/cpu`date +%d` 2> /dev/null
/usr/sbin/sar -b > /logging/perf/`date +%b%Y`/buffer`date +%d` 2> /dev/null
/usr/sbin/sar -d > /logging/perf/`date +%b%Y`/disk`date +%d` 2> /dev/null
Our greatest duty in this life is to help others. And please, if you can't
Chris Wilshaw
Honored Contributor

Re: little used favorite commands...

And for those who haven't seen it already, here's the link to your original thread on this one;

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=406126

Here's a new one to go on the list

rev - reverses the lines in a file.

eg:

=> cat file1
one
two
three
four
five
six

=>rev file1
eno
owt
eerht
ruof
evif
xis

I'm sure there are endless applications for this, but personally, I used it to write a fake shell for April Fools Day :)
Todd McDaniel_1
Honored Contributor

Re: little used favorite commands...

Thanks Chris... my sanity or lack thereof is being exposed yet again!!!

Heh well that was 18 months ago so I'm due a repeat!!
Unix, the other white meat.
Rita C Workman
Honored Contributor

Re: little used favorite commands...

vg problems I love this one...

echo "0x2008?4D"| adb /dev/dsk/c-t-d-

the output gives you for each field, if I can ready my old notes:

1=address of lvm data
2=system/cpu id
3=pvid
4=system/cpu id
5=vgid

...I compare a disk that is in the vg and one that is reporting error (but should be in same vg)...if field 5 don't match that confirms the problem...

Rgrds,
Rita
Mel Burslan
Honored Contributor

Re: little used favorite commands...

usually forgottoen steps when repairing a failed root disk mirror:

rawdevice=/dev/rdsk/cXtXdX
mkboot -l ${rawdevice}
mkboot -a "hpux -lq (;0)/stand/vmunix" ${rawdevice}
cd /usr/sbin/diag/lif
width=`getconf KERNEL_BITS`
if [ $width -eq 64 ]
then
mkboot -b updatediaglif2 -p ISL -p AUTO -p HPUX -p LABEL ${rawdevice}
else
mkboot -b updatediaglif -p ISL -p AUTO -p HPUX -p LABEL ${rawdevice}
fi

lvlnboot -r /dev/vg00/lvol3 # root fs /
lvlnboot -s /dev/vg00/lvol2 #swap
lvlnboot -d /dev/vg00/lvol2 #swap/dump
lvlnboot -b /dev/vg00/lvol1
lvlnboot -R
lvlnboot -v
________________________________
UNIX because I majored in cryptology...
Sandman!
Honored Contributor

Re: little used favorite commands...

display command used for filesystem creation:

# mkfs -m /dev/vgXX/lvolY

display contents of the superblock:

# fstyp -v /dev/vgXX/rlvolY

Moving all "*.arc" files to "*.old" in current dir:

# ls *.arc | awk -F"arc" '{system("cp "$0" "$1"old")}'
Michael D. Zorn
Regular Advisor

Re: little used favorite commands...

One I use almost every day: It shows the most recent files in a directory. I put it in my .kshrc file:

alias -x llast='ll -t | head -23' # ll most recent files`
Marlou Everson
Trusted Contributor

Re: little used favorite commands...

Actually, this is a command I use a lot. It's the option for it that I don't use as frequently anymore. For the lp command, I always repeated the -o option each time. I discovered that I could put everything in single quotes.

So instead of
lp -dprinter -oduplex -otray3 -o3hole -onb
I do
lp -dprinter -o'duplex tray3 3hole nb'

Also, printing out man pages so that they paginate correctly
man man | lp -dprinter -on

Marlou
Devesh Pant_1
Esteemed Contributor

Re: little used favorite commands...

I like the command
# strings /etc/lvmtab
to see the volumegroup entry in the lvmtab file.
thanks
Dp
Bill Hassell
Honored Contributor

Re: little used favorite commands...

Here's a few favorites:

whence (you'll never use which or whereis again)
type (even better than whence)

logins -d (a great security check)

ioscan -k (ultra-fast option)
ioscan -kfC lan (or disk or tape..)

addqueue (for JetDirect printers)

setboot (especially the SpeedyBoot options in 11.11)



Bill Hassell, sysadmin
Ranjith_5
Honored Contributor

Re: little used favorite commands...

Hi All,

I dont know any of this group have tried the command "yes"...this can be used to generate repeated outputs in a shell script. But I havent seen this used by any one yet. I think this is very rarely used.

eg:
#yes " How are you??"
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??
How are you??


Regards,
Syam
Ranjith_5
Honored Contributor

Re: little used favorite commands...

Hi,

what about the following commands.
These are rarely used and can do special functions.


lock locks the screen ( try this :-)
doscp dos copy
split split a bigger file into small pieces.
ftpwho shows the ftp user info
fold formating the colum width. ( try fold -30 /etc/issue)


Regards,
Syam
Cem Tugrul
Esteemed Contributor

Re: little used favorite commands...

i usually use to findout users who locked as
below;

echo "USERS BELOW LOCK!!!!:\r"
for USER in $(listusers | awk '{print $1}')
do
lock_pos=$(/usr/lbin/getprpw -r -m lockout $USER)
user_name=$(grep $USER /etc/passwd|awk -F: '{print $5}')
if [ $lock_pos != "0000000" ]
then
echo "$USER $user_name $lock_pos"
fi
done
Our greatest duty in this life is to help others. And please, if you can't
Borislav Perkov
Respected Contributor

Re: little used favorite commands...

Hi,

UNIX95= ps -eH -> hierarchical presentation of processes

/etc/motd -> message of the day

clear -> clear the screen

rm -r / -> have never used this :-)


Regards,
Borislav
Ernesto Cappello
Trusted Contributor

Re: little used favorite commands...

This is

ux2dos "filename" > "filename.att" | uuencode "filename.att" | mailx -m -s "SUBJECT" pippo@pippo.com

rm $1.att

Regards, Ernesto.