Home

The following paper is my preparing the exam 311-011 for Solaris. There are parts that have no explanation, while there are parts that have more or less details, or extra information, not required by the test objects. There are parts that I feel easy or not interesting, they will have no explanation. In this case, I read the manpage & do practise ( of course )

The documents and books that help me a lot are:
A Practical Guide to Solaris - Mark G. Sobell
Solaris 7 System Administrator Exam Cram - Derrell L. Ambro
Solaris 8 Document Answer Book - http://docs.sun.com or Solaris Documentation CD
The Solaris On Intel group: the questions and answers of this group may or may not directly relate to the exam objectives, but that's have helped me to have more much experience and skills with Solaris. And this is what a Solaris adminstator must have.

1 System Concepts

1.1 Concepts of daemon, shell, file system, kernel, operating system

1.2 Define the eefect of using various command options when viewing online manual page

- Use catman to create windex ( catman -w , or catman -w -M path )
- man option -k and -f require to have windex. ( the same applies for whatis and apropos.
whatis and apropos are hardlinks to each other ?)
option -k for searching info containing a word
# man -k print | more
accept          accept (1m)     - accept or reject print requests
acctcom         acctcom (1)     - search and print process accounting files
asa             asa (1)         - convert FORTRAN carriage-control output to 
printable form
auths           auths (1)       - print authorizations granted to a user
ber_printf      ber_encode (3ldap)  - simplified Basic Encoding Rules library 
encoding functions
cancel          cancel (1)      - cancel print request
curs_printw     curs_printw (3curses)   - print formatted output in curses 
windows
devinfo         devinfo (1m)    - print device specific information
digestp         mailp (1)       - frontends to the mp PostScript pretty printer
disable         enable (1)      - enable/disable LP printers
dmi_error       dmi_error (3dmi)    - print error in string form
dpost           dpost (1)       - troff postprocessor for PostScript printers
enable          enable (1)      - enable/disable LP printers
errno           perror (3c)     - print system error messages
filep           mailp (1)       - frontends to the mp PostScript pretty printer
filofaxp        mailp (1)       - frontends to the mp PostScript pretty printer
fncreate_printer                fncreate_printer (1m)   - create new printers in 
the FNS namespace
fprintf         printf (3c)     - print formatted output
fprintf         printf (3ucb)   - formatted output conversion
franklinp       mailp (1)       - frontends to the mp PostScript pretty printer
fwprintf        fwprintf (3c)   - print formatted wide-character output
groups          groups (1)      - print group membership of user
--More--

option -f for listing info of a man file
# man -f print
print           print (1)       - shell built-in function to output characters 
to the screen or window
print           print (9e)      - display a driver message on system console
#

option -a for displaying contents of all manfiles of a given name ( IOW, man files of different sections)
For example, man -f print will display the contents of print(1) and print(9E)
$ man -a print
Reformatting page.  Please Wait... done
Reformatting page.  Please Wait... done
::::::::::::::
/tmp/mpZ6a4yb
::::::::::::::

User Commands                                            print(1)

NAME
     print - shell built-in function to output characters to  the
     screen or window

......
......
......

::::::::::::::
/tmp/mp06a4yb
::::::::::::::
Driver Entry Points                                     print(9E)

NAME
     print - display a driver message on system console
......
......
......
option -F for searching all directory specifying by MANPATH or man.cf without using windex.
( This option is used by default if windex does not exist )

2 Boot Prom

( see manual page of monitor and OpenBoot 2.x Command Reference Manual )
OpenBoot firmware applies for Sparc systems only. It is used to boot the operating system, to run diagnostics, to modify boot-related parameters and provide the Forth interpreter. There are two versions of OpenBoot: 2.x for Sparc station and Sparc IPX, 3.x is an enhanced of 2.x and based on Boot firmware standards of IEEE1275 - 1994.
Openboot provides command line interface at the console. The prompt > is for Restricted monitor, the prompt ok is for Forth monitor.

Restricted monitor allows admininstrators to boot by using command b ( for boot ) , continue a operating system ( that was interrupted by Stop-A command ) by using command c ( for continue ), or to start the Forth Monitor( using command n).
Forth monitor allows to boot the OS, run diagnostics, modify NVRAM parameters ... The functions b and c of Restricted Monitor is boot and go respectively on Forth Monitor. We can go back to Restricted Monitor from Forth Monitor by suing command old-mode at the ok prompt.

OpenBoot commands for displaying system configuration parameters:
banner, devalias, .enet-addr, .idprom, module-info ( display CPU speed, 2.x only ), printenv, show-devs, .speed ( display cpu speed and bus speed, 3.x only ), .traps, .version, show-disks, show-displays, show-nets, show-sbus, show-tapes, show-ttys.

OpenBoot commands for hardware testing
pcia-probe-list, probe-scsi, probe-scsi-all, test-all, test floopy, test /memory, test net, watch-clock, watch-net

OpenBoot commands for selecting different boot devices
boot disk, boot net, boot cdrom

Some handy commands
To change from Restricted monitor to Forth monitor
> n
ok

To change default boot device
# init 0
> n
ok setenv boot-device device[n]
ok reset

# init 0
> n
ok setenv boot-device net
ok reset

2.1 Actions required to interrupt a non-responsive system

These commands must be typed from the workstation keyboard, not from a console which is attached via the serial ports. With the exception of Stop-A command , these commands are issued by pressing and holding down the indicated keys on the keyboard immediately after the system has been powered on. The keys must be held down until the monitor has checked their status. The Stop-A command can be issued at any time after the console display begins, and the keys do not need to be held down once they has been pressed.
Note: Stop key is on new keyboard. On old keyboard, it is L1 key.

Stop : bypass the POST.
Stop-A: abort the current operation or boot process, return to ok prompt.
Stop-D: enter diagnostic mode ( set diag-switch? nvram parm to true ). Diagnostic will be run and the meesages
will be display via system serial port A.
Stop-F: enter Forth monitor on TTYA
Stop-N: cause NVRAM parms reset to default value.

2.2 Command used to manipulate custom device aliases

syntax: nvalias alias device-path

This command stores the command 'devalias alias device-path' in NVRAMRC. The alias persists until the nvunalias or set-defaults commands are executed.( NVRAMRC is a part of the NVRAM. It is used to save Forth commands.The commands will be executed each time the system is reset, as long as use-nvramrc? has been set to true )

2.3 Some boot tasks

This session refers to funtion F4 - Boot Task on Solaris x86 ( I have no Sparc here to experience with it 8-) ).
After ESC is pressed at Secondary Boot to enter DCA ( Device configuration ASsistance ), the menu F4 - Boot Task will appear after device scanning is performed and drivers are loaded. This F4 key leads to the following menu
[] View/Edit Auto Boot Settings
[] View/Edit Property Settings
[] Set Network Configuration Strategy

Auto Boot Settings can be used to set options for Set Default Boot Device, Set Auto Boot Timeout and Set Auto Boot (ON/OFF).
Set Default Boot Device will choose the default device to boot the system. For example, my Solaris box will ask for which one from the following devices Harddisk, CDROM, Network card is used to boot.
Set Auto Boot Timout will set the time interval that the secondary boot menu for DCA will wait for ESC

Remember that these settings can be set by eeprom command of Solaris OS too.

Set Network Configuration Strategy specifies the network boot and install protocol to use for booting the Solaris system. It will display options of DHCP and RARP

Property Settings enables to set values for many system options such as auto-boot?, auto-boot-cfg-num, auto-boot-timeout, output-device ...

3 Installation

3.1 Steps of software installation

3.2 Packages

3.2.1 pkgtrans converts packages between datastream format and filesystem format
3.2.1.1 Converting from data stream format to file system format
# pwd
/export/home/vu/test
# ls -l
total 594
-r--r--r--   1 root     other     291328 Nov  5 17:21 gzip-1.2.local
drwxr-xr-x   2 root     other        512 Nov  5 17:21 packages
# pkgtrans gzip-1.2.local packages

The following packages are available:
  1  SMCgzip     gzip
                 (i86pc) 1.2.4a

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:
Transferring  package instance
#
# ls -l packages
total 2
drwxr-xr-x   3 root     other        512 Nov  5 17:24 SMCgzip
#
3.2.1.2 Converting from file system format to data stream format
# pkgtrans -s packages /export/home/vu/test/gzip-pkg

The following packages are available:
  1  SMCgzip     gzip
                 (i86pc) 1.2.4a

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:
Transferring  package instance
# ls -l
total 1186
-r--r--r--   1 root     other     291328 Nov  5 17:21 gzip-1.2.local
-rw-r--r--   1 root     other     291328 Nov  5 17:26 gzip-pkg
drwxr-xr-x   3 root     other        512 Nov  5 17:24 packages
#
3.2.2 pkgadd
pkgadd package-name ---> package-name will be searched in /var/spool/pkg
pkgadd -d device ---> device may be a datastream or a directory
pkgadd -d device pkg-name ---> install only pkg-name in the device
pkgadd -s /var/spool/pkg -d device ---> create the package in spool directory ( not install )

The following example is adding Netscape which package is in directory format

# pwd
/export/home/vu
# ls -l | grep NSCPcom
drwxr-xr-x   4 vu       staff        512 Nov  7 11:49 NSCPcom
# pkgadd -d . NSCPcom

Processing package instance NSCPcom from /export/home/vu

Netscape Communicator
(i386) 10.4.76,REV=2000.11.07.08.55
Copyright 2000 Sun Microsystems, Inc. All rights reserved.
Copyright 1994-1999 Netscape Communications Corporation. All rights reserved.

This appears to be an attempt to install the same architecture and
version of a package which is already installed.  This installation
will attempt to overwrite this package.

Using  as the package base directory.
...

3.2.3 pkgrm
pkgrm package-name
pkgrm -s /var/spool/pkg ---> remove packages in /var/spool/pkg
( a list of packages will be displayed and asked)

3.2.4 pkginfo
pkginfo -l pkg-name ---> display long info
pkginfo pkgname ---> display category, pkg-name, description

# pkginfo | more
system      AMImega        MEGA Family SCSI Host Bus Adapter
system      CPQcnft        Compaq NetFlex Family NIC
system      CPQncr         Compaq Family SCSI HBA
system      CPQsmii        Compaq SMART-2/E Family of Array Controller
...

# pkginfo -l SMCgzip
   PKGINST:  SMCgzip
      NAME:  gzip
  CATEGORY:  application
      ARCH:  i86pc
   VERSION:  1.2.4a
   BASEDIR:  /usr/local
    VENDOR:  Free Software Foundation
    PSTAMP:  Steve Christensen
  INSTDATE:  Nov 05 2000 17:07
     EMAIL:  steve@smc.vnet.net
    STATUS:  completely installed
     FILES:     39 installed pathnames
                 6 linked files
                 7 directories
                 7 executables
               564 blocks used (approx)

3.2.5 pkgchk
pkgchk pkgname
pkgchk -l pkgname ---> list information of files of the package
pkgchk -a pkgname ---> check attributes only
pkgadd -c pkgname ---> check contents only
pkginfo -i ---> full installed package only

3.3 Patches

3.3.1 Display applied patches
# showrev -p
Patch: 109138-01 Obsoletes:  Requires:  Incompatibles:  Packages: SUNWcsu
Patch: 109155-01 Obsoletes:  Requires:  Incompatibles:  Packages: SUNWcsr, 
SUNWcar
Patch: 108978-01 Obsoletes:  Requires:  Incompatibles:  Packages: SUNWcsr, 
SUNWvolu, SUNWhea
# patchadd -p

Patch: 109138-01 Obsoletes:  Requires: Incompatibles: Packages:  SUNWcsu
Patch: 109155-01 Obsoletes:  Requires: Incompatibles: Packages:  SUNWcar SUNWcsr
Patch: 108978-01 Obsoletes:  Requires: Incompatibles: Packages:  SUNWcsr SUNWhea 
SUNWvolu
#

3.3.2 Apply patches :
patchadd -p : shows installed patches
patchadd -d : does not back up files to be patched. The patche will not able to be removed.

3.3.3 Remove patches
patchrm patch-number

# patchrm 109155-01
Checking installed patches...

Patch 109155-01 was installed without backing up the original files.
It cannot be backed out.
# patchrm 108978-01

Checking installed patches...

Backing out patch 108978-01...

Patch 108978-01 has been backed out.

#

4 Initialization & Shutdonw

4.1 Match the Solaris run levels to their intended functions

4.2 /etc/inittab, /etc/init.d, /etc/rc#, /etc/rc#.d

4.2.1 /etc/inittab
The inittab is read when Solaris is booted or changed its runlelvel by init or shutdown commands. Each entry in /etc/inittab consists of id, rstate, action and command. Id is a unique number for each entry. Rstate is a list of runlevels ( an entry may belongs to many different run levels ) that this entry belongs to. Action speciifies how the process specified by command is executed.

Action can be one of the following values:

initdefault
the run level of the system. The corresponding entry will not have command component.

respawn
If the process does not exist, then start the process; do not wait for its termination (continue scanning the inittab file), and when the process dies, restart the process. If the process currently exists, do nothing and continue scanning the inittab file.

wait
When init enters the run level that matches the entry's rstate, start the process and wait for its termination. All subsequent reads of the inittab file while init is in the same run level cause init to ignore this entry.

once
When init enters a run level that matches the entry's rstate, start the process, do not wait for its termination. When it dies, do not restart the process. If init enters a new run level and the process is still running from a previous run level change, the program is not restarted.

boot
The entry is to be processed only at init's boot-time read of the inittab file. init is to start the process and not wait for its termination; when it dies, it does not restart the process. In order for this instruction to be meaningful, the rstate should be the default or it must match init's run level at boot time. This action is useful for an initialization function following a hardware reboot of the system.

bootwait
The entry is to be processed the first time init goes from single-user to multi-user state after the system is booted. (If initdefault is set to 2, the process runs right after the boot.) init starts the process, waits for its termination and, when it dies, does not restart the process.

powerfail
Execute the process associated with this entry only when init receives a power fail signal, SIGPWR.

powerwait
Execute the process associated with this entry only when init receives a power fail signal, SIGPWR, and wait until it terminates before con- tinuing any processing of inittab.

off
If the process associated with this entry is currently running, send the warning signal SIGTERM and wait 5 seconds before forcibly ter- minating the process with the kill signal SIG- KILL. If the process is nonexistent, ignore the entry.

ondemand
This instruction is really a synonym for the respawn action. It is functionally identical to respawn but is given a different keyword in order to divorce its association with run lev- els. This instruction is used only with the a, b or c values described in the rstate field.

sysinit
Entries of this type are executed before init tries to access the console (that is, before the Console Login: prompt). It is expected that this entry will be used only to initialize devices that init might try to ask the run level ques- tion. These entries are executed and init waits for their completion before continuing.

4.3 Identify the commands used to change the runlevel

init : 0, 1, 2, 3, 4, 5, 6, S
telinit: 0, 1, 2, 3, 4, 5, 6, s
shutdown: 0,1,2,5,6,s
halt : 0
reboot : 6
poweroff: 5
uadmin : 0, 5, 6

5 User Administration

5.1 Login/logout process

5.1.1 /etc/passwd
This file contains following fields:
Username: 1 to 8 chars ( a-z, A-Z,0-9, period, underline and hyphen ). The first letter must be letter.At least one lower case letter
Password: contains an x, placeholder for real password stored in /etc/shadow.
Uid:
Gid:
Comment:
Home directory:
Shell:
These fields are separated by colon ( : ).
5.1.2 /etc/shadow
Only super-user can read this file. It contains information relating to password and password policies. It contains the following fields:
Username:
Password:13-char encrypted user password.*LK* indicates the account is locked.*NP* indicates the account has no password.
Last Chagne: the last day that password is changed. All the date fields contain number being the number of date since Jan 1, 1970.
Minimum:the least number of days between password changes
Maximum:the maximum number of days that paasword can be unchanged
Inactive:the maximum of days that account can be inactive before being locked.
Expire:the date that the user account will expire.
These fields are separated by colon ( : ).
5.1.3 /etc/group
This file contains information about groups and their members. It contains the following fields:
Group name:
Group password: contains an asterisk or empty.
Group ID:
Members: a list of comma--separated users that has this group as secondary group. A user can have 16 secondary groups.
These fields are separated by colon ( : ).

5.4

5.4.1 useradd
Syntax 1: useradd [-c comment] [-d dir] [-e expire] [-f inactive] [ -m [ -k skel_dir] ] [-u uid] [-g gid] [-D gid] [-s shell] account-name
Syntax 2: useradd -D [-b base_dir] [-e expire] [-f inactive] [-g group]
-e expire : expire must be in format specified by /etc/datemsk
-f inactive : normally is positive value. A value of 0 defeats the status.
-k skel_dir : a directory that contains skeleton information that can be copied into a new user's home directory.
-D : displays the default values for appying to a new account. When used with other options, it will set the default values for those options.
-g: for primary group
-G: for supplementary group.
5.4.2 userdel
Syntax: userdel [ -r ] account-name
-r : remove user's home
5.4.3 groupadd
Syntax: groupadd [-g gid [-o]] group-name
-g : a specified group id.
-o : allows duplicated gid.
5.4.4 groupdel
Syntax: groupdel group-name
5.4.4 usermod & groupmod
usermod is for modifying user attributes ( uid, expire date ,... ). Its syntax is similar to useradd , but it has a special option [ -l new-name]. This option allow usermod to change account-name to new-name.
groupmod is for modifying group attributes ( gid, name ). Option -n new-name allows to change group-name.

5.5 User work environment

5.5.1 login time's user-specific settings
sh and ksh shells use ~/.profile for login time's user-specific settings
csh shell uses ~/.login for login time's user-specific settings

5.5.2 logout time's user-specific settings
Only C shell uses ~/.logout for logout time.
5.5.3 Shell startup file
Shell startup file contains settings & commands that will be set and run when the shell is called.
C shell uses ./cshrc for this purpose, while Korn shell uses ENV variable to set it up.
5.5.4 Initialization File Templates
When a new user account using sh or ksh is created, /etc/skel/local.profile will be copied to home directory of that account and renamed to .profile.
For account using csh, /etc/skel/local.login and /etc/skel/local.cshrc will be copied to corresponding home directory and renamed to .login and .cshrc.

For user that use CDE, ~/.dtprofile will be processed by /usr/dt/bin/Xsession and in that file, there is a line being DTSOURCEPROFILE=true. This means that ~/.login or ~/.profile will be sourced when Xsession starts. Setting this value to false will cause the corresponding file not to be sourced.

loginlog After five unsuccessful login attempts, all the attempts are logged in the file /var/adm/loginlog. This file contains one record for each failed attempt. Each record contains the login name, tty specification, and time.
This is an ASCII file. Each field within each entry is separated from the next by a colon. Each entry is separated from the next by a new-line.

By default, loginlog does not exist, so no logging is done.To enable logging, the log file must be created with read and write permission for owner only. Owner must be root and group must be sys.

Sticky bit Only root can set sticky bit on executable file
Both user and root can set sticky bit on directory

6 Security

6.1 Search regular expressions in the contents of one or more files

Using find with -exec
$ find /export/home/vu/test -type f -exec grep -i vu {} \;
This is a file, containing vu
This is a file containg vu nghia khoa
The parens {} will be replaced by filename found by find

$ find /export/home/vu/test -type f -exec grep -i vu {} /dev/null \;
/home/vu/test/file1:This is a file, containing vu
/home/vu/test/file4:This is a file containg vu nghia khoa

In case that we want to find {} in files, we need to escape them so that these parens ( of -i ) will not be translated to filenames

$ find /export/home/vu/test -type f -exec grep -i {\\} {} /dev/null \;
/export/home/vu/test/file1:{} aha i find it in file1
/export/home/vu/test/fil5:{} 1
/export/home/vu/test/fil5:{} 2
Using find, xargs and grep
We can have the same results for above examples using xargs as follows

$ find /export/home/vu/test -type f | xargs grep -i vu /dev/null
/export/home/vu/test/file1:This is a file, containing vu
/export/home/vu/test/file4:This is a file containg vu nghia khoa

$ find /export/home/vu/test -type f | xargs grep -i {\\}
/export/home/vu/test/file1:{} aha i find it in file1
/export/home/vu/test/fil5:{} 1
/export/home/vu/test/fil5:{} 2
Using grep only
$ grep -i vu /export/home/vu/test/*
/export/home/vu/test/file1:This is a file, containing vu
/export/home/vu/test/file4:This is a file containg vu nghia khoa
Remember that find will be more useful if we need to search files with different conditions such as modified time, access time, types
-atime +5 : accessed more than 5 days ago
-atime 5 : accessed exactly 5 days ago
-atime -5 : accessed in the last 5 days

Other usefule options
-ctime : time that status changed
-mtime: time that file modified

6.2 Commands used to display or modify file and directory permissions

6.2.1 ls
6.2.2 chown
Syntax:
chown [-fhR] userid file1 file2 ...
chown [-fhR] userid:groupid file1 file2 ...
option -f: do not report errors
option -h: if the file specified is the symbolic link, change the owner of the symbolic link. W/o this option, the owner of the referenced by this symbolic link is changed.
option -R: recursive on directories

/etc/system contains an option that affects chown. If this file contains a line of set rstchown = 1, then only super-user can change owner of this file. If this line is set to set rstchown = 0, then owner of this file can change the file owner, too.

If chown is not run by super-user, setuid bit will be cleared ( for security's sake ).

6.2.3 chgrp
Syntax:
chgrp [-fhR] group-id file1 file2 ...

If /etc/system sets set rstchown = 1 then the owner of the file will be restricted to change group if he/she belongs to new group.Super-user is not affected by this option

If chgrp is not set by super-user, setuid bit and setgid bit will be clear.

6.2.4 chmod

6.3 umask

An important thing to remember to calculate umask is subtract the expected permission value from 666 ( for files ) or 777 ( for directories ).
For example, if we want the file we create will have permission 600 ( rw- --- --- ) then umask will be 66. With this umask, any directory we create will have permission 711 ( rwx --x --x ).

6.4 Access Control Lists ( ACLs )

ACL supports more file security than standard Unix file security. For example, standard Unix file permissions can support the case that only one user in the group has the read permission on a file.
Files here include directories, too

Creating ACL
setfacl -s acl-entries file
acl-entries are speparated by comma and there is no spaces between acl-entries.Putting spaces between acl-entries makes acl-entries after space(s) being understood as file name
The folloing example shows how setting ACL affects file permissions

$ chmod 777 thisis
$ ls -l thisis
-rwxrwxrwx   1 vu       staff         20 Dec 10 21:25 thisis
$ setfacl -s u::rw-,g::r--,o:--- thisis
$ ls -l thisis
-rw-r-----   1 vu       staff         20 Dec 10 21:25 thisis
$

Note that the first syntax of setting ACL is another way of chmod. But it is more pwerful than chmod in the folloing example:
$ setfacl -s u::rw-,g::---,o:---,m:r--,u:nghia:rw- thisis
$ getfacl thisis

# file: thisis
# owner: vu
# group: staff
user::rw-
user:nghia:rw-          #effective:r--
group::---              #effective:---
mask:r--
other:---

In this case - having special rights for any person, we need to have user entry for that person ( u:user-id:perms ) and mask entry ( m:perms ), besides owner permissions ( u::perms ), group permissions ( g::perms) and other permissions ( o:perms ).
Note that although we specify that user nghia has read/write permission, but mask has only read permission. This leads to effective right for nghia is read permission.
Modifying ACL
setfacl -m acl-entries file1 file2 ...

$ setfacl -m u:nghia:---,u:khoa:rwx thisis
$ getfacl thisis

# file: thisis
# owner: vu
# group: staff
user::rw-
user:khoa:rwx           #effective:r--
user:nghia:---          #effective:---
group::r--              #effective:r--
mask:r--
other:---  
Deleting ACL
setfacl -d acl-entries
$ getfacl thisis

# file: thisis
# owner: vu
# group: staff
user::rw-
user:khoa:rwx           #effective:r--
user:nghia:rw-          #effective:r--
user:pa:rwx             #effective:r--
user:oracle:rw-         #effective:r--
group::r--              #effective:r--
mask:r--
other:---
$ setfacl -d u:nghia,u:khoa thisis
$ getfacl thisis

# file: thisis
# owner: vu
# group: staff
user::rw-
user:pa:rwx             #effective:r--
user:oracle:rw-         #effective:r--
group::r--              #effective:r--
mask:r--
other:---
$
Copy ACL
getfacl file1 | setfacl -f - file2

7 Process Control

8 File Systems

8.a News in Solaris 8

A new TMPFS mounted file system /var/run for temporary system files not needed across system reboots. It is a memory-based file, not disk-based file. /tmp is still for temporary non-system files.

/etc/mnttab becomes of type MNTFS that provides read-only information getting directly from the kernel about mounted file systems of local system.

8.1 Different types of file system in the Solaris OS Env

There are three types of file systems: disk-based file systems, network-based file systems and virtual file systems.
8.1.1 Disk-based file systems
: UFS ( Unix file system - harddisk ) , PCFS ( MSDOS file system - diskette), HSFS ( High Sierra, Rock Ridge, and ISO 9660 file system - CDROM ), and UDF ( file system format for storing data on DVD - DVD ).

8.2 Options of mount command

Command mount has two main syntaxes:
mount -p ( or mount -v ), and
mount [-F fstype] generic-options -o specific-options mount-point

mount -p will print a table of currently-mounted file systems. mount -v is similar -p, but more verbose

General-options can be:

8.3 /etc/mnttab and /etc/vfstab

8.3.1 /etc/mnttab
This read-only file displays current mount points. Each entry consists of following fields
device, mount point, fstype, option and time
8.3.2 /etc/vfstab
Thisi file specfies mount points and their attributes. Each entry consists of:
device, device to fsck, mount point, fstype, fsck pass, auto mount, option
8.3.3 /etc/default/fs and /etc/dfs/fstypes
When a file system type can not be specified from -F option, or can not be found in /etc/vfstab, then system will use /etc/default/fs for knowing default file system type for local file system, /etc/dfs/fstypes for remote file system.

/etc/default/fs contains line of LOCAL=filesystem type.

$ cat /etc/default/fs
LOCAL=ufs
$

/etc/dfs/fstypes lists distributed file system utility package installed in the system, each package per line. The first line is for the default distributed file system if this value can not be found from -F option or /etc/vfstab.

$ cat /etc/dfs/fstypes
nfs NFS Utilities
autofs AUTOFS Utilities
cachefs CACHEFS Utilities
$

8.4 Intended purpose of /etc, /opt, /usr, /export, /

root ( slice 0 ): holds files and directories that make up the operating system.
swap ( slice 1 ): local swap.
slice 2: the whole disk.
/export ( slice 3): holds alternate versions of the operating systems for remote clients that don't have the same platform with servers. Remote clients that have same plaform with server will use /usr of server.
/export/swap ( slice 4): swap for remote clients.
/opt ( slice 5 ) : holds application softwares added to the system. /usr ( slice 6 ) : holds executable files, documentations, system programs, and library routine.
/export/home or /home ( slice 7 ): home directories for users.

8.5 Access data on diskette & CDROM

8.5.1 Volume management
/etc/init.d/volmgt is the script to start and stop volume management.
Volume management will manage CDdrive & diskette drivers under /vol/dev.

For diskettes, they will be directories diskette0 and rdiskette0 for first floopy drive, diskette1 & rdiskette1 for second one. Under these directories are block device and character device for the diskette ( not diskette drive: diskette drive is the directory dieskettn under volume management ).

# pwd
/vol/dev/diskette0
# ls -l
total 0
brw-rw-rw-   1 nobody   nobody    93,  4 Dec 15 04:41 noname
# cd ../rdiskette0
# pwd
/vol/dev/rdiskette0
# ls -l
total 0
crw-rw-rw-   1 nobody   nobody    93,  4 Dec 15 04:41 noname    
#
noname is the label of the diskette mounted by volume management

For cdrom, the corresponding directories will be /vol/dev/dsk/device and /vol/dev/rdsk/device.

# pwd
/vol/dev/dsk/c1t0d0
# ls -l
total 0
brw-rw-rw-   1 nobody   nobody    93,  3 Dec 15 04:36 nui2000tech
# cd ../../rdsk/c1t0d0
# pwd
/vol/dev/rdsk/c1t0d0
# ls -l
total 0
crw-rw-rw-   1 nobody   nobody    93,  3 Dec 15 04:36 nui2000tech
8.5.2 Access to data on diskette and cdrom under volume management
To access to diskettes, go to the directory /floppy. Under this directory, we will have directories floppy0, and diskette-name0 with diskette-name0 is the label of the diskette0. floppy0 is a link to diskette-name0. Similar is for floppy1 if the second drive exists.
# pwd
/floppy
# ls -l
total 16
lrwxrwxrwx   1 root     nobody         8 Dec 15 04:41 floppy0 -> ./noname
drwxrwxrwx   1 root     other       7168 Dec 31  1969 noname
The content of these directories is the ones of the diskette.

For cdrom, it will be /cdrom and /cdrom/cdrom0 for first cddrive.

# pwd
/cdrom
# ls -l
total 10
lrwxrwxrwx   1 root     nobody        13 Dec 15 04:37 cdrom0 -> ./nui2000tech
drwxr-xr-x   2 root     nobody       512 Dec  2 06:17 games
dr-xr-xr-x   2 root     sys         2048 Oct 13 11:03 nui2000tech
drwxr-xr-x   2 root     other        512 Dec 13 23:14 oracle8i
Find out if a CD is in use: fuser -u [ -k ] /cdrom/cdrom0
-u displays the user of the CD
-k kills the process using the CD

9 Files and directories

9.1 Commands used to reduce the size of files and directories

- compress ( -c to standard output, -v verbose, -f force compression if the file is not actually reduced or if a coresponging file with .Z entension already exists ) create compressed file with .Z extension.
- uncompress ( -c to standard output, -v verbose, -f do not prompt for overwriting )
- zcat = uncompress -c ( display the content of the compressed file )

- pack ( -f force compression )
- unpack
- pcat display the content of the packed file

13 Backup and Recovery

13.1 Backup , archive, and restore utilities

If we use remote backups acrross the network, all systems that will use the tape drive of a system must declare that system name in their /.rhosts files ( Remember home directory of super-user is / ). The system that initiates the backup process must have its name in /.rhosts .
13.1.1 usfdump & ufsrestore
ufsdump can be used for full backup or incremental backup. It is based on the backup-level number and on /etc/dumpdates. /etc/dumpdates contains information of previous backups and their backup-levels.
usfdump will backup all files changed since the nearest lower-level backup.
Backup-level 0 specifies full backup.
Backup device argument may be a local tape drive or diskette drive, remote tape drive ( host:device or user@host:device ) or diskette drive, stand output device.
If the file system to backup is a device, use raw device.
ufsdump -S directory is used to specify the number of bytes of that directory.
# ufsdump -S /dev/rdsk/c0d0s0
87367680
#ufsdump -S /export/home
665805824

ufsdump 3f /dev/rmt/1 /dev/rdsk/c0d0s6
ufsdump 0f 192.168.2.200:/dev/rmt/2 /export/home/vu
ufsdump 0f - /dev/rdsk/c0t0d0s7 | (cd /home; ufsrestore xf -)
The following example is to backup /dev/rdsk/c0d0s3 to /dev/rdsk/c0d0s4.
This is just for practise when I don't have the real tape drive. Remember that tape devices are character devices so I must use disk device as raw device ( rdsk )
# ufsdump -3uf /dev/rdsk/c0d0s4 /dev/rdsk/c0d0s3
  DUMP: Writing 32 Kilobyte records
  DUMP: Date of this level 3 dump: Sun Dec 17 08:59:43 2000
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0d0s3 (esmeralda:/data2) to /dev/rdsk/c0d0s4.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 146928 blocks (71.74MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: 146878 blocks (71.72MB) on 1 volume at 2138 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 3 dump on Sun Dec 17 08:59:43 2000
# cat /etc/dumpdates
/dev/rdsk/c0d0s3                 3 Sun Dec 17 08:59:43 2000
The 2nd dump as incremental backup right after the first dump without any modidication on /dev/dskc0d0s3 gives the following result:
# ufsdump -4uf /dev/rdsk/c0d0s4 /dev/rdsk/c0d0s3
  DUMP: Writing 32 Kilobyte records
  DUMP: Date of this level 4 dump: Sun Dec 17 09:07:52 2000
  DUMP: Date of last level 3 dump: Sun Dec 17 08:59:43 2000
  DUMP: Dumping /dev/rdsk/c0d0s3 (esmeralda:/data2) to /dev/rdsk/c0d0s4.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 266 blocks (133KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: 126 blocks (63KB) on 1 volume at 863 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 4 dump on Sun Dec 17 09:07:52 2000

ufsrestore uses option x o extract the named files, or t to list table of contents, or r for the entire contents, or i for interactive mode.

# ufsrestore -tf file1
         2      .
    472913      ./nghia
    472914      ./nghia/.profile
    472915      ./nghia/local.cshrc
    472916      ./nghia/local.login
    472917      ./nghia/local.profile
#
# ufsrestore -if file1
ufsrestore > ls
.:
 nghia/
ufsrestore > cd nghia
ufsrestore > ls
./nghia:
 .profile        local.cshrc     local.login     local.profile
ufsrestore >
How to restore /( root ) and /usr
- Add a new disk to the system where / and /usr will be restored.
- Mount the new file system on a temporary directory
- Change to the mount directory
- restore the / directory from tape. Restore level 0 first, the other levels from low to high ( ufsrestore rvf /dev/rmt/0 )
- remove restoresymtable
- umount the mount directory
- check the new file system with fsck
- create the boot blocks on the root partition by using the following command:
# installboot  /usr/platform/`uname-i`/lib/fs/ufs/bootblk /dev/rdsk/devicename
13.1.2 tar
13.1.3 cpio
cpio has three modes -i, -o and -p.

Copy-In mode ( -i ): extracts files from the standard input, which is assumed to be a product of a previous cpio -o. If option d is used, the destination directory is the current directory.

To view the content of the tape:

#cpio -icvt < /dev/rmt/0
-c reads file in ASCII format
-v display output in format similar to the output of ls command
-t list the table of contents

To extract the content of the tape into current directory:

#cpio -icvd < /dev/rmt/0
-d creates directory as needed

# cpio -ivt < testcpio -rw-r--r-- 1 root other 34 Dec 17 07:06 2000, test/test1 -rw-r--r-- 1 root other 36 Dec 17 07:06 2000, test/test2 -rw-r--r-- 1 root other 51 Dec 17 07:31 2000, test/level2/level2file1 -rw-r--r-- 1 root other 50 Dec 17 07:31 2000, test/level2/level2file2 -rw-r--r-- 1 root other 9 Dec 17 07:52 2000, test/level2/level3/x1 -rw-r--r-- 1 root other 13 Dec 17 07:52 2000, test/level2/level3/x2 -rw-r--r-- 1 root other 11 Dec 17 07:52 2000, test/level2/level3/x3 16 blocks #

Copy-Out mode( -o ): reads a list of files from the standard input and write those files to the standard output.

ls | cpio -oc > /dev/rmt/n
# find test -type f | cpio -ocv > testcpio
test/test1
test/test2
test/level2/level2file1
test/level2/level2file2
test/level2/level3/x1
test/level2/level3/x2
test/level2/level3/x3
16 blocks

Pass mode ( -p ): reads the standard input to obtain a list of path names of files that are conditionally created ( by find command, for example ) and copied into the destination directory tree. So this mode is used to copy files/directories structure from one point to another point.

# find . -print -depth | cpio -pdm existing-directory
13.1.4 pax

13.2 Backup a file system to tape

13.3 Restore a file system from tape

14 Basic Command Syntax

The important thing is it is the shell that expand ambiguous file references, not the programs that the shell runs.The utilities such as ls, cat, echo, lp ... never see the ambiguous file references. The shell expands and passes the results to those utilities.

15 Editor

15.1 Three modes of vi

- command mode
- input mode
- last-line mode

From command mode to last-line mode : colon (;)
From last-line to command mode : Enter

From command mode to input mode : i ( insert before cursor) , a ( append at end of line) , o ( new line , lower the current line ), O ( new line, above the current line )
From input mode to command mode : ESC

15.2

Note : the followings are *commands*, so we need to put vi in command mode first.
15.2.1 Commands to position & move cursor
h, j, k, l for moving left, down, up, and right

15.3 Search and replace

15.3.1 Search

/ and text to search for.
n for pointing to next matched text
N for pointing to previous matched text
Special chars in search string :
^ beginning of line
$ end of line
\> end od word :
/s\> find word ending with s
/\> find end of word
\< beginning of word: /\< find beginning of word
/\< a find word starting with a
* 0 or more occurance
/th*s search for pattern that has t followed by 0 or more h followed by s. e.g: ths, ts, thhhs
. any character
/t..s search for patter having t followed by any two chars folowed by s
[] contains any chars inside the parentheses.
/\<[of] searches for words that begins with o OR f

15.3.2 Search & Substitute
:[address]s/search-string/replacement-string
:1,$s/exmaple/example Search from the beginning to the end of the work buffer, replace exmaple with example.

Note: the above syntax will replace only the first occurence of matched text on each line. To be able to replace all matches on a line, append the g at the end of the command
:1,$s/exmaple/example/g

15.3.3 Replace
R and r are replace commands.
The single character you enter following the r overwrites the current character, and after that vi returns to command mode.

The R command causes all subsequent characters overwrite existing text, until ESC is pressed.

16 Remote Connection

16.1 Commands for remote system operation

The remote commands are: rlogin, rsh, and rcp. In order these commands can run without directly logging in the remote system, the remote system 's /etc/hosts.equiv or ~/.rhosts must contain local host name, and or user name.Also the local user name must matche the remote username. The common entry format is:
hostname [username]
where hostname must be official name of the host, not one of its nick name.
if username is specified, it can access the system under appropriate account name.

For example, if /etc/host.equiv of host esmeralda contains
quasimodo.inet.sivell.com
then user vu can do the following command
#rcp some-file esmeralda:/export/home/vu

But if /etc/host.equiv of host esmeralda contains
quasimodo.inet.sivell.com vu
then user vu can do the following command
#rcp some-file khoa@esmeralda:/export/home/khoa
- vi ( replace in entire buffer, replace from cursor end of line ... ) - devfsadm - ls options to display permission, mandatory locking - pgrep, pkill option - format menu explanation - contents of /etc/default/fs, /etc/dfs/fstypes - symbolic link, hard link - if a process don't reveive any signal, kill its parent ? - where is csh, sh, csh - command usage of : type and file - regular exporession: grep & egrep - the shortest password length that a normal user must support when using passwd. - restricted shell ( /usr/lib/rsh ) and remote shell ( /usr/sbin/rsh ) - how rsh works

Home