We will never achieve true artificial intelligence until we break the barriers of silicon…
I am in the midst of sorting these commands out to be a bit more legible; however, in the meantime there are quite a few useful tricks here that I have acquired over the years.
Basic Admin Stuff
- groupadd -g 10139 groupname
- useradd -g groupname -u 139 -c ‘Full Name’ -m -s /bin/ksh username
- pkginfo -l `pkginfo -x | grep VRTS | awk ‘{print $1}’ `
- grep -li urlhost https-[a-z]*/config/obj.conf
- for dir in *.80 ; do $dir/start ; done
- for dir in https-*;do cp $dir/config/obj.conf $dir/config/obj.conf.20000512
- sed -n /\”ex/d $dir/config/obj.conf;done
- mt -f /dev/rmt/2 status# To check the status of a tape drive.
Regular Expression Stuff
- Deleting blank lines in the file using awk
- cat /tmp/test |awk ‘$0!~/^$/ {print $0}’ > /tmp/test
- In perl to match exactly www: /w{3}/ for 3 or more: /w{3,}/
Directory Renaming and Searcching
- find dir -depth -print |cpio -pdVm /disk1
- find opt -depth -print |cpio -pVmd /home
- find . -xdev -mtime +30 -ls
- find . -xdev -mtime -30 -ls
- find . -mount -mtime -3 -ls|more #Within 3 days.
- find . -name “*.zip” -mtime +14 -ls -exec rm {} \;
- find [befk]* lib lo* mnt nsr [ops]* [vwx]* -mtime -7 -print
- find [befk]* lib lo* mnt nsr [os]* pl* [vwx]* -mtime -7 -print
- find . -name ‘[S,s]hare’
SYSTEM TUNING
NOTE:INFO DOC 21622 at SUNSOLVE
CPU Control Commands–psrinfo,psradm,and psrset.
NOTE!:Refer to Man Pages on above commands before you use.
pmap -x PID #Prints out memory string which is usefull for performance tuning.
prtvtoc /dev/rdsk/c0t0d0s0 #for disk info
NETWORKING
# View just the NFS packets between sunroof and boutique: sunroof and boutique are server names:
- example$ snoop -i pkts rpc nfs and sunroof and boutique
# To see the top processes using CPU and memory:
- ps -eo pid,pcpu,args | sort +1n# for CPU percentage
- ps -eo pid,vsz,args | sort +1n# Kilobytes of virtual memory
# To view TCP setting on a Solaris (an alternative to ndd)
- netstat -sP tcp
SUN CLUSTER COMMANDS
- haswitch foo-db2 ha-billing # This procedure can also be done with scadmin
- scadmin switch foo foo-db2 ha-billing
Perl–Exercises
for dir in $(print whatever | perl -wpe ‘s/:/ /g;’); do
print -n $dir…
cd $dir && catman -w
print
done
Perl greping
- ls |perl -nwe ‘(/whatver/) && (print);’ |sort -n
- perl -wne ‘if (/W/) {print};’ /etc/motd
- perl -wne ‘/re/ && (print);’ /etc/motd
- perl -wne ‘print “Hello World\n”;’ < /etc/motd |wc -l
- perl -wne ‘print “Hello World\n”;’ < /etc/motd
- perl -wne ‘print “Hello World\n”;’ /etc/motd
- perl -wne ‘/re/ && (print);’ /etc/motd
- perl -wne ‘/re$/ && (print);’ /etc/motd
- perl -wne ‘if (/”(.*?)”/ ) {print “$1\n” };’ obj.conf > blah.txt
PERl FILE COMPARING
- perl -e “print while <>;” file1 file2 file3
PERL FILE MANIPULATION
- perl -p -i -e “s/abc/xyz/g” file
# remove all control M’s in a file
- perl -p -i -e ‘s/\r\n/\n/g’ file
# To append foo the end of a jsp group entry in /etc/group
- perl -p -i -e ‘s/(^jsp.+)/$1,foo/’ /etc/group
- perl -ne ‘if (/^\]*>//g;/
Backup and Procedures.
- ufsdump 0ucf /dev/rmt/0n /dev/rdsk/c0t0d0s0
#You must use the /0n to append to the tape.
- for file in `/bin/find /opt/WebSphere/AppServer/logs \( -name ‘BackUpLog’ -prune -o -name ‘*200*’ \) -type f -mtime +7`; do /usr/bin/gzip $file && /bin/mv $file.gz BackUpLog/. ;done
Sendmail Stuff
# Check the sendmail version.
- /usr/lib/sendmail -bt -d0.1 < /dev/null
Changing Case Examples
With vi
:%s/.*/\L&/
Conversely, :%s/.*/\U&/ will change all the characters to uppercase.
###
With the tr command
tr ‘[A-Z]‘ ‘[a-z]‘ < $fileName
AIX System Info
* Resetting a user ID
- # chsec -f /etc/security/lastlog -a unsuccessful_login_count=0 -s username
- # chuser “account_locked=false” username
- # passwd username
### AIX ####
- lsdev |grep hdisk
NOTE: To determine if disks on are on the SAN there are several ways, but here are a few examples.
- smitty disk_array
- lsdev -l hdisk2
- lsdev -Cc disk
uname -M # For Machine Type
- uname -L # Check if the machine is an LPAR
- lscfg
- lsattr -E -l proc0 | grep “Processor Speed”
#
- lsattr -El sys0 | grep realmem
- ls /dev/dsk/c?t?d?s2
WebSphere Application Server
- /var/mqm/mqgrs/QNAME/qmini
RHEL Commands
To ensure that clvmd is started at boot time, you can execute a chkconfig … on command on
the clvmd service, as follows:
- # chkconfig clvmd on
- # service clvmd start
Note
Shared storage for use in Red Hat Cluster Suite requires that you be running the cluster
logical volume manager daemon (clvmd) or the High Availability Logical Volume
Management agents (HA-LVM). If you are not able to use either the clvmd daemon or
HA-LVM for operational reasons or because you do not have the correct entitlements, you
must not use single-instance LVM on the shared disk as this may result in data corruption.
If you have any concerns please contact your Red Hat service representative.
Note
CLVM requires changes to the lvm.conf file for cluster-wide locking. Information
on configuring the lvm.conf file to support clustered locking is provided within the
lvm.conf file itself. For information about the lvm.conf file, see Appendix B, The LVM
Configuration Files.
- # lvcreate -L 50MB new_vg
- # lvcreate -v -L 50MB new_vg
NOTE: man lvm
4.2.1.2. Initializing Physical Volumes
Use the pvcreate command to initialize a block device to be used as a physical volume. Initialization
is analogous to formatting a file system.
The following command initializes /dev/sdd1, /dev/sde1, and /dev/sdf1 for use as LVM physical
volumes.
- pvcreate /dev/sdd1 /dev/sde1 /dev/sdf1
##
To initialize partitions rather than whole disks: run the pvcreate command on the partition. The
following example initializes the partition /dev/hdb1 as an LVM physical volume for later use as part
of an LVM logical volume.
pvcreate /dev/hdb1
###
- # lvmdiskscan
- # pvdisplay
- ethtool -i eth0
- lspci -v # To display all stats on device
- chkconfig clvmd –list
The following command disallows the allocation of physical extents on /dev/sdk1.
- pvchange -x n /dev/sdk1
#
- pvremove /dev/ram15
Labels on physical volume “/dev/ram15″ successfully wiped
#
NOTE The following command creates a volume group named vg1 that contains physical volumes /dev/
sdd1 and /dev/sde1.
- vgcreate vg1 /dev/sdd1 /dev/sde1
##
vgs
vgextend vg1 /dev/sdf1
vgdisplay new_vg
##
# pvdisplay /dev/hda1
The following command changes the maximum number of logical volumes of volume group vg00 to
128.
- vgchange -l 128 /dev/vg00
##
NOTE: Continue on section 4
##
- openssl s_client -connect www.soleas.net:443
##
Solaris Trouble Shooting and various commands
- svcadm enable sar
- kstat -n sd0,err
- fmadm faulty –a
- fmdump
- prstat –mL # For CPU statistics…
Disk trouble shooting commands.
- powermt display dev=all
- fcinfo hba-port
- /sbin/pp_inq -clar_wwn
- /sbin/pp_inq -no_dots -clar_wwn
- inq –clar_wwn
rpm -qa –queryformat “\n\nPACKAGE: %{name}\n” –scripts | less