Premson's Scratch Pad

This page was last updated on 2nd April 2007

Disclaimer

(This page is meant for my personal usage. Certain commands mentioned below are quite dangerous if run with high Privileges. Use at your risk.)

(57 KB)


TRU64



TRU64 - General Administration


# sizer -v (To view OS version and revision)

# psrinfo -v (To view all processors status)

# vmstat -P (Displays memory and related information)

# consvar -l (List firmware console environment variables)

# uerf -R (Outputs System Event reports)

# collect -sn -i 1 | egrep -e 'Name' -e 'tu0' (To check the speed of your adapter using collect)

# ipcs (Give info on Message Queues, Shared Memory, Semaphores)

# netstat -m (Shows information about memory allocated to the data structures
  associated with network operations)

# netstat -s (Shows statistics for each protocol)

# netstat -i (Show state of configured network interfaces)

# niffconfig -v (Display parameters for all interfaces that are being monitored including NetRAIN i/f monitoring).

# lmf list (Verify that system has the LSM license registered & loaded)

# collect -sf (Outputs info on file system subsystem)

# btcreate -t tape_device (Creates a bootable tape)


# dupatch -track -type kit -nolog (To list Patch Kits)

# dupatch -track -type patch -nolog (To list patches)

# sys_check -escalate (To report problems to your technical support organization)

# sys_check > file.html (Report in HTML format)

# sys_check -all > file.html (Entire system report in HTML format)

# sys_check -perf > file.html (Outputs only performance information)

# sys_check -frame -noquick (Entire system report in HTML output with frames)

# sysman config_report (Starts the SysMan Menu config_report)


# sysconfig -q envmon (Check the status of the environmental monitoring subsystem)

# envconfig -c ENVMON_CONFIGURED=1 (To configure the envmond daemon and reboot the system)

# rcmgr set ENVMON_CONFIGURED 1 (Enabling envmond daemon)

# envconfig -c ENVMON_GRACE_PERIOD=10 (This will shutdown the system after 10mins. if the sytem
  does not fall below the critical threshold)

# rcmgr set INSIGHTD_CONF NO (To prevent startup of insightd daemon)

# rcmgr set SNMPEVMD NO (Prevent startup of evm snmp trap handler daemon)

# sysconfig -r proc exec_disable_arg_limit=1 (Use when U encounter "arg list too long" error

# /usr/sbin/clu_get_info -full (To determine the version of the TruCluster software running)

# /usr/sbin/wol [nw_interface] hw_address (Send network packet to power on target system [wake-on-LAN])

# asemgr -dv (To Administers an Available Server Environment. An infrastructure is provided
  to move applications from one member to another in the event of failure.)


# mailq (To view summary of mail messages queued)

# sendmail -q (To process the saved messages in the queue)

# /usr/bin/X11/xhost + (Enable X Windows sessions for remote users [generally not recommended])

# /usr/bin/X11/xhost - (Disable X Windows sessions for remote users)




TRU64 - Disk Administration


# disklabel -r rzb32 (To read disklabel info of the disk)

# showfdmn domain_name (To view disk details)

# showfsets domain_name (To view file sets of a domain)

# rmfset (To delete filesets)

# chfsets -b 1000 -f 200 account_dmn credit_fs (To change file hard limit from 11 to 200 and block

  hard limit from 121 to 1000 for the credit_fs fileset in the account_dmn)

# rmfset domain fileset (To remove a file set from a given domain)

# mkfdmn /dev/rz1c accounts_dmn (To create domains for given disk)

# mkfset accounts_dmn credit_fs (To create file sets for given domain)

# addvol /dev/rz1c accounts_dmn (adds a new volume to an active file domain)

# balance accounts_dmn (and then to balance the even distribution of files over all of the volumes)


# dsfmgr -m dsk7 dsk0 (Renames dsk7 to dsk0)

or

# dsfmgr -e dsk7 dsk0 (Exchanges the device special files for the named nodes)

# dn_setup -clean (Deletes all devices files (everything under /dev and /device)

# dn_setup -init (Recreates all device files)

# dsfmgr -K (Creates all device special files)


# hwmgr -view dev (To view all the devices in the system)

# hwmgr -view hierarchy (To view the hierarchy of hardware within your system)

# hwmgr -show scsi -full (Show SCSI/CAM devices, with access paths)

# hwmgr -delete scsi -did 1 (Cleans a particular scsi entry)

# hwmgr -delete component -id XX (To delete the component ID of a particular disk)

# hwmgr -show component (Display hardware components from the hardware component databases)

# hwmgr -scan component (Scans the system for new hardware components)

# hwmgr -refresh component (Removes obsolete hardware entries from all databases)

# hwmgr -flash light (The disk will attempt to flash the activity light)



On TRU64 Clusters


# caa_stat (To Provide status on Cluster Application Availability [CAA])

# caa_stat -a dhcp -g ; echo $? (To determine the status of DHCP registered resource with the return code)

# caa_stat -a dhcp -r ; echo $? (To determine the status of DHCP running resource with the return code)

# caa_stop -f autofs (Stop AutoFS by entering the following command on the member)

# caa_relocate -s current_member -c target_member (Perform the manual relocation of other applications running

  on that member)

# caa_startautofs -c target_member (to restart AutoFS on a member)



TRU64 - Account Administration


# useradd -u 26890 -g bcs -c "Simon Charlie" -m -d /home/sim -s /usr/bin/ksh sim

# usermod -x administrative_lock_applied=0 user_name # To unlock a user account when disabled

# usermod -x grace_limit=1 user_name # To reset grace limit only after v5.1

# usermod -x passwd_lifetime=0 user_name # To reset password life time

# usermod -G group username # To add a user to a secondary group

# usermod -l smith johnsmith (To change name of the username)

# useradd -u 7033 -o -g 15 -c "Agent Smith,333" -d /usr/users/smith -s /bin/false asmith (To create a duplicate UID user)

# usermod -s /bin/csh -x distributed=1 abc (To change a shell and update that in NIS database)


# /tcb/bin/edauth -g username # To view a user account details

# /tcb/bin/edauth username # To edit the user account details

# /tcb/bin/edauth -g -dd default # To view the defaults file

# /tcb/bin/edauth -dd default # Edit defaults file

# /tcb/bin/edauth -g -dt # Can set login timeouts for terminals

# /tcb/bin/edauth -r username # To delete a user from auth.db

# /usr/tcb/bin/edauth -g username | sed 's/:u_retired:/:/' | /usr/tcb/bin/edauth -s # To get rid of retire entry



TRU64 - HSG CLI


# /usr/lbin/hsxterm -f /dev/rrz88c # Host Port CLI Terminal Emulator

# /usr/lbin/hsxterm -b10 -t1 -l0 (HSXterm, Host Port CLI Terminal Emulator)



TRU64 - Using MT


# mt -f /dev/ntape/tape0_d1 rewind (To rewind tape0)

# mt -f /dev/ntape/tape0_d1 offline (To rewind and offline the tape0)

# mt -f /dev/ntape/tape0_d1 online (To bring tape0 to online state)

# mt -f /dev/ntape/tape0_d1 unload (To eject tape0)

# mt -f /dev/ntape/tape0_d1 fsf 1 (To forward space files)

# mt -f /dev/ntape/tape0_d1 bsf 1 (To backspace space files)



TRU64 - Printing


# lpc stat rp123 (Checking the remote printer rp123 print spool)

# lpc status rp123 (Checking the remote printer rp123 print spool)

# lpc restart rp123 (Restart the remote printer daemon)

# lpc start rp123 (Starting the printing daemon)

# lpc stop rp123 (Stoping the printing daemon)

# lpc down rp123 (Disables print queuing and disables printing)

# lpc up rp123 (Enables print queuing and enables starts new printer daemon)

# lpc enable rp123 (Enabling print spooling)

# lpc disable rp123 (Disabling print spooling)

# lpc abort rp123 (Terminates spooling daemon disables printing)

# lpc clean rp123 (Cleans jobs from the spool)

# lpq -P (Displays requests queued for that printer only)

# lprm -P (Removes requests from the line printer spooling queue)





TRU64 - LSM on ALPHA


# volprint -Ath (To view entire LSM Disk groups)

# voldisk list (Prints list of disks)

# volprint -g ictdg (To view a particular disk group)

# voldctl list (The following command checks the status of /etc/vol/volboot)

# voldctl mode (The following command checks the status of vold)

# volstat -ff -v export_vol (Checking the number of failures on the volume)


# voldiskadm - Menu driven program to view, create, mirror, enable (online), disable volumes of disks

# volassist - Create, mirror, backup, grow, shrink, and move Logical Storage

# voldisk rm rz8 # Remove the disk from LSM



Plexing to Subdisk


# volprint -g dcsdata12dg (To print the disk group)

# volsd assoc data12-02 rzf49c-01 (Associate the plex to the sub-disk)

# volplex att data12 data12-02 (Attach the plex to the volume)

# volprint -Ath | grep data12 (Keep a track till STALE is gone)



Adding a mirrored system disk to the volboot file:


# voldctl add disk rz1 (Add the mirrored system disk to the volboot file)

# volencap rz0g (if UFS) OR # voladvdomencap usr_domain (if AdvFS) [Encapsulate the usr partition]

>>>set bootdef_dev dka0,dka100 [Shutdown your system now and change bootdef_dev to point to

   bothsystem disks and to reboot to encapsulate usr]

# disklabel -e rz1 [Edit the partition table of the rz1 (mirrored disk), to match the off-set and size of your usr]

# voldisk init rz1g type=nopriv [Make this new partition available to LSM as a nopriv disk]

# voldg adddisk rz1g

# volassist mirror vol-rz0g rz1g [Now mirror usr making sure it uses the rz1g disk (UFS File System)]

# volassist mirror volrz0g rz1g [for AdvFS filesystem]



How To Replace A Failed System Disk When Mirrored Through LSM:


# voldisk list


DEVICE TYPE DISK GROUP STATUS

rz0 sliced - - error rz0b nopriv - - error

rz0g nopriv - - error rz0h nopriv - - error

rz1 sliced rz1 rootdg online rz1b nopriv

rz1b rootdg onlinerz1g nopriv

rz1g rootdg online rz1h nopriv

rz1h rootdg online- -

rz0 rootdg failed was:rz0 - -

rz0b rootdg failed was:rz0b- -

rz0g rootdg failed was:rz0g - -

advfs_rz0h rootdg failed was:rz0h


# volprint -ht


DG NAME GROUP-IDDM NAME DEVICE TYPE PRIVLEN PUBLEN PUBPATH

V NAME USETYPE KSTATE STATE LENGTH READPOL PREFPLEX

PL NAME VOLUME KSTATE STATE LENGTH LAYOUT ST-WIDTH MODE

SD NAME PLEX PLOFFS DISKOFFS LENGTH DISK-NAME DEVICE


dg rootdg 823681228.1025.frick.alf.dec.com


dm advfs_rz0h - - - -

dm rz0 - - - -

dm rz0b - - - -

dm rz0g - - - -

dm rz1 rz1 sliced 512 131072 /dev/rrz1e


dm rz1b rz1b nopriv 0 261616 /dev/rrz1b

dm rz1g rz1g nopriv 0 819200 /dev/rrz1g

dm rz1h rz1h nopriv 0 838444 /dev/rrz1h


v rootvol root ENABLED ACTIVE 131072 ROUND

pl rootvol-01 rootvol DISABLED NODEVICE 131072 CONCAT - RW

sd rz0-01 rootvol-01 0 131056 16 rz0 -

sd rz0-02 rootvol-01 16 0 131056 rz0 -


pl rootvol-02 rootvol ENABLED ACTIVE 131072 CONCAT - RW

sd rz1-01 rootvol-02 0 131056 16 rz1 rz1

sd rz1-02 rootvol-02 16 0 131056 rz1 rz1


v swapvol swap ENABLED ACTIVE 261616 ROUND

pl swapvol-01 swapvol DISABLED NODEVICE 261616 CONCAT - RW

sd rz0b-01 swapvol-01 0 0 261616 rz0b -


pl swapvol-02 swapvol ENABLED ACTIVE 261616 CONCAT - RW

sd rz1b-01 swapvol-02 0 0 261616 rz1b rz1b




SUN



USING META


When disksuite error occurs:


# metastat d5 # Check which sub-mirror has caused it

# metareplace -e d5 c4t0d0s0 # Determine the disk and replace it with the mirror

# metastat d5 # Verify the disk syncing progress


else


# prtvtoc /dev/rdsk/c2t3d1s2 # To check whether the disk is alright

# prtvtoc /dev/rdsk/c15t1d1s2 | fmthard -s - /dev/rdsk/c2t3d1s2 # Use the good partition table and reformat the new disk

# metareplace -e d5 c4t0d0s0 # Replace the new disk with the mirror

# metastat d5 # Verify the disk syncing progress


# prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t8d0s2 # Copy the partition table of the boot drive to its mirror


# metadb -a -f -c2 /dev/dsk/c0t0d0s6 /dev/dsk/c0t8d0s6 # Creating at least 2 state database replicas on each disk

(Where -a means adding; -f means force because this is the first time creating databases; and -c 2 means create 2 databases in each slice.)



MIRRORING


Create the mirror for / filesystem


# metainit -f d10 1 1 c0t0d0s0 # "1 1" means we are creating a 1 way 1 slice metadevice.

# metainit d20 1 1 c0t8d0s0

# metainit d30 -m d10 # Creates the metadevice mirror and attaches the submirror "d10" to it.

# metaroot d30 # To update the /etc/vfstab for / filesystem and /etc/system


Create the mirror for all other filesystems


Swap filesystem:

# metainit -f d11 1 1 c0t0d0s1

# metainit d21 1 1 c0t8d0s1

# metainit d31 -m d11


/var filesystem:

# metainit -f d12 1 1 c0t0d0s3

# metainit d22 1 1 c0t8d0s3

# metainit d32 -m d12


/opt filesystem:

# metainit -f d13 1 1 c0t0d0s4

# metainit d23 1 1 c0t8d0s4

# metainit d33 -m d13


/export/home filesystem:

# metainit -f d14 1 1 c0t0d0s5

# metainit d24 1 1 c0t8d0s5

# metainit d34 -m d14


Edit the /etc/vfstab to mount the new mirrors on boot.


The /etc/vfstab prior to updating it:

/dev/md/dsk/d30 /dev/md/rdsk/d30 / ufs 1 no -
/dev/dsk/c0t0d0s3 /dev/rdsk/c0t0d0s3 /var ufs 1 no -
/dev/dsk/c0t0d0s5 /dev/rdsk/c0t0d0s5 /export/home ufs 2 yes -
/dev/dsk/c0t0d0s4 /dev/rdsk/c0t0d0s4 /opt ufs 2 yes -

The /etc/vfstab after updating it:

/dev/md/dsk/d30 /dev/md/rdsk/d30 / ufs 1 no -
/dev/md/dsk/d32 /dev/md/rdsk/d32 /var ufs 1 no -
/dev/md/dsk/d34 /dev/md/rdsk/d34 /export/home ufs 2 yes
/dev/md/dsk/d33 /dev/md/rdsk/d33 /opt ufs 2 yes -

# metainit hsp001 # Suppress harmless warning messages (optional)

# lockfs -fa

# init 6 # Reboot and allow the system to mount the mirrors


Attach the second submirror to the mirror. This will cause the data from the boot disk to be synchronized with the mirrored drive.


# metattach d30 d20

# metattach d31 d21

# metattach d32 d22

# metattach d33 d23

# metattach d34 d24


# metastat # Use metastat to track progress


# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t8d0s0 # Enable the mirror disk to be bootable


Set nvram and reboot system to verify system will boot


# eeprom "boot-device=disk0 disk1

# eeprom use-nvramrc?=false

# init 6


(or)


# ls -l /dev/rdsk/c0t8d0s0

lrwxrwxrwx 1 root root 54 Aug 5 20:35 /dev/rdsk/c0t8d0s0 ->
../../devices/sbus@3,0/SUNW,fas@3,8800000/sd@b,0:a,raw

ok nvalias backup /sbus@3,0/SUNW,fas@3,8800000/sd@b,0:a
# eeprom nvramrc="devalias backup /sbus@3,0/SUNW,fas@3,8800000/sd@b,0:a"

ok boot backup

In case of primary boot disk failure, boot from the alternate disk


ok boot mirror



SUN - STEPS TO REMOVE A DISK ON AN SSA:


# ssaadm -v display c0 # To display controller info of c0 (SPARCstorage Array Administration)

# ssaadm reserve /dev/dsk/c1t8d0s2 # The first step reserves the SCSI device so that it can't
  be accessed via its second SCSI bus

# ssaadm -e offline /dev/dsk/c1t8d0s2 # To make the disk offline

# ssaadm -e bus_quiesce /dev/dsk/c1t8d0s2 # The quiesce the bus


Now replace the diskby unquiescing the bus, putting the disk back online, then releasing it:


# ssaadm -e bus_unquiesce /dev/dsk/c1t8d0s2

# ssaadm -e online /dev/dsk/c1t8d0s2

# ssaadm release /dev/dsk/c1t8d0s2



SUN CLI Administration


Memory


# prtconf | grep Mem /* Display Memory Size */

# prstat -a /* Reports active process status */

# pmem 3687 /* To check process address space */

# prtmem /* Prints Memory Summary */

# sar -k 1 5 /* Determine kernel memory used */

# sar -g -f sa06 -s 14:30 -e 15:30 /* Reads from sa06 for start and end time for paging activity */

# sar -r -f sa06 -s 14:30 -e 15:30 /* Reports unused memory pages and disk blocks */

# sar -u -P 0,1 /* To check for listed processor usage */

# /usr/proc/bin/pmap 3687 /* To check application process memory */

# memps /* Determine resident, shared, private memory */

# memps -m /* Determine cached memory */

# echo 'ecache_scan_rate/D' | adb -k /* To determine the current value of ecache_scan_rate */

# echo 'ecache_scan_rate/W 0t1000' | adb -kw /* To apply the value of 1000 to ecache_scan_rate */


Processes


# fuser -uc /var /* Processes that are running from /var */

# kill -HUP `ps -ef | grep 23 | awk '{print $2}'` /* HUP any related process in one step */

# lsof -i TCP:25 /* Mapping port with process */

# pfiles /* Shows processes' current open files */

# pkill -n /* Kill a process by name */

# kill `ps -ef | grep inetd | grep -v grep | cut -f8 -d ' '` /* pkill for solaris 2.6 */

# pgrep -x -u root inetd /* To determine process of inetd */

# pkill -HUP inetd /* To restart inetd process */

# pkill -TERM rpcbind /* To terminate rpcbind process */

# kill -HUP 193 /* To restart process 193 */

# prstat -a /* Reports active process status (alternative for top command) */

# pmem 3687 /* To check process address space */

# ps -aux | more /* Displays CPU % usage for each process in ascending order */

# ps -auxww | grep /* Gives the full listing of the process (long listing) */

# ps -ef | grep -i | awk '{print $2}' /* Creates list of running PID by */

# ps -ef | grep -v "0:00" | more /* Gives you a list of any process with CPU time more than 0:00 */

# ps -ef | more /* Show all processes running */

# ps -eo pid,args /* List processes in simplified format */

# ps -fu oracle|grep pmon /* See which instances of Oracle are running */

# /usr/proc/bin/ptree /* Print the parent/child process 'tree' of a process */

# /usr/proc/bin/pwdx /* Print the working directory of a process */

# top -b 1 /* Returns the process utilizing the most cpu and quits */


Swap


# swap -l /* List the current swap devices */

# swap -s /* Print summary information about total swap space usage and availability */

# mkfile -v 10m /export/disk1/myswap /* Makes a 10 Megabyte swapfile in /export/disk */

# mkfile -nv 10m /export/disk1/myswap /* Makes an empty 10 Megabyte swapfile */

# mkfile 20m /* To create a 20 mb swapfile */

# swap -a /dev/dsk/c0t0d0s1 /* Add a swapfile */

# swap -d /dev/dsk/c0t0d0s4 /* Deletes a swap device */


System Configuration


# drvconfig ; disks /* Adding hot-plug disks to system */

# /usr/sbin/eeprom auto-boot? false /* Changes eeprom autoboot? setting without going to Ok prompt */

# /usr/sbin/eeprom diag-switch? true /* Set the system to perform diagnostics on the next reboot. */

# /usr/sbin/eeprom local-mac-address?=true /* Multiple Port Network Card Setting */

# /usr/sbin/grpck /* Check /etc/group file syntax */

# /usr/sbin/pwck /* Check /etc/passwd file syntax */

# /usr/sbin/sys-unconfig /* Clear host specific network configuration information */


System Information and Monitoring


# /usr/platform/sun4u/sbin/prtdiag /* To check system configuration */

# coreadm -e log /* Report global core */

# /usr/sbin/eeprom /* Show eeprom parameters */

# grep "\-root" /var/adm/sulog \ /* List most recent attempts to switch to superuser account. */

  | grep -v \+ | tail -25

# isainfo -bv /* Quickly checkout if machine is in 32 or 64 bit mode */

# last /* Tells who was or still is on the system */

# logger -i /* Log the process ID */

# psradm -f [processor id] /* Take processor offline */

# /usr/sbin/prtconf -vp /* Show system configuration details */

# /usr/platform/`/bin/uname -i`/sbin/prtdiag -v /* System Diagnostics */

# prtconf -pv | grep banner-name \ /* Show actual model name of machine */
  |awk -F\' ' { print $2 } ' | head -1

# psrinfo | wc -l /* Display number of processors */

# sar -A

Task Name Service Commands
Add a user account NIS + nistbladm
nisclient
NIS useradd
make
None useradd
Modify a user account NIS+ nistbladm
NIS usermod
make
None usermod
Delete a user account NIS+ nistbladm
nisclient
NIS userdel
make
None userdel
Set up user account defaults NIS+ not available
NIS useradd -D
make
None useradd -D
Disable a user account NIS+ nistbladm
NIS passwd -r nis -l
make
None passwd -r files -l
Change a user's password NIS+ passwd -r nisplus
NIS passwd -r nis
None passwd -r files
Sort user accounts NIS+ niscat
sort
NIS ypcat
sort
None awk
sort
Find a user account NIS+ nismatch
NIS ypmatch
None grep
Add a group NIS+ nistbladm
NIS groupadd
make
None groupadd
Modify users in a group NIS+ nistbladm
NIS groupmod
make
None groupmod
Delete a group NIS+ nistbladm
NIS groupdel
make
None groupdel



IBM


General


# oslevel (To check the OS version)

# lscfg (Display hardware details for the system)

# lsattr -E -l sys0 | grep realmem (To determine the physical memory)

# lsattr -E -l aio0 -a maxservers (To determine maxservers parameter)

# chdev -l aio0 -a maxservers=350 -T (-T changes the parameter immediately and it lasts until the next boot)

# chdev -l aio0 -a maxservers=450 -P (-P change is deferred until the next boot and is permanent)

# lsps -s or lsps -a (List swap)

# lssrc -g nfs (To verify that Network File System (NFS) is running)

# errpt -d H (To generate a report of logged errors [here specific to hardware(H)])

# lsvg -l datavg2 (To List LV status of a volume group)

# lvextend "lvol name" "newsize"M (To increase the storage space)

# lvextend /dev/s12lv01 4620

# chdev -l sys0 -a maxuproc='4096'

# no -a | more (To list the current settings of all network-related parameters)

# no -o tcp_sendspace=221184 (To set the tcp_sendspace parameter to 221184)

# lsattr -l css0 -E (To list the current settings of these parameters)

# /usr/lpp/ssp/css/chgcss -l css0 -a spoolsize=16777216 (To set these parameters)

# sar -u -p 0,1 -r 1 10 (To check for CPU1,2 usage every 1 sec for interval of 10)

# instfix -k IX38794 -d /dev/rmt0.1 (To install all filesets associated with fix IX38794 from
  the tape mounted on /dev/rmt0.1)

# instfix -T -d /dev/rmt0.1 | instfix -d /dev/rmt0.1 -f- (To install all fixes on the media in the tape drive)

# instfix -s SCSI -d /dev/rmt0.1 (To list all keyword entries on the tape containing the string SCSI)

# instfix -i -k "IX38794 IX48523" (To inform the user on whether fixes IX38794 and IX48523 are installed)

# instfix -p -k IX12345 -d /bffs | installp -acgX -f- -d /bffs (To create a list of filesets
  associated with fix IX12345 for bffs in the /bffs directory)

# instfix -i |grep AIX_ML (To verify all maintenance level fixes are applied or not)


Account Administration in AIX


# smitty user

# mkgroup id=999 db2iadm1 (Create a group)

# mkuser id=1004 pgrp=db2 groups=db2adm home=/db2home/db2 core=-1 \
  data=491519 stack=32767 rss=-1 fsize=-1 db2 (Create a User)

# passwd db2inst1 (Set the password)

# rmuser -p username (Removes a user, not home directory)


# lsuser -f -a id pgrp groups admgroups smith (To display the user id and
  group-related information about the smith account in stanza form)

# lsuser -c -a id home groups smith (To display the user id, groups, and
  home directory of smith in colon format)

# lsuser smith (To display all the attributes of user smith in the default format)

# lsuser ALL (To display all the attributes of all the users)


# lsgroup finance (To display the attributes of the finance group in the default format)

# setgroups (As user sah, you can display your current group membership and process group set)

# setgroups -a finance (To add the finance group to the process group of the current session)

# setgroups -d payroll (To delete the payroll group from the current process group set)

# setgroups - (To change the process group set back to your default set)


# chgroup users=sam,carol,frank finance (To add sam and carol to the finance group,
  which currently only has frank as a member)

# chgroup users=sam,carol adms= finance (To remove frank from the finance group,
  but retain sam and carol, and to remove the administrators of the finance group)

# spchuser groups=C47031A,C47032A,C47033A,cmbsapA,ops cp035259


With Kerberos


# chkp -e 2000-12-31 -l 181 joeuser joe.admin harry.admin user12 (To set the
  expiration date to the end of the year 2000 and the lifetime to approximately two weeks)


ACLs


# spacl -a permissions -s ssp/hardmon (To see the permissions defined for
  Hardware Monitor objects)

# spacl -a check -s ssp/hardmon -o frame1/slot1 (to see if you can change
  the ACL of the Hardware Monitor object frame1/slot1)


Admin


# splstdata -p (To show information for all system partitions)

# lsauthpar -p system3p1 (Checking the AIX remote command authentication method setting_

# chauthpar -vp system3p2 k5 std (To enable and disable authentication methods)



Partitions


backup Performs a full or incremental backup of a file system
chfs Changes the characteristics of a file system
crfs Adds a file system
dd Copies data directly from one device to another for making file system backups
df Reports the amount of space used and free on a file system
fsck Checks file systems and repairs inconsistencies
lsfs Displays the characteristics of a file system
mkfs Makes a file system of a specified size on a specified logical volume
mount Makes a file system available for use
restore Restores files from a backup
rmfs Removes a file system
umount Removes a file system from use


$ lsfs /local
Nodename Mount Pt VFS Size Options Auto Accounting
/appsre/AIX ap137nap /local nfs -- bg,soft,intr,vers=3,proto=tcp yes no


$ lsfs /appsdisk1
Name Nodename Mount Pt VFS Size Options Auto Accounting
/dev/fslv02 -- /appsdisk1 jfs2 281018368 rw yes no


Configuring sendmail on AIX


1. Check whether sendmail is active:

$ lssrc -s sendmail
Subsystem Group PID Status
sendmail mail inoperative

2. Kill the sendmail daemon if its running by any chance

kill `head -1 /etc/sendmail.pid`

3. Alter the sendmail subsystem (as root)

# chssys -s sendmail -f 9 -n 15 -S -a "-bD"

4. Start sendmail daemon

# startsrc -s sendmail -a "-bd -q30m"


HP-UX



# swinstall -s /tmp/sophos-2.12.depot SOPHOS # Install a product

# ioscan (Scans system hardware, usable I/O system devices, or kernel I/O system data structures)

# ioscan -fnCdisk (To displays device special file names associated with a peripheral)

# ioscan -C disk (Shows the device files available for the disk class, as well as the

# ioscan -fn # Verify Hardware

# passwd -r files -s root # To determins current passwd details of an account

  name status mm/dd/yy min max warn

# cat /tcb/files/auth/r/root # To see root's credentials

# /usr/sbin/swapinfo -tam # To view swap information

# /usr/sbin/swlist | grep -i glance # To view check for a particular package

# /usr/sbin/vgdisplay -v | grep -e \"VG Name\" -e dsk | grep -v Alter # To view Volume Groups

# sar -u 10 10 # Reports CPU Utilization

# sar -d 10 10 # Report activity for each block device (disk or tape)

# bdf | sort +3nr # To view Disk Capacity

# iostat -t # Monitoring disks

# kmtune # Monitoring kernel tunable modules

# glance (Shows subsystem [default] statistics)

# glance -i (Outputs only from the file system subsystem)

# ipcs (Give info on Message Queues, Shared Memory, Semaphores)

# top (Top Load on CPU, processes, memory)



Setting up NFS on HP-UX


On Server

# start /sbin/init.d/nfs.server

# cat /etc/exports
/d2/R12_DVD access=server01.com,root=server01.com

# exportfs -i -o access= /usr

On Client

# mount -F nfs server01:/usr /usr




NETBACKUP COMMANDS


# bpsyncinfo

# /usr/openv/netbackup/bin/admincmd/bpbackupdb -seq 1 (To check backups)

# bperror -media -hoursago ... |grep -vi expired

# tpclean -c
# bpimagelist -U -client client_name -hoursago 24 (Backups which were successfully
  run on a NetBackup client in the last 24 hours)

# bpexpdate (To change the expiration date on a duplicated copy for a backup)

# bppllist (Generates a list of NetBackup policies)

# bpdbm -consistency | egrep -iv "checking image file|checking files file" (How to Check
  the Consistency of NetBackup Database)



LEGATO


# nsr_ize -i -s # To install networker software on the server

# inquire # list of SCSI devices attached to your server

# sjiielm # To initialize the element status, if autochanger does not support the -E option

# jb_config # To configure a jukebox

# jbexercise -c /dev/scsidev@1.2.0 -m Quantum DLT/Digital DLT # To test the jukebox connection

# scanner -B device_name # To determine the save set ID of the most recent bootstrap

# scanner -iv -c udun5231 /dev/ntape/tape5_d1 # Scanning for tape on Host

# changers - List SCSI autochangers attached to the system

# nsrjb -Iv -S # To inventory the backup tape in slot # (the tape that contains the latest bootstrap)

# nsrjb -lnv -S # -f device_name to load the backup tape in slot # into the device

# nsrjb -Iv # To inventory the autochanger

# nsrjb -HEv # To initialize everything (resets jukebox, autochanger & performs inventory)

# nsr_shutdown -a # Stop the NetWorker daemons

# nsrexecd ; nsrd # Restart the NetWorker server

-----

# nsrjb -s servername -lvv -S2-6 (Load tapes 2-6 on server)

# nsrjb -j tl895 -p -n -f /dev/ntape/tape0_d1 -S 51 # Verifying a tape

# nsrjb -j tl895 -Y -L -g -bdrive2 -f /dev/ntape/tape0_d1 -S 52 # Labeling a tape

# nsrjb -j tl895 -l -f /dev/ntape/tape0_d1 DNV084 # Mounting a tape

# nsrjb -j tl895 -u -f /dev/ntape/tape0_d1 # Unmounting a tape

# mminfo # To check the size of the system save sets

# mminfo -mv # To list the media associated with the files you want to recover

# mminfo -avot -c # To determine which volumes contain the application and user data backups

# nsrinfo -c client # Reports file index of a client

# nsrmm -d volume_name # Delete the records of the original volumes

# nsrmm -d mars.1 # To delete mars.1 from the media database

# mmrecov # To recover the NetWorker media database and resource configuration files

# nsrck # To recover the client file indexes (including the NetWorker server’s own client file index)

# nsrck -L7 # Recover the client file indexes

# mminfo -s serverhost -c clienthost | grep 02/15/04 # To check backup taken on 02/15/04




SNIPPETS




# ls -A . | while read name; do du -sk $name; done | sort -nr (To list biggest files first)

# awk -F: '$4 ~ /3/ {print $0}' /etc/passwd (Compare delimited columns and list them when successful)

# crontab -l | grep -v "^#"

# dd if=/u11/oradata/CMBS_ST/c47031_idx47.dbf of=/dev/null (Reads every byte of the file to isolate I/O errors related problem)



AWK & SED


uname -n|sed -e s'/\..*$//' (Determine hostname)

sed -e '/^$/d' logfile

sed 's/\(\w*\) \(\w*\)/\2 \1 \2/' names | sort | cut -f 2-3 -d " "

sed 'n;d' logs # Output odd lines

sed 'G;G' logs # Output triple space

VAL="20030910091500000000"

echo $VAL | sed 's/\(....\)\(..\)\(..\)\(..\)\(..\)\(..\)\(......\)/\1-\2-\3-\4:\5:\6.\7/'

Will give U : 2003-09-10-09:15:00.000000

awk 'BEGIN{FS=":"}{print $1}' < /etc/passwd

awk '{print tolower($0)}'

awk -F: '{ print $1" : "$5}' /etc/passwd [OR cut equivalent]

ps -ef -o comm | grep sshd | sed -n 1p

y=`eval ps ax | sed -n '/ppp/p' | awk '{ print $1 }'`

kill -9 `ps ax | awk '/ppp/ { print $1 }'


VI

# Usage : $0

[ $# -ne 1 ] && echo "Usage: $0 " && exit 1

vi <<-eof
:r $1
:%g/^[\t]*$/d
:wq!
eof


CUT & SORT


sort -k 2 names

cut -f 2 -d " " names | paste names - | sort -k 3 | cut -f 1

cut -f 2 -d " " names | paste - names | sort | cut -f 2

du -S | sort -n # Which directory has largest

echo "`echo $line | cut -d: -f 1` : `echo $line | cut -d: -f 5`"; done < /etc/passwd


FIND


find $PWD \( -name \*~ -or -name \*.o -or -name \*.log -or -name \*\#\) -exec rm -f {} \;

find $PWD \( -name \*.tex -or -name \*README\* -or -name \*readme\* \) -exec gzip -9 {} \;

find $1 -name core -exec ls -l {} \; | cut -c16-24

find / -user root -type file \( -perm -4000 -o -perm -6000 \) -print | xargs ls -l | tee -a suidlist


GREP


grep '[^ ].' logs # Otput lines with more than just space characters

grep '[^[:space:]].' logs # Output lines with more than just space or tab characters

grep . logs # Output all non-empty lines

egrep -v -i -e "fail|err|warn|not|illegal" sys_check.log

crontab -l | grep -v "^#" | more


EXPR

a=1234zipper43231

b=`expr length $a`

b=`expr index $a 23`

b=`expr substr $a 2 6`

b=`expr match "$a" '[0-9]*'`

b=`expr match "$a" '\([0-9]*\)'`


SUBSTRINGS


String=23skidoo1

echo ${String:2:4} # position 3 (0-1-2) 4 characters long

echo | awk '{ print substr("'"${String}"'",3,4)}' # Awk equivalent


PR


pr -t -o 5 -w 77 logs > output.file # Adding Margins

pr -d -t logs # Output double space


GENERAL SHELL OPERATIONS


(cd /source/directory && tar cf - . ) | (cd /dest/directory && tar xvfp -)




Perl Snippets


Text Computing

$ perl -i -pe 's/^__END__\n/\#$_/' ~/premson/test

$ perl -i -pe 's/^\#(__END__)$/$1/' ~/premson/test

$ perl -i -pe 's/(net_proxy_type = )\d+/${1}0/' ~/premson/test

$ perl -i -pe 's/(net_proxy_type = )\d+/${1}3/' ~/premson/test

$ perl -ne 'use Text::Wrap qw(wrap);print wrap("","",$_)' testing

$ perl -ne 'if(/(CRIT|ERROR)(.+)$/){$s="$1$2";$h{$s}++}END{$,=$\="\n";print sort keys %h}' testing



Timing

perl -e "use POSIX;print strftime \"%X \", localtime time;for('c'..'e', 'g'..'m', 'o'){print \"\$_\\n\";system \"ls -l test*\"}" (For looping time and listing)

perl -e "use POSIX;print strftime \"%X \", localtime time;for('a'..'o'){print \"\$_\\n\";system \"dd if=/dev/zero of=/dev/sd\$_ count=20000\"}" (Zeroing the disks)

perl -e "use POSIX;print strftime \"%X \", localtime time;for('a'..'o'){print \"\$_\\n\";system \"parted /dev/sd\$_ mklabel msdos\"}" (Partitioning the disks)



Determine CPAN Version

perl -e 'use FileHandle; print $FileHandle::VERSION."\n"' (on unix)

perl -e "use FileHandle; print $FileHandle::VERSION" (on windows)