Paddy and Jim's SOLARIS NOTES

 

Also see solaris infrequently asked and obscure questions.html for more stuff


NETWORKING

 

Ifconfig –a                                                                      #displays interface names and IP addresses.

 

Ifconfig <interface> down                                                #takes down an interface

 

Ifconfig <interface> unplumb                                            #removes interface completely (careful now)

 

route add host <IP_address> <default_gateway>              #adds a volatile host to the routing table

 

route add net <IP_address> <default_gateway>                #adds a volatile network to the routing table

 

netstat –an                                                                    #shows all listening ports.

 

netstat –in                                                                     #shows trend network traffic

 

netstat –nr                                                                     #shows the routing table

 

netstat –an –p tcp 5                                                       #shows all listening tcp ports, and refresh every 5 seconds

 

route get <IP_address>                                                  #displays route information (gateway, interface etc) for a given IP


SNOOPING

           

snoop –d <interface_name> -o ./<filename> &                  #writes snoop information from a particular interface to a specified file. (remember to kill the job when finished)

                                                                                    (-d means device, -o means save packets to a file)

                                                                                                           

snoop –d <interface _name> | grep <IP_address>             #displays snoop information for a specific IP address.

 

snoop –i <file_name> | more                                           #pipe filename created by snoop to more (-i means display

                                                                                    previously captured packets)

 

The default mode of snoop is summary, if you add the –V switch it logs in verbose summary.  The –v switch logs in verbose mode and is the most detailed.  The –c n switch allows you to specify how many packets to capture.

 


TCP/IP SETTINGS

 

/etc/defaultrouter                                                            #f(default gateway) file should contain the text “defaultrouter”, which is referenced in the hosts file.

 

/etc/hosts                                                                      #contains IP, hostname, DNS name of local machine, default gateway e.g.

                                                                                    10.20.3.193       beebfw1            beebfw1.icl.net

                                                                                    10.20.3.122       default router

 

/etc/netmasks                                                               #contains local IP, any other interfaces and subnet masks e.g.

10.20.3.192              255.255.255.128

10.20.3.193               

 

/etc/hostname.interface                                                  #contains name that should be aliased in the hosts file. (bob.hme0).  Should have a hostname.interface entry for each interface defined.  If not, interface will not be defined if a server is rebooted (nasty)

 

/etc/resolv.conf                                                              #contains name server information in the following format

                                                                                    domain icl.net

                                                                                    nameserver 192.168.45.3

 

/etc/nsswitch.conf                                                          # remember, if using DNS to add "dns", for example - "hosts    files dns"


MAIL

 

/usr/lib/sendmail –bp | more                                            #shows the number of mail items in queue

 

/usr/lib/sendmail –bp | head -i                                          #shows the number of mail items in queue

 

 

SECURING SENDMAIL ON SOL8

to stop sendmail listening, you neen to edit the S88sendmail script in /etc/rc2.d as indicated below.

If you see an a warning when you boot up that sendmail cannot resolve it's FQDN, you need to edit your /etc/hosts file to include it's FQDN, ie: myserver.mydom.com

#!/sbin/sh

#

# Copyright (c) 1992, 1995, 1997 - 1999 by Sun Microsystems, Inc.

# All rights reserved.

#

#ident "@(#)sendmail 1.15 99/01/28 SMI"

ERRMSG1='WARNING: /var/mail is NFS-mounted without setting actimeo=0,'

ERRMSG2='this can cause mailbox locking and access problems.'

case "$1" in

'start')

if [ -f /usr/lib/sendmail -a -f /etc/mail/sendmail.cf ]; then

if [ ! -d /var/spool/mqueue ]; then

/usr/bin/mkdir -m 0750 /var/spool/mqueue

/usr/bin/chown root:bin /var/spool/mqueue

fi

MODE=""

# MODE="-bd"

if [ -f /etc/default/sendmail ]; then

CRONTAB

 

Crontabs are found in /var/spool/cron/crontabs/

 

crontab –l                                                                      #display crontab contents

 

crontab –l > /tmp/crontab.bak                                         #backup the crontab before making any changes

 

contab < /tmp/crontab.bak                                              #import modified crontab back into crontab filqe

                                                                                   

VISUAL=vi crontab –e                                                    #syntax used to edit the crontab

 

/var/spool/cron                                                               #location of system and user crontab files

 

/var/cron/log                                                                   #crontab logs here if CRONLOG=YES is in the /etc/default/cron file. 

 


HARDWARE

 

stop a, boot –t                                                               #reloads the device tree to find new hardware

 

volcheck, cd /, cd /floppy                                                #access a floppy disk

 

fstyp /dev/dsk/c0t0d0s0 | more                                        #shows filesystem type (ufs, nfs etc)

 

fstyp -v /dev/dsk/c0t0d0s0 | more                         #shows detailed information about HDD

 

drvconfig

disk                                                                              #probes for drives

 

power-off                                                                       #powers off the server

 


SECURITY

 

/etc/inet/inetd.conf                                                         #Backup file first, then delete all entries other than telnet from allowed client machines. 
            
Then “kill   –9 –HUP inetd”

 

etc/rc2.d                                                                       #stop nfs.client, autofs, xntpd, nscd, lp, sendmail

 

etc/rc3.d                                                                       #stop nfs.server, snmpdx, dmc

#Once above services have been renamed to s67… they must be stopped by typing:  sh ./s99dtlogin stop

 

etc/default/login                                                             #configure login parameters in this file

 

 

IP forwarding can be configured as follows: /etc/system file

# ndd -set /dev/ip ip_forwarding 1

The available settings are as follows:

0 Never forward

1 Always forward

2 Only forward when two or more interfaces are up

 

Or, touch a file in /etc/ call  notrouter

 


ADMINISTRATION

Pretty user prompt /.profile

PS1="`/usr/ucb/whoami`@`uname -n`"

case `/usr/xpg4/bin/id -u` in

0) PS1="$PS1# ";;

*) PS1="$PS1$ ";;

esac
export PS1

 

 

How to remove the last character from a line using vi (dos 2 unix ^M problem)

To remove the extra carriage return at the end of the line. for example, do a global replacement of the last character on each line, "g/.$/s//"

 

Mounting CDROM

note: to mount the cdrom:-
mkdir cdrom
On Ultra5/10 mount -F hsfs -o ro /dev/dsk/c0t2d0s0 /cdrom
on other sparc mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom

 

Adding users

useradd -s /usr/bin/sh -c "admin user" -d /var/amin -m admin

NOTE: use shell /bin/true for FTP users!

                                                                                    

                                                                                     #add new user (-s /bin/sh =shell)

(-c "admin user"=comment) (-d /=directory)  

( -m make directory) (admin=username)

 

 

 

 

 

gzip –cd <filename> | tar xvf -                                          #unzips and then untars a give filename

 

jobs                                                                              #shows commands running in the background.

                                                                                   

kill %<job No>                                                               #kills a job, specified by number.

 

 

find . –print | cpio –pmduv /destination directory                mass copy

 

pkginfo |grep -i <name of package> (find a package)

pkgrm <name of package> (removes a package)

pkginfo -l 

ldd <path> (find the libraries linked to a binary)

 

shutdown -y -i6 -g0                                                        #Shutdown the system and reboot

init 6                                                                            #Shutdown the system and reboot

init 0                                                                            #Bring down to ok prompt

 

 

note: to mount the cdrom
mkdir cdrom
On Ultra5/10 mount -F hsfs -o ro /dev/dsk/c0t2d0s0 /cdrom
on other sparc mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom

 

 

 

ENABLING SAR

 

Install packages SUNWaccu and SUNWaccr using pkgadd -d

Then edit the crontab by typing:

VISUAL=vi crontab -e (un-hash)

Edit /etc/rc2.d/S21perf (un-hash)

Start S21perf

Run: sar 5 5

 

Another useful tool: vmstat 5 5

 

 

 

DIAGNOSTIC INFO & TROUBLESHOOTING

 

/usr/platform/sun4u/sbin/prtdiag -v

 

sysdef

 

dmesg | more

/usr/ucb/ps -aux                                                             #shows processes running with more information that normal ps.  S=sleeping process   T=terminating  Z=zombie

 

ps –ef | grep <command> | grep –v grep | awk ‘{ print $2 }’             #If a process is out of control, this will select all instances and child processes of a given command.

 

ps –ef | grep <command> | grep –v grep | awk ‘{ print $2 }’ | xargs kill –9  #same as above, but will kill all processes.

 

swap –l                                                                          #shows available, and in use swap space

 

find / -name core –atime +3                                             #find any core files older than 3 days, they can be deleted by adding –exec rm {} \;

 

sar 5 5                                                                          #shows processor stats, 5 instances @ 5 seconds apart

sar -q                                                                            #shows your average queue size

sar -p & -g                                                                     #show paging activity

sar -d                                                                            #shows disk utilization

sar -r                                                                             #shows memory utilization

sar -f <filename>                                                            #reads a previously saved file, sar -f /var/adm/sa/sa03

 

So where's the slowdown?
Using tools such as sar, netstat, and lockstat can help you determine where a slowdown might be happening, or where one is about to happen. Here are some examples of how you can use these tools:

sar with no options. This will show how idle the CPUs are. If your CPUs are using a lot of %usr or %sys, you may have to add extra CPUs to deal with increased demand. If %wio is high, your system is waiting for your I/O subsystems to catch up. You may have a slow disk or array.

sar -g. If you have many pgscan/s, your system is swapping. No swapping is the only good swapping. Your system is probably short on memory. Use sar -r to verify this.

netstat -in. Look to see if an interface is overloaded with traffic. If so, you may have to add another physical interface. Also, look for Ierrs, Oerrs, and Collis. These should all be relatively low numbers if not zero. High numbers in these columns can indicate network problems, such as speed or duplex autonegotiation issues, bad cabling, or a bad switch port.

top. If all else fails, look at top. What process is taking up the most resources?

 


DISK MIRRORING

 

- The Intranet Extensions CD contains disk mirroring software

 

- The database partition, created during install should not be mounted at boot. To stop this, delete the mbd line from the vfstab file, then unmount /mdb.  You can check that mdb is not mounted by issuing the mount command.  Once this is done, export the disk 0 partition table to a given text file as follows:

 

prtvtoc /dev/rdsk/c0t0d0s0 > tempfile.whatever

 

- This disk information can then be applied to the second disk as follows:

 

fmthard –s tempfile.whatever /dev/rdsk/c0t2d0s0

 

- A file system can now be created on the second disk as follows and then formatted:

 

newfs -v /dev/rdk/c0t2d0s0

 

- The databases can now be created on Slice 7 of the first partition as follows:

 

metadb -a -f -c 3 /dev/dsk/c0t0d0s7

 

 

Example -- Creating a Two-Way Mirror from command line

# DO METAROOT IF MIRRORING ROOT SLICE
# metainit d1 1 1 c0t0d0s0
d1: Concat/Stripe is setup
# metainit d2 1 1 c1t0d0s2
d2: Concat/Stripe is setup
# metainit d0 -m d1
d0: Mirror is setup
# metaroot d0
# lockfs -fa
# reboot
# metattach d0 d2
d0: Submirror d2 is attached
ls -l /dev/rdsk/c1t0d0s0
NOTE: To make sure the second disk boots if the fist one fails, set this at the ok prompt!
{0} ok setenv boot-device disk0 disk1
{0} ok setenv diag-device disk0 disk1

 

Example -- Associating a Hot Spare Pool with Submirrors from command line

# metaparam -h hsp100 d10
# metaparam -h hsp100 d11
# metastat d0

 

 

Example -- Creating a Hot Spare Pool from command line

# metainit hsp001 c2t2d0s2 c3t2d0s2
hsp001: Hotspare pool is setup

 

Example -- Adding a Hot Spare Slice to All Hot Spare Pools

# metahs -a -all /dev/dsk/c3t0d0s2
hsp001: Hotspare is added
hsp002: Hotspare is added
hsp003: 

 

 

Example -- Unmirroring root (/) from command line

# metadetach d0 d20
d0: submirror d20 is detached
# metaroot /dev/dsk/c0t3d0s0
# reboot
...
# metaclear -r d0
d0: Mirror is cleared
d10: Concat/Stripe is cleared
# metaclear d20
d20: Concat/Stripe is cleared

 

 

 

 

edit md.tab - add entries for the mirrored slices as follows: 

 

The /etc/vfstab should be amended to mirror the following (bold):

 

#device         device          mount           FS      fsck    mount   mount

#to mount       to fsck         point           type    pass    at boot options

#

#/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr          ufs     1       yes     -

fd      -       /dev/fd fd      -       no      -

/proc   -       /proc   proc    -       no      -

/dev/dsk/c0t0d0s1       -       -       swap    -       no      -

/dev/md/dsk/d1  /dev/md/rdsk/d1 /       ufs     1       no      -

/dev/md/dsk/d3  /dev/md/rdsk/d3 /var    ufs     1       no      -

/dev/md/dsk/d4  /dev/md/rdsk/d4 /export ufs     2       yes     -

swap    -       /tmp    tmpfs   -       yes     -

 

/etc/vfstab                     #The file /etc/vfstab describes defaults for each file system. The information is stored in a table with the following column headings: device, to mount

 

prtvtoc                           #report information about a disk geometry and partitioning.

 

fmthard                         # updates the VTOC (Volume Table of Contents) on hard disks.

 

newfs                            #newfs is a "friendly" front-end to the mkfs(1M) program for making UFS file systems on disk partitions. newfs calculates the appropriate parameters to use and calls mkfs

 

metadb                         The metadb command creates and deletes replicas of the metadevice state database. State database replicas can be created on dedicated slices, or on slices that will later become part of a simple metadevice (concatenation or stripe), RAID5 metadevice, or trans metadevice.

-a Attach a new database device. The /etc/system file is automatically edited with the new information and the /etc/opt/SUNWmd/mddb.cf file is updated. An alternate way to create replicas is by defining them in the /etc/opt/SUNWmd/md.tab file and specifying the assigned name at the command line in the form, mddbnn, where nn is a two-digit number given to the replica definitions. Refer to the md.tab(4) man page for instructions on setting up replicas in that file.

-c number Specifies the number of replicas to be placed on each device. The default number of replicas is 1.

-f The -f option is used to create the initial state dataabase. It is also used to force the deletion of replicas below the minimum of two. (The -a and -f options should be used together only when no state databases exist.)

 

 

Weird stuff (notes)

 

Can't write to /home?

# /etc/auto_master, hash the line containing '/home auto_home -nobrowse' and/or stop the rc script for autofs

 

When you reboot the system after installing the DiskSuite SNMP log daemon (SUNWmdn package), the following message appears:

Starting mdlogd ...

/etc/opt/SUNWmd/mdlogd.cf: no configuration information

DiskSuite displays this message because you have not yet configured the mdlogd.cf file.

To Fix, I removed the package!

When I reboot this machine, this message appear in the console :
INIT: failed write of utmpx entry:"s6" 
INIT: failed write of utmpx entry:"rb" 

Nothing to worry about: you have a seperate /var and that's unmounted before INIT tries to update /var/adm/utmpx.
This is a bug ... workaround is as follows : 
Remove the following line from your /etc/rc6 file : /sbin/umount /var > /dev/null 2>&1 Reboot after this change and you should not see the offending message. This primarily happens when /var is on an independent partition

 

 

jimparker.co.uk