Questions and Answers
I. System
A. General
1. How do I untar a file with absolute paths to a relative location?
a. Method
1 (user)
1. /usr/bin/pax -r -s ',^/,,' -f file.tar
b. Method
2 (root)
1. /usr/bin/cp /usr/sbin/static/tar /tmp
2. /usr/bin/dd if=file.tar | /usr/bin/chroot /tmp ./tar xf -
2. How do I do a recursive grep?
a. Method
1 (recommended)
1. /usr/bin/find . | /usr/bin/xargs /usr/bin/grep PATTERN
2. displays filename:match
b. Method
2
1. /usr/bin/find . -exec /usr/bin/grep PATTERN {} \; -print
2. displays match followed by filename containing match
3. How do I find out the number of files used on local filesystems?
a. System
V
1. /usr/bin/df -F ufs -o i
b.
Berkeley
1. /usr/ucb/df -i
4. How do I compress a datastream?
a. mkfifo
fifo
b.
compress < fifo > file.Z &
c.
/usr/bin/cat file > fifo
1. compresses file into file.Z
5. How do I list available signals?
a.
/usr/bin/kill -l
b. Read
/usr/include/sys/signal.h
c.
Solaris 2.6/7
1. /usr/bin/man -s 5 signal
d.
Solaris 8
1. /usr/bin/man -s 3HEAD signal
6. How do I show how a process will respond to a given signal?
a.
/usr/proc/bin/psig pid
1. you must be root or own the process to read /proc/pid
7. How do I remove a file that begins with a - ?
a. This
problem, contrary to popular belief, has nothing to do with
the shell. It has to do with how rm(1) parses options.
b. Method
1
1. /usr/bin/rm ./-file
c. Method
2
1. /usr/bin/rm -- -file
a. many programs use getopt(), thus they'll interpret - as
an argument, to tell getopt() there are no more
arguments to parse, use --
8. ls(1) no longer works, how can i view directory contents?
a. echo *
1. This method uses the shell built-in echo() in conjunction
with the * matching properties to generate listing of
current directory.
9. How can I tell what the various ERROR codes mean?
a. Read /usr/include/sys/errno.h
10. How can I create a file of arbitrary size?
a. Method
1 (recommended)
1. /usr/sbin/mkfile 10m file
a. Creates a 10 Megabyte file
b. For each write() operation, there is no accompanying
read() operation, making this method very efficient
b. Method
2
1. /usr/bin/dd < /dev/zero > file bs=5120 count=2000
a. Creates a 10 Megabyte file
b. For each write() operation there is an accompanying
read() operation, making this method less efficient
c. What it lacks in efficiency, it more than makes up in
configurability
11. How can I get seconds from epoch?
a. Solaris 2.6/7
1. /usr/bin/truss /usr/bin/date 2>&1 | /usr/bin/awk '/^time/ {print $NF}'
b. Solaris 8
1. /usr/bin/perl -e 'printf "%d\n", time;'
12. How do I get yesterdays date?
a. echo '*time-0t86400=Y' | /usr/bin/adb -k
13. How do I get access, modify, creation time of a file?
a. (/usr/bin/truss -t stat -v all /usr/bin/file filename 2>&3 >/dev/null) 3>&1 | /usr/bin/tail -6
B. Shell
1. My setuid shell script keeps running as the real user, why?
a. Bourne Shell
1. The use of setuid shell scripts is discouraged
a. 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
b. C Shell
1. The use of setuid shell scripts is discouraged
2. C shell does not run setuid/setgid shell scripts by default
a. "/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?
a. Quick Answer
1. a child process cannot modify the environment of the parent
b. 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?
a. Bourne Shell
1. to stdout
a. command 2>&1
2. to file
a. command 2> file
3. to null
a. command 2> /dev/null
b. C Shell
1. to stdout
a. command >& /dev/tty
2. to file (without affecting stdout)
a. ( command > /dev/tty ) >& file
3. to null (without affecting stdout)
a. ( command > /dev/tty ) >& /dev/null
C. General Kernel
1. Where do I put kernel configuration?
a. /etc/system
2. How do I add more PTYs?
a. Do not attempt to do this with '/usr/bin/adb -k'.
b. Solaris <= 7
1. Modify /etc/system
a. set pt_cnt=X
2. /usr/sbin/reboot -- -r
c. Solaris 8
1. Dynamically allocated.
2. Limit is forced by modifying /etc/system
a. set pt_cnt=X
3. /usr/sbin/reboot -- -r
3. What is shared memory?
a. Just as it sounds. Shared memory is an Interprocess
Communication (IPC) mechanism used by multiple processes to
access common memory segments.
4. How do I know the limits for shared memory kernel tunables?
a. Read /usr/include/shm.h
5. What is a semaphore?
a. A non-negative integer that is incremented or decremented
relative to available resources.
6. How do I know the limits for semaphore kernel tunables?
a. Read /usr/include/sem.h
7. What is a door?
a. A door is a file descriptor that describes a method for
interprocess communication between client and server
threads.
b. A door file appears with file mode D---------.
8. add_drv(1m) fails with "add_drv/rem_drv currently busy; try later".
a. rm /tmp/AdDrEm.lck
D. Devices
1. How do I add a disk to the system? (Everything attached correctly)
a. While the system is up ( no fcal)
1. Solaris <= 7
a. Generate /devices structure
1. /usr/sbin/drvconfig
b. Generate /dev/dsk and /dev/rdsk links
2. /usr/sbin/disks
2. Solaris 8
a. Generate /devices and /dev/dsk, /dev/rdsk links
1. /usr/sbin/devfsadm
b. While the system is up ( fcal )
1. Get the enclosure name
a. /usr/sbin/luxadm probe
2. Add the disk
a. /usr/sbin/luxadm insert_device enclosure,slot
c. With a reboot
1. Method 1
a. /usr/sbin/shutdown -g0 -i0 "disk addition"
b. Reconfigure Boot (From OpenBoot PROM monitor)
1. boot -r
2. Method 2
a. /usr/bin/touch /reconfigure
b. /usr/sbin/shutdown -g0 -i6 "disk addition"
2. How do I know what the video configuration for my adapter/display is?
a. M64 Adapter
1. /usr/sbin/m64config -propt
b. Creator 3D Adapter
1. /usr/sbin/ffbconfig -propt
3. How do I know what the adapter/display is capable of?
a. M64 Adapter
1. Display what the card is capable of
a. /usr/sbin/m64config -res \?
2. Display what the card and display are capable of
a. /usr/sbin/m64config -prconf
b. Creator 3D Adapter
1. Display what the card is capable of
a. /usr/sbin/ffbconfig -res \?
2. Display what the card and display are capable of
a. /usr/sbin/ffbconfig -prconf
4. How do I change color depth?
a. M64 Adapter
1. /usr/sbin/m64config -depth 24
a. Attempts to set the default color depth to 24.
a. Creator 3D Adapter
1. /usr/sbin/ffbconfig -depth 24
a. Attempts to set the default color depth to 24.
5. How can I prevent my system from halting when my terminal server is rebooted?
a. Patches
1. Solaris 2.6
a. Install patch 105924-10 or later
2. Solaris 7
a. Install patch 107589-02 or later
3. Solaris 8
a. Integrated
b. Method 1 (persistent)
1. Modify /etc/default/kbd
a. KEYBOARD_ABORT=alternate
2. /usr/sbin/init 6
3. New break sequence is "~^b"
c. Method 2 (no persistent, system up)
1. Solaris 2.6 / 7
a. /usr/bin/kbd -a disable
b. This disables keyboard abort (L1-A / Stop-A)
until you perform Method 1
2. Solaris 8
a. /usr/bin/kbd -a alternate
b. This allows for the alternate sequence to be
immediately available until you perform Method 1
E. Filesystem
1. How do I get a list of superblocks on a filesystem?
a. /usr/sbin/newfs -N device | awk '/^ [0-9]/'
2. How do I grow a ufs filesystem?
a. Unmounted filesystem (not /, /usr, /var)
1. Allocate additional contiguous disk space with format(1m)
a. Unnecessary if you are using a volume manager
2. /usr/lib/fs/ufs/mkfs -G rawdevice newsize
b. Mounted filesytem (not /, /usr, /var)
1. Allocate additional contiguous disk space with format(1m)
a. Unnecessary if you are using a volume manager
2. /usr/lib/fs/ufs/mkfs -G -M mountpoint rawdevice newsize
3. How do I determine what type of filesystem a given device has?
a. Method 1 (root)
1. /usr/sbin/fstyp blockdevice
4. What are inodes 0, 1, and 2 used for?
a. Inode 0 is unusable. It is used to mark unused inodes.
b. Inode 1 is unusable. Use of this inode for bad block information
is deprecated.
c. Inode 2 is "/" or "root" of the filesystem.
5. What do I do if I have a corrupt boot block?
a. ok boot cdrom -s
b. /usr/sbin/installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk
/dev/rdsk/cXtXdXsX
6. What is the DNLC?
a. DNLC is the directory name look up cache
b. It is a hash table bucket structure of name cache entries
for fast lookup. The elements in this cache are directory
vnode, file name, and credential.
c. Solaris also employs a directory cache mechanism for large
directories. This is an unordered linked list of free space
entries.
d. Solaris caches names up to 30 characters. Longer names are too
long are read using the standard, slower method, by traversing
the directory structure.
e. Read /usr/include/sys/dnlc.h
7. How does the DNLC relate to the kernel vfs layer?
a. Since the DNLC is a reference to recently used vnodes, the
filesystem will read from the DNLC prior to the underlying
filesystem. This is due to the fact that every inode/rnode
has a corresponding vnode. vfs is a layer of abstraction
in the kernel that allows the kernel to support multiple
filesystem types by presenting all filesystems in a uniform
manner.
8. How do I get statistics about DNLC performance?
a. A value of 90% or less requires tuning.
b. Method 1 (recommended)
1. /usr/bin/vmstat -s | /usr/bin/grep "name lookup"
c. Method 2
1. echo '*ncstats*0t100%(*ncstats+*(ncstats+4)+*(ncstats+14))=D' | /usr/bin/adb
-k
F. X11
1. How do I use an alternate window manager?
a. Bypassing CDE
1. echo "exec /path/to/alternate/window/manager" > .xsession
b. Maintaining CDE
1. Xresources
a. cd /usr/dt/config/C/Xresources.d
b. /usr/bin/cp Xresources.ow Xresources.wm
c. 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
a. cd /usr/dt/config
b. /usr/bin/cp Xsession.ow Xsession.wm
c. Modify Xsession.wm
1. Place windowmanager environment
3. Logo (for display in CDE login)
a. cd /usr/dt/appconfig/icons/C
b. /usr/bin/cp OWlogo.pm WMlogo.pm
1. Replace this with your own XPM file
2. How do I disable X Windows from starting at boot?
a. /usr/dt/bin/dtconfig -d
3. How do I disable that annoying beep?
a. Method 1
1. /usr/openwin/bin/xset b 0
b. Method 2
1. /usr/openwin/bin/xset b off
c. Method 2
1. /usr/openwin/bin/xset -b
G. Crash dump Analysis
1. When did it happen?
a. Method 1 (to the minute)
1. /usr/bin/who -b
b. Method 2 (to the second)
1. Become root
2. echo '*time-(*lbolt%64)=Y' | /usr/bin/adb -k
2. How do I get information about what was going on?
a. Enable savecore
1. Solaris 2.6
a. disabled by default
b. Modify /etc/init.d/sysetup
1. Uncomment last 6 lines
2. Solaris 7
a. Message me this info if you have it
3. Solaris 8
a. enabled by default
b. enable with '/usr/bin/dumpadm -y'
b. Default file locations
1. corefile is /var/crash/`uname -n`/vmcore.n
2. namelist is /var/crash/`uname -n`/unix.n
c. Process status
1. Open the crash interpreter
a. /usr/sbin/crash -d corefile -n namelist
2. p -e
a. the "p" command reads the process table.
d. Network status
1. /usr/bin/netstat namelist corefile
e. IPC status
1. /usr/sbin/ipcs -C corefile -N namelist
H. Veritas Volume Manager
1. How do I allow a user to write to a managed raw device?
a. /usr/bin/chown is not persistent across reboots
b. /usr/sbin/vxedit set user=oracle group=dba mode=600 volume
I. Veritas Filesystem
1. How do I make vxfs support large files?
a. /usr/lib/fs/vxfs/fsadm -o largefiles mountpoint
II. Networking
A. Physical Layer
1. How do I find the speed my network card is at?
a. /usr/sbin/ndd -set /dev/hme instance 0
1. instance 0 - hme0
2. instance 1 - hme1
b. /usr/sbin/ndd -get /dev/hme transciever_inuse
1. 0 - onboard
2. 1 - offboard card (mii)
c. /usr/sbin/ndd -get /dev/hme link_status
1. 0 - down
2. 1 - up
d. /usr/sbin/ndd -get /dev/hme link_speed
1. 0 - 10Mb
2. 1 - 100Mb
e. /usr/sbin/ndd -get /dev/hme link_mode
1. 0 - half duplex
2. 1 - full duplex
2. How do I configure what my network card is capable of?
a. /usr/sbin/ndd -set /dev/hme instance 0
1. instance 0 - hme0
2. instance 1 - hme1
b. /usr/sbin/ndd -set /dev/hme adv_autoneg_cap 0
1. adv_autoneg_cap - advertise auto negotiate capability
2. 0 - off
3. 1 - on
c. /usr/sbin/ndd -set /dev/hme adv_100fdx_cap 0
1. advertise 100Mbit full duplex capability
2. 0 - off
3. 1 - on
d. /usr/sbin/ndd -set /dev/hme adv_100hdx_cap 0
1. advertise 100Mbit half duplex capability
2. 0 - off
3. 1 - on
e. /usr/sbin/ndd -set /dev/hme adv_100T4_cap 0
1. advertise deprecated 100Mbit T4 capability
2. 0 - off
3. 1 - on
f. /usr/sbin/ndd -set /dev/hme adv_10fdx_cap 0
1. advertise 10Mbit full duplex capability
2. 0 - off
3. 1 - on
g. /usr/sbin/ndd -set /dev/hme adv_10hdx_cap 0
1. advertise 10Mbit half duplex capability
2. 0 - off
3. 1 - on
3. How do I configure what my link partner is capable of?
a. /usr/sbin/ndd -set /dev/hme instance 0
1. instance 0 - hme0
2. instance 1 - hme1
b. /usr/sbin/ndd -set /dev/hme lp_autoneg_cap 0
1. link partner has auto negotiate capability
2. 0 - off
3. 1 - on
c. /usr/sbin/ndd -set /dev/hme lp_100fdx_cap 0
1. link partner has 100Mbit full duplex capability
2. 0 - off
3. 1 - on
d. /usr/sbin/ndd -set /dev/hme lp_100hdx_cap 0
1. link partner has 100Mbit half duplex capability
2. 0 - off
3. 1 - on
e. /usr/sbin/ndd -set /dev/hme lp_100T4_cap 0
1. link partner has deprecated 100Mbit T4 capability
2. 0 - off
3. 1 - on
f. /usr/sbin/ndd -set /dev/hme lp_10fdx_cap 0
1. link partner has 10Mbit full duplex capability
2. 0 - off
3. 1 - on
g. /usr/sbin/ndd -set /dev/hme lp_10hdx_cap 0
1. link partner has 10Mbit half duplex capability
2. 0 - off
3. 1 - on
B. Transport Layer
1. How do I configure stronger sequence number generation?
a. From RFC 1948; "The initial sequence numbers are intended to
be more or less random. More precisely, RFC 793 specifies that
the 32-bit counter be incremented by 1 in the low-order
position about every 4 microseconds. Instead, Berkeley-derived
kernels increment it by a constant every second, and by another
constant for each new connection. Thus, if you open a
connection to a machine, you know to a very high degree of
confidence what sequence number it will use for its next
connection. And therein lies the attack."
b. /usr/sbin/ndd -set /dev/tcp tcp_strong_iss 2
1. 0 - Sequential
2. 1 - Random increment variance (Default)
3. 2 - RFC 1948, unique-per-connection-ID.
c. Modify /etc/default/inetinit.
1. TCP_STRONG_ISS=2
2. I have a large amount of connections in state CLOSE_WAIT, what can
be done to reduce this number in the future?
a. Increase Connection Hash Table
1. Used for faster connection lookups
2. Default is 256, Max is 262144
3. Must be set at boot time
3. Modify /etc/system
a. set tcp:tcp_conn_hash_size=8192
4. /usr/sbin/init 6
b. Decrease Close Wait Interval
1. Default is 240000, Minimum Recommended is 60000
2. Can be modified on the fly at any time
3. /usr/sbin/ndd -set /dev/tcp tcp_close_wait_interval 60000
3. How can I increase my TCP Window size?
a. Increase Transmit Buffer
1. Increasing this value in excess of the 16bit window defined
in RFC793, as SEG.WND, causes the Window Scaling option as
defined in RFC1323.
2. Increasing this value takes additional memory
3. /usr/sbin/ndd -set /dev/tcp tcp_xmit_hiwat 32768
b. Increase Receive Window
1. Increasing this value in excess of the 16bit window defined
in RFC793, as SEG.WND, causes the Window Scaling option as
defined in RFC1323.
2. Increasing this value takes additional memory
3. /usr/sbin/ndd -set /dev/tcp tcp_recv_hiwat 32768
-------------------------
Have an obscure question not covered by this
IAOQ?
iaoq-requests@devunix.org - Requests
iaoq-comments@devunix.org - Comments
-------------------------
Additional feedback provided by;
arp,
masters, torment
-------------------------
Disclaimer;
This
document is not supported by Sun Microsystems.
how to increase standard in size By : anonymous ( Wed May 1 19:11:25 2002 )
stopping and re-starting a process By : anonymous ( Fri Apr 26 06:23:06 2002 )
mailx By : anonymous ( Thu Apr 25 10:41:01 2002 )
fsck By : josoto ( Thu Apr 25 09:35:54 2002 )
solaris patch 108528-14 is failing By : bruce draper ( Thu Apr 25 08:02:57 2002 )
stack size By : anonymous ( Thu Apr 25 03:31:38 2002 )
Stack Trace Interpretation By : anonymous ( Tue Apr 23 13:47:34 2002 )
question By : Alberto T. ( Mon Apr 22 15:57:34 2002 )
108528-14 obs has to many fields, record 85 By : anonymous ( Mon Apr 22 12:10:36 2002 )
How do I set up my system for multiple boots. By : anonymous ( Sat Apr 20 18:09:48 2002 )
How can I step down processor speed By : anonymous ( Fri Apr 19 06:39:20 2002 )
re:How can I deal with "can't deduct MsgBuf from physical memory list"? By : anonymous ( Tue Apr 16 07:10:07 2002 )
How can I deal with "can't deduct MsgBuf from physical memory list"? By : anonymous ( Mon Apr 15 23:15:02 2002 )
Renaming a sun host By : anonymous ( Mon Apr 15 16:11:29 2002 )
Sun Solaris 7+ By : Mohammad Noorzay ( Mon Apr 15 12:56:56 2002 )
untarring with -h option still overwrites sym links By : anonymous ( Mon Apr 8 11:13:48 2002 )
largefiles By : anonymous ( Thu Apr 4 14:18:40 2002 )
solaris8 change vxfs filesystem from option nolargefiles to largefiles By : anonymous ( Thu Apr 4 12:30:46 2002 )
monitor frequency By : KC ( Thu Mar 28 19:54:08 2002 )
How can find the ports associated with a process? By : anonymous ( Wed Mar 27 16:36:33 2002 )
How can find the ports associated with a process? By : anonymous ( Wed Mar 27 10:46:53 2002 )
filehandles By : anonymous ( Wed Mar 27 02:35:46 2002 )
ufs UFS By : anonymous ( Fri Mar 8 17:13:26 2002 )
ufs FS By : anonymous ( Fri Mar 8 14:45:53 2002 )
X11 forwarding with SSH By : Niculin Barblan ( Thu Jan 24 01:06:10 2002 )
SBUS By : anonymous ( Mon Nov 19 05:15:07 2001 )
PC keyboard on sun By : chaosmt ( Wed Oct 24 15:18:46 2001 )
tar gzip on the fly By : chaosmt ( Wed Oct 24 14:29:05 2001 )
Xsession Hangup By : anonymous ( Sun Sep 9 22:38:29 2001 )
How to send Break command with directly connected PS2 keyboard By : Aaron Gabrielson ( Sun Aug 26 23:35:44 2001 )
ipchains By : anonymous ( Tue Aug 21 05:32:09 2001 )
Kernel Tunables For Fibre-Channel disks By : Paul Ho ( Thu Aug 16 21:35:04 2001 )
Networking By : anonymous ( Mon Jul 9 17:49:50 2001 )
How to hide the Options & Help buttons in the CDE login screen By : Wen Chen Hol ( Wed Apr 11 23:23:30 2001 )
Recursive shell scripts By : Kalpesh ( Mon Apr 2 00:30:10 2001 )
How to break the boot sequence of Sun Ultra2 using PS2 keyboard and Hyperteminal connection from Win NT as a console. By : Alex Bourov ( Mon Feb 19 17:04:06 2001 )
How can I controll the fan speed (E450) ? By : Lars Timmann ( Tue Feb 13 02:09:47 2001 )
G 2. a. 2. a. Enable savecore in Solaris 7 By : Lars Timmann ( Tue Feb 13 01:37:59 2001 )
how can i change the resolution of the screen ? By : anonymous ( Fri Jan 19 11:32:37 2001 )
UNIXguide.net | Suggest a Site |