HP-UX tricks

From Unix Wiki
Jump to: navigation, search

Lock / Unlock account user id on HP-UX trusted system

Check account status:

# /usr/lbin/getprpw useraccount

Unlock / Enable / Reactivate:

# /usr/lbin/modprpw -k useraccount

Lock / Expire password:

# /usr/lbin/modprpw -e useraccount
  • Do not use a capital E, as it will expire the password on all user accounts.

Memory operations

List process by consumed memory

# UNIX95=1 /usr/bin/ps -e -o vsz,pid,args | /bin/sort -u -r

Show memory and swap usage

# swapinfo

or total info

# swapinfo -t

LVM operations

Most used commands

 # strings /etc/lvmtab							- lists existing VG
 # vgdisplay								- lists existing VG
 # vgdisplay -v								- lists existing VG, LV, PV
 # lvlnboot -v								- lists boot definitions
 # vgdisplay -v /dev/vg00						- lists info about VG & LVs belonging here
 # lvdisplay -v /dev/vg00/lvol1						- lists info about LV
 # pvdisplay (-v) /dev/dsk/c0t5d0					- lists physical volume
 # vgcfgbackup vg01							- creates a backup copy of the LVM configuration
 # vgexport -v -p -s -m /tmp/vg01.map vg01				- exports VG vg01 definitions
 # vgimport -v -s -m /tmp/vg01.map vg01					- imports VG vg01 definitions
 # vgchange -a r vg01							- changes VG to read-only

As you can see it's very similar with Linux LVM commands, but HP-UX has some features comparison with Linux, for example before creating volume group you need:

 # mkdir /dev/vg01							- creates VG directory
 # mknod /dev/vg01/group c 64 0x010000					- creates VG control file (always called "group")
 # pvcreate [ -f ] /dev/rdsk/c_t_d0					- prepares the disks for LVM
 # vgcreate /dev/vg01 /dev/dsk/c_t_d0					- creates the VG

Resize logical volume

Resize of logical volume pretty simple as on Linux, but online resize available only if you have online JFS. To check it type following:

 # swlist -l product | grep -i online

if checked successfully, resize online:

# lvextend -L 20480 /dev/vg00/lvol1 - make size of logical volume by 20480 MB
# fsadm -F vxfs -b 20480M /lvol1 - in this example you should specify current mountpoint
  • important thing - value before key -L in lvextend means size in MB, value before key -b in fsadm means size in bytes.

or if you do not have JFS online you should umount your logical volume and extend size to maximum amount of logical volume size

# extendfs -F vxfs /dev/vg00/lvol1

Finally check your newly free space

# bdf

List of fileset sorted by install date

# swlist -l fileset -a install_date -a revision -a title | sed -e 's/#/ /g' | sort -rn -k 2

ptree equivalent in HP-UX

# UNIX95=1 ps -eHf

System serial and product number

# echo "sel path system;info;wait;il;exit" | cstm | egrep -i "(system serial|original product) number"


It can download sets of packages and their dependencies (caching them for later use) and then install any of them that aren't already installed. This release has fixed auto-updating (use "depothelper depothelper" to upgrade from 1.00 to 2.00), added the uninstallation of packages and corrected various output bugs.

Find NIC speed

Script 1

ppas=`lanscan | awk '$3~/^[0-9]$/{print $3}' | xargs`
for i in $ppas
printf "Card at PPA %s - " $i
ipa=`ifconfig lan${i} 2>/dev/null | awk '{ip=$2}END{if(ip==""){printf("Not assigned ")}else{printf("%s ",ip)}}'`
printf "IP Address: %15s- " "$ipa"
lanadmin -x $i 2>/dev/null | awk '{$1="";printf("%s",$0)}'
echo ""

Script 2



netstat -i
nwmgr -g -v -c lan3