solaris intermediate

1:Directory <!--WizRtf2Html Charset=0 --> Hierarchy
/bin --->/usr/bin
/dev---->/devices   /dev  logical    /devices   physical
/etc/mnttab    contains details of current  mounted file system .
/sbin    single user mode command.  used to restore system
/usr/sbin   system administration commands
 
the size of a symbolic link always match the number of characters in the path name it contains.
ls -l /bin
lrwxrwxrwx 1 root root 9 Oct 27 08:41 /bin -> ./usr/bin        the size of  " ./usr/bin" is 9 ,so the size of symbolic link /bin  is 9
 
2: init
init 5   shutdown system
init 6   restart  system
 
3: smc
Solaris managment console  :    smc&
check smc status  : /etc/init.d/init.wbem  status
stop smc: /etc/init.d/init.wbem stop
start smc: /etc/init.d/init.wbem start
 
when you use xstart connect to solaris 10  to start smc , it may shows "It appears you are attempting to run the graphical
Solaris Management Console from a terminal which does not have a suitable 'DISPLAY' environment......"
then you can use "setenv DISPLAY=**.**.**.**:0.0"   use your local IP address to substitute my ip address ,after that ,type "smc&" it will be ok.
 
4: quot
quot -af   display all filesystem's current kilobytes used,number of files,and owner  respectively
quot -f      /dev/rdsk/c1t0d0s7         display space used (KB)  number of files ,owner on filesystem /dev/rdsk/c1t0d0s7 
  29 17 xcollin 
    9 2 root       
note that the difference between filesystem name and filesystem type
 
5:mount
 <!--WizRtf2Html Charset=0 --> File systems do not contain their own mount point directories.
mount      display the currently mounted file system 
/etc/vfstab
#device                                  device                                           mount                          FS      fsck       mount   mount
#to mount                             to fsck                                           point                            type    pass    at boot options
#
fd                                               -                                                    /dev/fd                         fd          -           no            -
/proc                                        -                                                    /proc                              proc      -           no            -
/dev/dsk/c1t0d0s1             -                                                    -                                       swap    -           no            -
/dev/dsk/c1t0d0s0           /dev/rdsk/c1t0d0s0              /                                        ufs       1           no             -
/dev/dsk/c1t0d0s7          /dev/rdsk/c1t0d0s7               /export/home            ufs        2          yes            -
/devices                               -                                                    /devices                         devfs   -           no             -
sharefs                                 -                                                    /etc/dfs/sharetab      sharefs  -         no             -
ctfs                                         -                                                   /system/contract        ctfs         -          no             -
objfs                                      -                                                  /system/object             objfs     -           no             -
swap                                     -                                                  /tmp                                   tmpfs     -         yes           -
 
fsck pass    0   ufs filesystem are  not checked, non ufs-filesystem are checked.
                >0   the file system is always checked.
 
 
device name             mount point        filesystem type               mount options                                                                                      date and time mounted 
/dev/dsk/c1t0d0s0    /                         ufs                               rw,intr,largefiles,logging,xattr,onerror=panic,dev=800000                          1319764148
/devices                  /devices              devfs                            dev=47c0000                                                                                         1319764144
ctfs                        /system/contract  ctfs                               dev=4800001                                                                                         1319764144
proc                       /proc                  proc                               dev=4840000                                                                                         1319764144
mnttab                   /etc/mnttab           mntfs                           dev=4880001                                                                                          1319764144
/tmp/VMwareDnD  /var/run/vmblock  vmblock                        dev=4c00000                                                                                          1319764314
/export/home/xcollin /home/xcollin      lofs                              dev=800007                                                                                           1321490035
....
....
 
mount a different file system,use the -F option.
mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom
use fstyp to determine a file system's type
fstyp /dev/rdsk/c0t0d0s7     ufs
----------------------------------------------------------------------
umount
before you use the fsck command, you need to unmount the file system.
 
 
umount -l    unmount all local filesystem.
 
There are two methods to make a filesystem available for umounting if it is busy:
1):fuser command: list all the processes that are accessing the file system and kills them if necessary
    1:As the root user, list all the process that are cccessing the file system.
       fuser -cu mount_point
    2: kill all the processes accessing the file system.
        fuser -ck mount_point
    3: verify that there are no processes accessing the file system.
        fuser -c mount_point
    4: unmount the file system
        umount mount_point
2):umount -f command: Forces the unmount of a file system.
    umount -f mount_point
     A forced unmount can result in loss of data and in zombie processes that are left running on the system. However, it is particularly useful for unmounting a shared file system  if the remote file server is nonfunctional
 
6    Reparing important files if boot fails
    1) insert the solaris 10  OS  CD-ROM  into CD-ROM drive.
    2) execute a single-user boot from the cd-rom:    boot cdrom -s
    3)fsck /dev/rdsk/c0t0d0s0
    4) mount /dev/dsk/c0t0d0s0 /a
    5) TERM=sun ;  export TERM
    6) vi /a/etc/vfstab
    7) cd /  ; umount /a
    8) init 6
 
7  CD-ROM fails to eject from the drive,
    1) stop vold  :   /etc/init.d/volmgt  stop ,then try to eject the cd-rom  ,if it doesn't work, following step 2
    2) pkill -9 vold    then eject the cd-rom, and leave the tray out. 
    3) start vold service :  /etc/init.d/volmgt start      and then push the cd-rom tray back into drive.
 
8  packages
packages path:  /var/sadm/pkg
package map of the entire system:   /var/sadm/install/contents
pkgtrans :   Translates packages from one format to another
pkgadd   :    Installs software packages to the system
pkgrm    :    Removes a package from the system
pkginfo  :     Displays software package information
 
pkginfo | more  displays information about software packages installed on local system's disk.
pkginfo SUNWzip     display information for a specific package 
pkginfo -l  SUNWzip     display detail information for a specific package.
pkginfo  -d  /cdrom/cdrom0/Solaris_10/Product | more         view information about packages that are located on the Solaris 10 CD-ROM.   You must use "-d" flag to view a directory of packages.
 
adding  a software from a CD-ROM in /cdrom/cdrom0/Solaris_10/Product
pkgadd -d  /cdrom/cdrom0/Solaris_10/Product   SUNWvts        
 
<!--WizRtf2Html Charset=0 --> To install all packages in a data stream format package, perform the command :
pkgadd -d /tmp/SUNWrsc.pkg all
check if a package is installed :
pkgchk -l  SUNWzip
 
delete a package
pkgrm SUNWsvim
 
adding packages to spool directory:
the default spool directory is  /var/spool/pkg 
pkgadd -d /cdrom/cdrom0/Solaris_10/Product -s spool SUNWauda
then you can directly use pkgadd SUNWauda   to install this package.
To remove a package from the spool directory:
pkgrm -s spool SUNWauda  
You can define an alternative directory to reposit the spooled package.
pkgadd -d /cdrom/cdrom0/Solaris_10/Product -s /export/xcollin/inventory SUNWauda
pkgrm -s /export/home/xcollin/inventory SUNWauda
 
9     Manage the process
1):CDE process manager
Start cde process manager on a console:
/usr/dt/bin/sdtprocess &
 
2):command line mode:
prstat    (like linux's "top"),By default ,this command displays information about all processes sorted by CPU usage.
   PID         USERNAME         SIZE       RSS           STATE           PRI        NICE       TIME         CPU          PROCESS/NLWP      
  3057        root                     137M      37M           cpu1              59         0             0:57:08     0.2%         java/20
  11357      root                      514M     452M         run                 59         0             1:07:40     0.1%         java/19
   2958       root                      68M       11M           sleep              59         0              0:27:53    0.1%         mixer_applet2/1
   10799     xcollin                  6684K     3932K       stop               59         0              0:00:01    0.0%         sshd/1
SIZE: the total virtual memory size of the process.
RSS: the resident set size of the process
STATE: cpu1 :the process is running on cpu
               run   : the process   is in the run queue.
               stop : the process   is stopped.
PRI: the priority of the process
TIME: the cumulative execution time for the process
 
prstat -t   <!--WizRtf2Html Charset=0 --> reports the total usuage summary for each user.      (very useful)                                     prstat -t
prstat -u uid  reports the sepcified user's  total processes.    (very useful)   to list xcollin's processes.   prstat -u 512     
another way to list xcollin's processes.     pgrep -lU  xcollin  
prstat -s [cpu,time,size,rss,pri]     sort output lines by cpu,or time or...                                                   prstat -s size                                                              
prstat -n    restricts the number of output lines.                                                                                     prstat -n 10
 
pgrep -l ssh                        pgrep -lf ssh
948    sshd                          948    /usr/lib/ssh/sshd
2967   sshd                         2967  /usr/lib/ssh/sshd
2966    sshd                        2966  /usr/lib/ssh/sshd
 
pgrep -lt pts/2     display the terminal pts/2's process  (must be 'lt' not 'tl')
pgrep -lU root       displays the root's process (U=user) (must be 'lU' not 'Ul')
3): From the solaris management console
smc&
This computer--system status--processes.
 
10  at
at 20:16
>rm -rf  /tmp
>ctrl+d
at  -l      list the current 'at' job.
user = root 1322136960.a Thu Nov 24 20:16:00 2011
at -r 1322136960.a          remove the task 1322136960.a
 
send some message to specific terminal.
tty     
/dev/pts/5
at  20:20
> echo "Test Complete" >/dev/pts/5
>ctrl+d
the same as crontab.
 
 
deny a user to use "at" command
add the user to /etc/cron.d/at.deny  
if you want to allow only a few users to user "at" command. you can create a at.allow file. only users in that file can use "at" command.
It's the same as "cron"
when you type "crontab" without any option. Just press ctrl+c  to exit.  Do not press ctrl+ d  .this will overwrite the existing crontab file with an empty file.
when you want to edit a crontab file. but can not open it with vi. use the following steps: export EDITOR=vi
 
another way to schedule job is  to user smc&
this computer--services--scheduled jobs
 
11: Disk
The smallest addressable unit on a platter is called sector. sectors are also known as blocks,  512 bytes.
<!--WizRtf2Html Charset=0 --> Disk slices are groupings of cylinders
cylinder is just tracks from the top of disk to bottom ,not including the whole inside tracks. 
 
 
 
 
every disk device has an entry in both /dev/dsk ,/dev/rdsk       dsk is block disk devices. rdsk is charactor disk devices.
listing a system's device:
prtconf
<!--WizRtf2Html Charset=0 --> /etc/path_to_inst
 
steps to add a newly device to system and adding entry to /dev/dsk  and /dev/rdsk
1): touch /reconfigure           this file cause the system to check for any newly installed devices the next time system restarted.
2): init 5                                  shut down the system
3): install  devices
4): turn on power
5): prtconf                              check if the device has been added.
 
if you don't want to power off machine. another way to add new devices is to use
devfsadm
 
12 format
the main funtion of format utility is to divide a disk into disk slices.
Do not change the size of a disk slices that are currently in use. when a disk with existing slices is repartitioned and relabeled,any existing data
can become inaccessible. copy existing data to backup media before the disk is repartitioned and restore the data to the disk after the disk is relabeled
and contains a new file system.
 
Disk labels: the disk's label is the area set aside for storing information about the disk's controller,geometry,and slices. the disk's lable is stored on the first sector of the disk.
 
To label a disk means to write slice information onto the disk.If you fail to label a disk after defining slices, the slice information will be lost.
an important part of the disk label is the partition table,which identifies a disk's slices,the slice boundaries in cylinders and the total size of the slices.
 
If the label on the disk has been destroyed, you need to relabel a disk with fmthard command. Following the below steps.
1):prtvtoc /dev/dsk/c1t0d0s0 > /var/tmp/c1t0d0.vtoc
2): fmthard -s /var/tmp/c1t0d0.vtoc /dev/rdsk/c0t0d0s2    the fmthard command cannot write a disk label on an unlabeled disk. you need to label it first with format command.
3): fmthard -s /dev/null /dev/rdsk/c1t0d0s2
 
13 newfs
 you can construct a new ufs filesystem on a disk slice by using the newfs command.
creating a new filesystem is destructive .the newfs command overwrite data that resides on the selected  disk slice.
newfs /dev/rdsk/c1t0d0s7
newfs -m 5 /dev/rdsk/c1t0d0s0   reserve 5 percent of free space when  you create a new filesystem.  (create new filesystem)
tunefs -m 1 /dev/rdks/c1t0d0s0   changing the percentage of free space to 1 percent.                         (filesystem has been created)
 
14  fsck
fsck command is used to check the data consistency of a file system and attempts to correct or repair any inconsistencies or damage found.
Remind that: never run fsck command on a mounted filesystem. this could leave the filesystem to an usable state.
 
fsck  /dev/rdsk/c1t0d0s7   this is the only way to check a file system that don't have entry in /etc/vfstab file.
fsck -o f   /dev/rdsk/c1t0d0s7    fsck command force a filesystem check,regardless of the state of the file system's superblock state flag. 
 
15 service
list service information:               svcs
svc.startd control all the system services. it can be referred to as the master restarter daemon. it can obtain information from the repository
service configuration repository:    /etc/svc/repository.db                   this file can only be manipulated by svccfg and svcprop  utility.
a corrupt repository prevents the system from booting. you can restore the repository using the following commands by booting system to single-user mode                   /lib/svc/bin/restore_repository        
import  new service to SMF repository                   svccfg import /var/svc/manifest/site/banner-smf.xml 
 
disable a service
pgrep -fl  cron             1647 /usr/sbin/cron
svcs        cron              online 11:13:16 svc:/system/cron:default
svcadm  -v  disable system/cron:default   
               
temporarily disable a service (it will start the next time system reboot)
svcadm -v disable -t system/cron:default
 
troubleshoot why services are not running
svcs -x cron
 
16  run-level
display system's current run-level      who -r
solaris run-level
0         running the PROM monitor
s          single user mode with critical file systems mounted and accessible
1          single user mode, same as "s " option
2          multiuser mode,  except the NFS filesystem not mounted
3          multiuser mode with all filesystems mounted
4          not used
5          shutdown system and power off
6          restart system.
 
17   milestone
currently the milestones  that can be used at boot time are:
none,   single-user,    multi-user,    multi-user-server,    all
boot system to specific milestone  from OBP
ok > boot -m milestone=single-user
 

猜你喜欢

转载自collin-xu.iteye.com/blog/1289375