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 /* Provides cumulative system report. */
# sar -a /* Report use of file access system routines. */
# sar -u /* Report CPU Utilization */
# telnet 13 | grep ':' /* Get the time on remote Unix machine */
# uname -a /* Displays system information */
# vmstat 10 /* Displays summary of what the system is doing every 10 seconds */
# who -b /* Displays the date of the last system reboot. */
# ypcat hosts \ /* Take the input of "ypcat hosts" or "cat /etc/inet/hosts" and sort by IP. */
| sort -n -t. +0 -1 +1 -2 +2 -3 +3 -4
Hardware
# cfgadm /* Verify reconfigurable hardware resources */
# m64config -prconf /* Print M64 hardware configuration */
# m64config -depth 8|24 /* Sets the screen depth of your M64 graphics accelerator */
# m64config -res 'video_mode' /* Change the resolution of your M64 graphics accelerator */
Kernel
# /usr/sbin/modinfo /* Display kernel module information */
# /usr/sbin/modload /* Load a kernel module */
# /usr/sbin/modunload -i /* Unload a kernel module */
# nm -x /dev/ksyms | grep OBJ | more /* Tuneable kernel parameters */
# /usr/sbin/sysdef /* Show system kernal tunable details */
# /usr/bin/ldd [filename] /* List the dynamic dependencies of executable files */
Debugging
# truss -f -p /* Trace doing of given command ( useful debugging ) */
Disk Commands
# fdformat -d -U /* Format diskette */
# format /* Partition the devices */
# iostat -E /* Command to display drives statistics */
# mount -F hsfs -o ro /dev/sr0 /cdrom /* Mount an ISO 9660 CDROM */
# newfs -Nv /dev/rdsk/c0t0d0s1 /* To view the superfblocks available */
# prtvtoc /dev/rdsk/c0t0d0s2 /* Disk geometry and partitioning info */
# quot -af /* How much space is used by users in kilobytes */
# du -sk . /* Reports only total disk space used in Kilobytes */
# du -sk *|sort -k1,1n /* Reports disk space used in Kilobytes in present directory sorted in ascending */
# du -sk /var | sort -nr /* Sort subdirectories in greater than order */
# du -ad /var | sort -nr /* Tells you how big the /var files are in reverse order */
File Manipulation
# dos2unix | -ascii /* Converts DOS file formats to Unix */
# split /* Split files into pieces */
# [vi] : %s/existing/new/g /* Search and Replace text in vi */
# [vi] :set nu /* Set line numbers in vi */
# [vi] :set ts=[num] /* Set tab stops in vi */
File System
# cat /dev/null > filename /* Zero's out the file without breaking pipe */
# dd if=/dev/rdsk/... of=/dev/rdsk/... bs=4096 /* Make a mirror image of your boot disk */
# df -k | grep dg| awk '{print $6}' \ /* Unmount all file systems in disk group dg */
| xargs -n 1 umount
# fsck -F ufs /dev/rdsk/c0t0d0s0 /* Check a UFS filesystem on c0t0d0s0 */
# fsck -F ufs -y /dev/rdsk/c0t0d0s0 /* Check answering yes to all questions */
# fsck -F ufs -o b=97472 /dev/rdsk/c0t0d0s0 /* Check using an alternate super block */
# gzip -dc file1.tar.gz | tar xf - /* Unpack .tar.gz files in place */
# gzip -d -c tarball.tgz | \ /* Unpacking tarballs to diff location */
(cd /[dir];tar xf - ) &
# ln [-fhns] /* Creating hard links and soft links */
# ls -la | awk '{print $5," ",$9}' | sort -rn /* File sizes of current directory */
# mount -f pcfs /dev/dsk/c0d0p1 /export/dos /* Mount DOS fdisk partition from Solaris */
# mount -F ufs -o rw,remount / /* Used to remount root to make it writeable */
# mount -o remount,logging /spare /* Re-mount the ro file system rw and turn on ufs logging */
# pax -rw . /newdir /* Efficient alternative for copying directories */
# prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2 /* Cloning Partitiontables */
Backup
# tar cvf filename.tar /* Create a tape (tar) archive */
# tar xvf filename.tar /* Extract a tape (tar) archive */
# tar tvf filename.tar /* List a tape (tar) archive */
# tar cf - . | (cd /newdir ; tar xf -) /* Recursively copy files and their permissions */
# /sbin/uadmin x x /* Syncs File Systems and Reboots systems fast */
# X=$(wc -l < filename); echo $X /* Count number of lines in a file into a variable (ksh) */
# zcat [cpio file] | cpio -itmv /* Show the contents of a compressed cpio */
# zcat patch_file.tar.Z | tar xvf - /* Extract the patch_file that is a compressed tar file */
File Transfer
# get filename.suffix |"tar xf -" /* Undocumented Feature of FTP */
# put "| tar cf - ." filename.tar /* Undocumented Feature of FTP */
# find . -depth | cpio -pdmv /pathtobecopiedto /* Fast alternative to cp -pr */
# sendport /* Transferring large numbers of files within the same ftp control session */
Network Information
# ndd /dev/arp arp_cache_report /* Prints ARP table in cache with IP and MAC address */
# netstat -a | grep EST | wc -l /* Displays number active established connections to the localhost */
# netstat -k hme0 /* Undocumented netstat command */
# netstat -i /* Show the TCP/IP network interfaces */
# netstat -np /* Similar to arp -a without name resolution */
# netstat -r /* Show network route table */
# netstat -rn /* Displays routing information but bypasses hostname lookup. */
# netstat -a | more /* Show the state of all sockets */
# traceroute /* Follow the route to the ipaddress */
Driver Parameters
# ndd /dev/ip \? /* Shows IP variables in the kernel */
# ndd /dev/ip ip_forwarding /* Tells you if forwarding is on (=1) */
# ndd -set /dev/ip ip_forwarding 1 /* Enables IP forwarding between interfaces */
Network/Tuning
# ifconfig eth0 mtu 1500 /* Change MTU of interface */
# ifconfig eth0 10.1.1.1 netmask 255.255.255.0 /* Add an Interface */
# ifconfig hme0:1 inet 10.210.xx.xxx netmask \ /* Virtual Interfaces */
255.255.0.0 broadcast 10.210.xxx.xxx
# /sbin/ifconfig hme0:1 up /* Bring virtual interface up */
# ndd -get /dev/hme link_speed /* To get NIC speed) */
# ndd -get /dev/hme link_mode /* To get NIC duplex mode */
To set NIC (hme0) values
# ndd -set /dev/hme instance 0 /* To set the first instance of the card */
# ndd -set /dev/hme link_mode 1 /* To set the duplex to full */
To set the hme0 to 100Mbps Full Duplex (to permanently set modify /etc/system)
# set hme:hme_adv_autoneg_cap=0
# set hme:hme_adv_100T4_cap=0
# set hme:hme_adv_100fdx_cap=1
# set hme:hme_adv_100hdx_cap=0
# set hme:hme_adv_10fdx_cap=0
# set hme:hme_adv_10hdx_cap=0
# ndd -set /dev/hme adv_100fdx_cap 1 /* Nailling to 100Mbps */
# ndd -set /dev/ip ip_addrs_per_if 1-8192 /* To set more than 256 virtual ip addresses. */
# ndd -set /dev/tcp tcp_xmit_hiwat 65535 /* Increase TCP-transmitbuffers */
# ndd -set /dev/tcp tcp_recv_hiwat 65535 /* Increase TCP-receivebuffers */
ARPing
# arp -a . /* Shows the ethernet address arp table */
# arp -d myhost /* Delete a stale ethernet entry for host myhost */
Route Configuration
# route add -net 128.50.0.0 128.50.1.6 1 /* Adds route to 128.50 network via 128.50.1.6 */
# route change 128.50.0.0 128.50.1.5 /* Changes the destination address for a route */
# route delete -net 128.50.0.0 128.50.1.6 /* Deletes route to 128.50 network */
# route get [hostname] /* Which interface will be used to contact hostname */
# route monitor /* Monitors traffic to the routes */
# route flush /* Removes all entries in the route table */
Sample routing on Linux
# route add -host x.y.82.41 eth1
# route add -host x.y.82.42 eth1
# route add -host x.y.82.43 eth1
# route add -host x.y.82.44 eth1
# route add -net x.y.116.0 gw x.y.80.1 netmask x.y.255.0 eth0
# route add -net x.y.117.0 gw x.y.80.1 netmask x.y.255.0 eth0
Searching Items
# egrep "patterna|patternb" /* Search for multiple patterns within the same file */
# find . -exec egrep -li "str" {} \; /* Find a string in files starting cwd */
# find / -fstype nfs -prune -o fstype \ /* Find without traversing NFS mounted file systems */
autofs -prune -o -name filename -print
# find . -mtime -1 -type f /* Find recently modified files */
# find / -mtime <# of days> /* Find files modified during the past # of days */
# find . ! -mtime - | xargs rm -rf /* Finds and removes files older than specified */
# find ./ \! -type f -exec ls -l {} \;| \ /* Find number of directories under the current directory */
grep -v '^[l|p|s|-]'|grep -v 'total' | wc -l
# find . -type f -exec grep "str" {} \; -print /* Find files (and content) containing within directory tree */
# find . -type f -exec grep -l "str" {} \; /* Find filenames containing within directory tree */
# find . -type f -print | xargs grep -i pattern /* Recursive grep on files */
# find / -user /* Find all files owned by */
# find / | grep [file mask] /* Fast way to search for files */
# find -name "" \ /* Recursively finds files by name and automatically removes them */
-exec rm -rf {} \;
# find /proc/*/fd -links 0 -type f \ /* Find large files held open by a process */
-size +2000 -ls
# grep filename /var/sadm/install/contents \ /* Find which package contains a particular file */
| awk '{ print $1 ' ' $10 }'
# ls -lR | grep /* Fast alternative to find */
Security
# echo 'Please go away' > /etc/nologin /* Stops users logging in */
# find / -perm -0777 -type d -ls /* Find all your writable directories */
# find / -type f -perm -2000 -print /* Find all SGID files */
# find / -type f -perm -4000 -print /* find all SUID files */
# trap 'exit 0' 1 2 3 9 15 /* Trap specific signals and exit */
Set Terminal Options
# stty erase ^H /* Sets the Backspace Key to erase */
# stty erase ^? /* Sets the Delete Key to erase */
# stty sane /* Rreset terminal after viewing a binary file. */
# tput rmacs /* Reset to standard char set */
General
# /usr/bin/catman -w /* Create windex databases for man page directories */
# FQ_FILENAME=; \ /* Extract directory from fully-qualified file name. */
echo ${FQ_FILENAME%/*}
# mailx -H -u /* List out mail headers for specified user */
# set filec /* Set file-completion for csh */
# uuencode [filename] | mailx -s "Subj" mailto /* Send files as attachments */
SUN - Administrating NIS
# ypwhich (Tells you the yp server connected to)
# yppasswd user (Change password in NIS)
# yppush -p 6 (This example allows up to six simultaneous transfers to NIS slave servers)
# ypcat passwd | grep user (Gives info about user from NIS server)
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)