misc Solaris tips... ymmv... these from: http://www.columbia.edu/~rtt2101/iaoq/ Solaris Infrequently Asked and Obscure Questions Composed by Argoth (2003.04.22) ^^ How do I do a recursive grep? 1. Method 1 (recommended) 1. /usr/bin/find . | /usr/bin/xargs /usr/bin/grep PATTERN 2. displays filename:match 2. Method 2 (recommended) 1. /usr/bin/find . -exec /usr/bin/grep PATTERN {} /dev/null \; 2. displays filename:match How do I find out the number of files used on local filesystems? 1. System V 1. /usr/bin/df -F ufs -o i 2. Berkeley 1. /usr/ucb/df -i # How do I list available signals? 1. /usr/bin/kill -l 2. Read /usr/include/sys/signal.h 3. Solaris 2.6/7 1. /usr/bin/man -s 5 signal 4. Solaris 8 1. /usr/bin/man -s 3HEAD signal # ^^ How do I show how a process will respond to a given signal? 1. /usr/proc/bin/psig pid 1. you must be root or own the process to read /proc/pid # ^^ How do I remove a file that begins with a - ? 1. This problem, contrary to popular belief, has nothing to do with the shell. It has to do with how rm(1) parses options. 2. Method 1 1. /usr/bin/rm ./-file 3. Method 2 1. /usr/bin/rm -- -file 2. many programs use getopt(), thus they'll interpret - as an argument, to tell getopt() there are no more arguments to parse, use -- # ^^ ls(1) no longer works, how can i view directory contents? 1. echo * 1. This method uses the shell built-in echo() in conjunction with the * matching properties to generate listing of current directory. # ^^ How can I tell what the various ERROR codes mean? 1. Read /usr/include/sys/errno.h 2. /usr/bin/man -s 2 Intro # ^^ How can I create a file of arbitrary size? 1. Method 1 1. /usr/sbin/mkfile 10m file 1. Creates a 10 Megabyte file 2. For each write() operation, there is no accompanying read() operation, making this method very efficient 2. Method 2 (recommended) 1. /usr/bin/dd < /dev/zero > file bs=1024 seek=10240 count=1 1. Creates a 10 Megabyte file 2. This method does not require many reads and writes since the file is sparse. # ^^ How can I get seconds from epoch? 1. Solaris 2.6/7 1. /usr/bin/truss /usr/bin/date 2>&1 | /usr/bin/awk '/^time/ {print $NF}' 2. Solaris 8 1. /usr/bin/perl -e 'printf "%d\n", time;' # ^^ How do I get yesterdays date? 1. Solaris 2.6/7 1. TZ=timezone+shift date 1. replace timezone with EST,CST,PST,etc 2. replace shift with 24-(shift from GMT) 3. Example 1. EST=-5 2. 24-(-5)=29 3. TZ=EST+29 date 2. echo `echo '*time-0t86400=Y' | /usr/bin/adb -k | tail -2` 2. Solaris 8 1. /usr/bin/perl -e 'printf "%s\n",scalar localtime(time-86400)' 2. This breaks twice a year during the DST transition. 3. From perlfaq4; Note very carefully that the code above assumes that your days are twenty-four hours each. For most people, there are two days a year when they aren't: the switch to and from summer time throws this off. A solution to this issue is offered by Russ Allbery. sub yesterday { my $now = defined $_[0] ? $_[0] : time; my $then = $now - 60 * 60 * 24; my $ndst = (localtime $now)[8] > 0; my $tdst = (localtime $then)[8] > 0; $then - ($tdst - $ndst) * 60 * 60; } # Should give you "this time yesterday" in seconds since epoch relative to # the first argument or the current time if no argument is given and # suitable for passing to localtime or whatever else you need to do with # it. $ndst is whether we're currently in daylight savings time; $tdst is # whether the point 24 hours ago was in daylight savings time. If $tdst # and $ndst are the same, a boundary wasn't crossed, and the correction # will subtract 0. If $tdst is 1 and $ndst is 0, subtract an hour more # from yesterday's time since we gained an extra hour while going off # daylight savings time. If $tdst is 0 and $ndst is 1, subtract a # negative hour (add an hour) to yesterday's time since we lost an hour. # # All of this is because during those days when one switches off or onto # DST, a "day" isn't 24 hours long; it's either 23 or 25. # # The explicit settings of $ndst and $tdst are necessary because localtime # only says it returns the system tm struct, and the system tm struct at # least on Solaris doesn't guarantee any particular positive value (like, # say, 1) for isdst, just a positive value. And that value can # potentially be negative, if DST information isn't available (this sub # just treats those cases like no DST). # # Note that between 2am and 3am on the day after the time zone switches # off daylight savings time, the exact hour of "yesterday" corresponding # to the current hour is not clearly defined. Note also that if used # between 2am and 3am the day after the change to daylight savings time, # the result will be between 3am and 4am of the previous day; it's # arguable whether this is correct. # # This sub does not attempt to deal with leap seconds (most things don't). # # Copyright relinquished 1999 by Russ Allbery # This code is in the public domain # ^^ How do I get access, modify, creation time of a file? 1. Access time (atime) 1. /usr/bin/ls -ul filename 2. Modify time (mtime) 1. /usr/bin/ls -l filename 3. Creation time 1. There is no way to determine creation time in the ufs filesystem 4. Change time (ctime) 1. /usr/bin/ls -cl filename 2. this includes status changes (like permissions) 5. All in one (root) 1. /usr/bin/ls -i filename | /usr/bin/awk \ '{print "0t"$1":ino?i"}' | /usr/sbin/fsdb -F ufs /dev/rdsk/c0t0d0s0 1. assumes raw device of filesystem for filename is c0t0d0s0 # ^^ What is load? 1. Load is the number of processes currently in the run queue. 2. Method 1 1. /usr/bin/w -u 2. displays load average over last 1, 5 and 15 minutes 3. Method 2 1. /usr/bin/uptime 2. displays load average over last 1, 5 and 15 minutes # ^^ What is the run queue? 1. The run queue consists of processes ready to run, i.e not otherwise blocked or waiting for i/o, that are contending for cpu resources to become available. 2. /usr/bin/vmstat 1 2 1. Current run queue is indicated by the "r" heading 2. First line of output is average since system boot # ^^ How can I copy directory contents to a remote machine (without nfs)? 1. /usr/bin/tar -cf - sourcepath | /usr/bin/rsh remote " cd /targetpath ; /usr/bin/tar -xBf - " 2. /usr/bin/find sourcepath | /usr/bin/cpio -o | /usr/bin/rsh remote "cd /targetpath ; /usr/bin/cpio -id" Shell 1. ^^ My setuid shell script keeps running as the real user, why? 1. Bourne Shell 1. The use of setuid shell scripts is discouraged 1. If you must, protect yourself with trap() 2. Bourne shell always sets the effective user and group IDs to the real user and group IDs. 3. /bin/sh -p 2. C Shell 1. The use of setuid shell scripts is discouraged 2. C shell does not run setuid/setgid shell scripts by default 1. "/dev/fd/3: Bad file number" is a common error 3. /bin/csh -b 2. ^^ Why is cd() a shell built-in rather than an executable? 1. Quick Answer 1. a child process cannot modify the environment of the parent 2. Long Answer 1. a shell fork()s and then exec()s the requested executable. in doing so, the newly created process begins life with the environment of the parent process. the new child process then manipulates the environment in the manner requested, in this case a modification of the directory stack, and returns to the parent. however, since this change occurred in the child address space, the parent's environment was never changed, and therefore the requested operation did not take place. 3. ^^ How do I redirect stderr? 1. Bourne Shell 1. to stdout 1. command 2>&1 2. to file 1. command 2> file 3. to null 1. command 2> /dev/null # What is the default memory page size? 1. sun4u 1. 8192 bytes 2. sun4c/sun4m/sun4d 1. 4096 bytes # ^^ What is the current memory page size? 1. /usr/bin/pagesize Filesystem 1. ^^ How do I get a list of superblocks on a filesystem? 1. assumes filesystem was created with default parameters 2. /usr/sbin/newfs -N device | awk '/^ [0-9]/' 2. ^^ How do I grow/shrink a ufs filesystem? 1. Grow 1. Unmounted filesystem (not /, /usr, /var) 1. Allocate additional contiguous disk space with format(1m) 1. Unnecessary if you are using a volume manager 2. /usr/lib/fs/ufs/mkfs -G rawdevice newsize 2. Mounted filesytem (not /, /usr, /var) 1. Allocate additional contiguous disk space with format(1m) 1. Unnecessary if you are using a volume manager 2. /usr/lib/fs/ufs/mkfs -G -M mountpoint rawdevice newsize 2. Shrink 1. You cannot shrink a UFS filesystem 3. ^^ How do I determine what type of filesystem a given device has? 1. /usr/sbin/fstyp blockdevice 4. ^^ What are inodes 0, 1, and 2 used for? 1. Inode 0 is unusable. It is used to mark unused inodes. 2. Inode 1 is unusable. Use of this inode for bad block information is deprecated. 3. Inode 2 is "/" or "root" of the filesystem. 5. ^^ What do I do if I have a corrupt boot block? 1. ok boot cdrom -s 2. /usr/sbin/installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c#t#d#s# X11 # How do I use an alternate window manager? 1. Bypassing CDE 1. echo "exec /path/to/alternate/window/manager" > .xsession 2. Maintaining CDE 1. Xresources 1. cd /usr/dt/config/C/Xresources.d 2. /usr/bin/cp Xresources.ow Xresources.wm 3. Modify Xresources.wm 1. Dtlogin*altDtName: Alternate WindowManager 2. Dtlogin*altDtKey: /path/to/alternate/window/manager 3. Dtlogin*altDtStart: /usr/dt/config/Xsession.wm 4. Dtlogin*altDtLogo: WMlogo 2. Xsession 1. cd /usr/dt/config 2. /usr/bin/cp Xsession.ow Xsession.wm 3. Modify Xsession.wm 1. Place windowmanager environment 3. Logo (for display in CDE login) 1. cd /usr/dt/appconfig/icons/C 2. /usr/bin/cp OWlogo.pm WMlogo.pm 1. Replace this with your own XPM file # ^^ How do I disable X Windows from starting at boot? 1. Method 1 (recommended) 1. /usr/dt/bin/dtconfig -d 2. Method 2 1. /usr/bin/mv /etc/rc2.d/S99dtlogin /etc/rc2.d/s99dtlogin # ^^ How do I disable that annoying beep? 1. Method 1 1. /usr/openwin/bin/xset b 0 2. Method 2 1. /usr/openwin/bin/xset b off 3. Method 3 1. /usr/openwin/bin/xset -b # ^^ How do I disable the CDE front panel? 1. Modify $HOME/.Xdefaults 1. Dtwm*useFrontPanel: false # Veritas Volume Manager 1. ^^ How do I allow a user to write to a managed raw device? 1. /usr/bin/chown is not persistent across reboots 2. /usr/sbin/vxedit set user=oracle group=dba mode=600 volume 2. ^^ How do I move rootdg from one system to another? 1. without this procedure, you will get error messages at boot because the system sees two instances of rootdg 2. /etc/vx/diag.d/vxprivutil list /dev/rdsk/c#t#d#s# | awk '/^group/' 1. note the disk group id number 3. /usr/sbin/vxdg -C -n newdg import dgid 1. dgid is group id from (a) 2. this command creates disk group newdg and imports the disk 3. ^^ What is the difference between Disk Suite and Veritas Volume Manager? 1. Veritas Volume Manager logs metadata and filesystem data, whereas Disk Suite logs only metadata 4. ^^ What is the difference between RAID 0+1 and 1+0? 1. Diagram A (RAID 0+1) 1. [ v] || [ p] || [sv] || =======================[v2]======================= | | ==========[p2]========== ==========[p2]========== | | | | =[s2]==[s2]==[s2]==[s2]= =[s2]==[s2]==[s2]==[s2]= 2. Striping occurs at the subvolume(p2) layer. 3. Mirroring occurs at the subplex (v2) layer. 2. Diagram B (RAID 1+0) 1. [ v] || [ p] || ==========================[sv]========================== | | ===========[v2]=========== ===========[v2]=========== | | | | ====[p2]==== ====[p2]==== ====[p2]==== ====[p2]==== | | | | | | | | =[s2]==[s2]= =[s2]==[s2]= =[s2]==[s2]= =[s2]==[s2]= 2. Striping occurs at the subvolume(sv) layer. 3. Mirroring occurs at the subplex (p2) layer. 3. The diagrams above use the Veritas 3.x nomenclature. 4. Volume Resynchronization 1. There is an additional layer of abstraction in RAID 1+0 that allows for isolation of the subdisks into subplexes. Since the subplexes are smaller than the plexes in RAID 0+1, time to resynchronize is reduced. 5. Fault Tolerance 1. There is an additional layer of abstraction in RAID 1+0 that allows for isolation of the subdisks into subplexes. Since the subplexes now contain reduced amounts of disks, and are composed solely of single subdisk mirrors, the RAID 1+0 volume can sustain the loss of multiple disks pending all of the disks within a given subplex do not fail. # ^^ Veritas Filesystem 1. ^^ How do I make vxfs support large files? 1. /usr/lib/fs/vxfs/fsadm -o largefiles /mountpoint 2. ^^ How do I defragment a vxfs filesystem? 1. Determine if necessary 1. Method 1 1. /usr/lib/fs/vxfs/df -o s /mountpoint 2. Method 2 1. /usr/lib/fs/vxfs/fsadm -ED /mountpoint 1. reports on both extent and directory fragmentation 2. /usr/lib/fs/vxfs/fsadm -ed /mountpoint 1. reorganizes extents and directories 3. ^^ How do I grow/shrink a vxfs filesystem? 1. vxfs, unlike ufs, filesystems can be shrunk. 2. Mounted filesystem (not /, /usr, /var) 1. /usr/lib/fs/vxfs/fsadm -b size /mountpoint 4. ^^ How do I prevent the vxfs filesystem from buffering my database files? 1. Method 1 (persistent) 1. Add "mincache=direct,convosync=direct" to mount options in /etc/vfstab 2. Method 2 (not persistent, system up) 1. /usr/sbin/mount -o remount,mincache=direct,convosync=direct, /mountpoint 2. [UNVERIFIED] please email if you can confirm 3. Method 3 (Quick I/O) 1. This is presented as an add-on module for filesystem and ships with Veritas Database Edition. 2. Quick I/O presents files with preallocated extents as character devices to the application in the form of ".filename::cdev:vxfs" by use of the vxqio device driver 3. Quick I/O is enabled per filesystem, by default, but is configured on a per file basis 5. ^^ How do I create a Quick I/O file? 1. Oracle 1. /usr/sbin/qiomkfile -h
-s /path/to/dbfile 1.
should correspond to DB_BLOCK_SIZE, 32k by default 2. should correspond to the size of the database. by allocating appropriate extents you can prevent fragmentation 6. ^^ What is the default vxfs block size? 1. Filesystem size <= 8GB 1. 1024 bytes 2. Filesystem size 8GB <= 16GB 1. 2048 bytes 3. Filesystem size 16GB <= 32GB 1. 4096 bytes 4. Filesystem > 32GB 1. 8192 bytes # How do I configure what my network card is capable of? 1. Method 1 1. /etc/system 1. this sets global defaults for the driver, therefore it is effective for all instances of the card 2. HME/QFE/GE interfaces 1. set hme:hme_adv_autoneg_cap=0 1. Advertise auto negotiate capability 2. 0 - off 3. 1 - on 2. set hme:hme_adv_100T4=0 1. Advertise deprecated 100Mbit T4 capability 2. 0 - off 3. 1 - on 3. set hme:hme_adv_100fdx=0 1. Advertise 100Mbit full duplex capability 2. 0 - off 3. 1 - on 4. set hme:hme_adv_100hdx=0 1. Advertise 100Mbit half duplex capability 2. 0 - off 3. 1 - on 5. set hme:hme_adv_10fdx=0 1. Advertise 10Mbit full duplex capability 2. 0 - off 3. 1 - on 6. set hme:hme_adv_10hdx=0 1. Advertise 10Mbit half duplex capability 2. 0 - off 3. 1 - on 3. ERI interfaces 1. set eri:adv_autoneg_cap=0 1. Advertise auto negotiate capability 2. 0 - off 3. 1 - on 2. set eri:adv_100T4=0 1. Advertise deprecated 100Mbit T4 capability 2. 0 - off 3. 1 - on 3. set eri:adv_100fdx=0 1. Advertise 100Mbit full duplex capability 2. 0 - off 3. 1 - on 4. set eri:adv_100hdx=0 1. Advertise 100Mbit half duplex capability 2. 0 - off 3. 1 - on 5. set eri:adv_10fdx=0 1. Advertise 10Mbit full duplex capability 2. 0 - off 3. 1 - on 6. set eri:adv_10hdx=0 1. Advertise 10Mbit half duplex capability 2. 0 - off 3. 1 - on 2. Method 2 1. This method allows more granular control over the interface driver. You can specify configuration by port. 2. /usr/sbin/ndd -set /dev/hme instance 0 1. Instance 0 - hme0 2. Instance 1 - hme1 3. /usr/sbin/ndd -set /dev/hme adv_autoneg_cap 0 1. Advertise auto negotiate capability 2. 0 - off 3. 1 - on 4. /usr/sbin/ndd -set /dev/hme adv_100fdx_cap 0 1. Advertise 100Mbit full duplex capability 2. 0 - off 3. 1 - on 5. /usr/sbin/ndd -set /dev/hme adv_100hdx_cap 0 1. Advertise 100Mbit half duplex capability 2. 0 - off 3. 1 - on 6. /usr/sbin/ndd -set /dev/hme adv_100T4_cap 0 1. Advertise deprecated 100Mbit T4 capability 2. 0 - off 3. 1 - on 7. /usr/sbin/ndd -set /dev/hme adv_10fdx_cap 0 1. Advertise 10Mbit full duplex capability 2. 0 - off 3. 1 - on 8. /usr/sbin/ndd -set /dev/hme adv_10hdx_cap 0 1. Advertise 10Mbit half duplex capability 2. 0 - off 3. 1 - on # ^^ How do I display what my link partner is capable of? 1. /usr/sbin/ndd -set /dev/hme instance 0 1. Instance 0 - hme0 2. Instance 1 - hme1 2. /usr/sbin/ndd -get /dev/hme lp_autoneg_cap 1. link partner has auto negotiate capability 2. 0 - off 3. 1 - on 3. /usr/sbin/ndd -get /dev/hme lp_100fdx_cap 1. link partner has 100Mbit full duplex capability 2. 0 - off 3. 1 - on 4. /usr/sbin/ndd -get /dev/hme lp_100hdx_cap 1. link partner has 100Mbit half duplex capability 2. 0 - off 3. 1 - on 5. /usr/sbin/ndd -get /dev/hme lp_100T4_cap 1. link partner has deprecated 100Mbit T4 capability 2. 0 - off 3. 1 - on 6. /usr/sbin/ndd -get /dev/hme lp_10fdx_cap 1. link partner has 10Mbit full duplex capability 2. 0 - off 3. 1 - on 7. /usr/sbin/ndd -get /dev/hme lp_10hdx_cap 1. link partner has 10Mbit half duplex capability 2. 0 - off 3. 1 - on # ^^ How can I tell if my card is active on the network? 1. Method 1 (Openboot PROM) 1. watch-net