You are on page 1of 59

Sun Solaris System Admin Notes 1

DISK ADMINISTRATION
NOTE:
In the case of swap memory:
If RAM < 2gb = Double the size of physical memory
If RAM is between 2gb and 8gb = 75% of physical memory
If RAM > 8gb = 50% of physical memory

ON SUN HARDWARE: SPARC [Scalar Processor ARCH]


c#t#d#s#
c = controller
t = target
d = disk
s = slice
# = number
These logical names are linked to physical devices.
For eg: c0t3d0s5
In SPARC, it's possible to create 7 slices per disk drive. 0 to 7, where slice-2 cannot be used nor
created.
ON X-86 HARDWARE:
Targets will not be shown in X86 architecture, Hence
c#d#s#
It's possible to create 7 slices.
But will have 0 - 9
slice 8 and 9 = holds the boot loaders.

# prtconf
This command provides the following informations:
1. physical memory size
2. Arch of the system
3. Machine model
4. What are the devices connected to the system along with the driver
# format
This is a utility which provides the following
1. How many hard disk drives are attached and recongnised by the OS.
2. Physical name and logical name of the disk
3. Volume name assigned to each disk
To skip the
utility: Ctrl+c
# echo | format
will also the above mentioned information
# prtvtoc /dev/dsk/c0t0d0s2
* /dev/dsk/c0t0d0s2 partition map
*

Ravi Mishra

Sun Solaris System Admin Notes 1


*
*
*
*
*
*

Dimensions:
512 bytes/sector
248 sectors/track
19 tracks/cylinder
4712 sectors/cylinder
7508 cylinders

# prtvtoc
prints the Volume Table Of Contents
Following informations will be provided:
1. disk (volume name)
2. disk information, about the sectors, tracks. Cylinders.
3. the created slices inforation along with the flags
Re-labling a disk:
# prtvtoc /dev/dsk/c0t0d0s0 > /var/tmp/test_disk0
Redirecting the output of # prtvtoc to the file
/var/tmp/test_disk0
# fmthard -s /var/tmp/test_disk0 /dev/rdsk/c0t10d0s2
Copying the VTOC (Volume Table Of contents) of disk c0t0d0 to new disk c0t10d0s2
# fmthard
this command is used to create/copy the layout of one disk drive to another.
NOTE: Above command can be used only if both the source disk and the destination disk drive
geometry
remains same.
Reconfiguring the disk:
It can be achieve by 3 ways
1. At OK prompt
OK boot -r
will boot the system and reconfigure, identifies the newly connected disks.
2. # touch /reconfiure
Create a file named "reconfigure" under root.
# init 6
Restart the system
Now, when the system restarts, the newly connected disks will be identified.
NOTE: Once the system is rebooted, the reconfigured file will be removed automatically.

3. # devfsadm Cv
will be applicable when the system supports hot pluggable disk drives.
here
-C = to clear and create a new list of newly identified disk drives
-v = verbose. detailed output
FILE SYSTEM
Mainly classified into 3 types

Ravi Mishra

Sun Solaris System Admin Notes 1


1. Disk Based file system Ex: ufs (default for solaris), ext2, ext3 for Linux
2. Pseudo file system, Ex: swapfs, tmpfs, procfs, mntfs, etc
3. Distributed file system Ex: nfs - Network file system, for accessing the shared resources.
Boot block (bootblk): Track 0, sector 1-15 will be active only at the root disk.
Primary super block: Track 0, sector 16-31 provides info about data blocks, inodes and more.
Secondary backup block: Track 0, sector 32; number of backup super blocks will be created at the
time of file system creation.
Cylinder group blocks: provides the information about the cylinder per groups free data block, size
available, number of inodes and more.
# newfs This command is used to create a new file system.
When this command is invoked to create a new file system, it refers to the file /etc/default/fs
At the time of creation it will provide the below info:
1. where the slice was mounted earlier,
2. geometry of the slice
3. secondary backup blocks
# cat /etc/default/fs
LOCAL=ufs
This file will have the above mentioned entry and hence only ufs file system will be created by
default.
# newfs /dev/rdsk/c0t12d0s0
newfs: /dev/rdsk/c0t12d0s0 last mounted as /mnt/sone
newfs: construct a new file system /dev/rdsk/c0t12d0s0: (y/n)? y
Warning: 5166 sector(s) in last cylinder unallocated
/dev/rdsk/c0t12d0s0: 1027026 sectors in 168 cylinders of 48 tracks, 128
sectors
501.5MB in 13 cyl groups (13 c/g, 39.00MB/g, 18624 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 80032, 160032, 240032, 320032, 400032, 480032, 560032, 640032, 720032,
800032, 880032, 960032
# newfs -N /dev/dsk/c0t12d0s0
Will not create the file system, instead display the information about the geomerty of the disk
slice and the super backup blocks, if file system is created.
# newfs -T /dev/rdsk/c0t12d0s0
will create a file system that can support terrabyte.
# newfs -m 1 /dev/rdsk/c0t12d0s0
will create the file system, with the minfree value as 1%
Minfree:
A certain % of space is reserved for every slices.
# fstyp -v /dev/dsk/c0t12d0s0 | grep -i min
minfree 10% maxbpg 2048 optim time
To change the minfree value:
# tunefs -m 1 /dev/dsk/c0t12d0s0
minimum percentage of free space changes from 10% to 1%
# fsck

Ravi Mishra

Sun Solaris System Admin Notes 1


file system check
It can be done in two ways
1. Non-interactive - only at the time of booting
2. Interactive - at any time
NOTE: Before running # fsck, it's recommended to unmount the slice
# fsck -y -o b=160032 /dev/dsk/c0t12d0s0

Alternate super block location: 160032.


** /dev/rdsk/c0t12d0s0
** Last Mounted on
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3a - Check Connectivity
** Phase 3b - Verify Shadows/ACLs
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cylinder Groups
UPDATE STANDARD SUPERBLOCK? yes
2 files, 9 used, 483015 free (15 frags, 60375 blocks, 0.0% fragmentation)
***** FILE SYSTEM WAS MODIFIED *****

Where
-o = to specify the option
b = to specify the block number
-y = to confirm "yes"
NOTE: fsck command will check file system consistency, inode consistency, cylinder groups
consistency.
# df -h
will provide
1. what are the devices mounted?
2. where it is mounted?
3. what is the total size of the slice?
4. how much of space is used?
5. how much of space is available?
6. space utilized in %?
Where
-h = to view the information in human readable format.
# du -h /<dir>
# du -ks `ls -d *` | sort nr -- To find directories taking larger space within a given path
# du -h /mnt/sone
will provide how much of space is occupied by each file and directory
# quot -h /dev/dsk/c0t12d0s0
/dev/rdsk/c0t12d0s0:
9 root
will show the ownership.

PERFORMING MOUNTING AND UNMOUNTING OPERATION


Mounting is the process of getting ready to access the newly created slices. It can be done only for slice
having the FS, to mount a device it is essential to have a mount point.

Ravi Mishra

Sun Solaris System Admin Notes 1


Note: By default only one device can be mounted at a single mount point.
# mount
This command can be used only by the root user. It provides info about the devices mounted along
with its property. It will show both permanent and temp mounted devices information along with the
newtwork mounted informations.
# df -h
will also provide the information about the device currenlty mounted.
This command can be used by the non-root users.
To know the file system type of the slice
# fstyp <logical_device_name>

eg: # fstyp /dev/dsk/c2t1d0s0


ufs
/etc/mnttab
1. Non-editable file even by the root user
2. It can be updated by executing the command "#mount"
3. It has the information about the currently mounted slices
4. Provides the information about the device mounted, mount point of the device, how it's mounted
(state - ro/rw, nosuid, intr/nointr, largefiles/noloargefiles,xattr, on error=panic/unmount/lock), type
of the FS
5. While mounting the slice we can provide the following options:
ro = read only
rw = read & write (Default)
nosuid = will not support the suid file scripts. By default it's supported
intr = accepts the keyboard intrupts (Default)
nointr = will not support
largefiles = will support the file size more than 2gb (Default)
nolargefile = will not support the files with more file size.
xattr = extreme attributes, to provide compatability with unix flavors.
on error = three actions can be performed
panic = displays the message (Default)
lock = will lock the slice from performing any actions
unmount = will unmount the slice forcefully.
# cat /etc/mnttab
/dev/dsk/c2t0d0s0 / ufs
rw,intr,largefiles,logging,xattr,onerror=panic,dev=1d80008 1247927748
/devices /devices devfs dev=4b80000 1247927736
ctfs /system/contract ctfs dev=4bc0001 1247927736
proc /proc proc dev=4c00000 1247927736
mnttab /etc/mnttab mntfs dev=4c40001 1247927736
swap /etc/svc/volatile tmpfs xattr,dev=4c80001 1247927736
objfs /system/object objfs dev=4cc0001 1247927736
/dev/dsk/c2t0d0s3 /usr ufs
rw,intr,largefiles,logging,xattr,onerror=panic,dev=1d8000b 1247927749
/platform/sun4u-us3/lib/libc_psr/libc_psr_hwcap1.so.1 /platform/sun4uus3/
lib/libc_psr.so.1 lofs dev=1d80008 1247927744

To mount the device:


# mount <device> <mount_point>
Eg: # mount /dev/dsk/c2t0d0s6 /six6

Ravi Mishra

Sun Solaris System Admin Notes 1


Example to mount slice with manually with different options:
# mount -o ro,nolargefiles,nosuid /dev/dsk/c2t1d0s1 /mnt/slice1
To check:
# tail -1 /etc/mnttab
/dev/dsk/c2t1d0s1 /mnt/slice1 ufs
ro,nosuid,intr,nolargefiles,logging,xattr,onerror=panic,dev=1d80001
where
-o = to specify the options
NOTE:
If the properties of the mounted slice has to be changed, then the slice has to be unmounted and
mounted once again.
By default, the # mount command mounts the slice having the ufs file system.
# cat /etc/default/fs
LOCAl=ufs
/etc/vfstab
1.
2.
3.
4.

This file is editable file, by the root user.


Will have the entries of the devices that have to mounted permanently, even after reboots.
At the time of booting only this file will be checked.
The entries to this file and /etc/mnttab differs.

# cat /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/c2t0d0s1 - - swap - no /dev/dsk/c2t0d0s0 /dev/rdsk/c2t0d0s0 / ufs 1 no /dev/dsk/c2t0d0s3 /dev/rdsk/c2t0d0s3 /usr ufs 1 no /dev/dsk/c2t0d0s4 /dev/rdsk/c2t0d0s4 /var ufs 1 no /dev/dsk/c2t0d0s7 /dev/rdsk/c2t0d0s7 /export/home ufs 2 yes -/devices - /devices devfs - no ctfs - /system/contract ctfs - no objfs - /system/object objfs - no swap - /tmp tmpfs - yes -

5. Will have number of fields


a. device to mount = logical name of the device that has to be mounted
b. device to fsck = logical name of the raw device is specified to check the file system
consistency to check the integrity
c. mount point = to where the slice has to be mounted
d. Fs type = to specify the file system of the slice to be mounted
e. fsck pass = to assign the priority
f. mount at boot = either "yes" or "no"
only if the option is "yes" the slice will be mounted after reboot
g. mount options = to specify the options of the slice while mounting, for eg: ro, nosuid...
NOTE:
/, /usr, /var
will have the option mount at boot = no but, before reading this file entry, those slices will be mounted
by running a script. Hence these above 3 were exception.

Ravi Mishra

Sun Solaris System Admin Notes 1


# mountall
will mount all the slices which have the option mount at boot = yes
Note:
1. After making updations to the file /etc/vfstab we can make the slice available by
a. # mountall
b. # mount <mount_point>
Eg: # mount /fiv

To umount the device:


# umount <mount_point>
or
# umount <logical_device_name>
Eg: # umount /mnt/slice0
# umount /dev/dsk/c2t0d0s0
NOTE:
Before unmounting make sure, we are away from the mount point.
To know which user is using the mount point:
# fuser -cu <mount_point>
Eg: # fuser -cu /fiv
will display which user is using the specified mount point.
# fuser -ck <mount_point>
Eg: # fuser -ck /fiv
will kill all the process related with the specified mount point.
Then it's possible to umount the slice normally.
# umount -f <mount_point>
# umount -f <logical_device_name>
Eg: # umount -f /fiv
# umount -f /dev/dsk/c2t0d0s5
will forcefull umount the device.
where
-f = forcefully
To mount the cdrom: It can be performed by 2 methods.
1. mounting the device using volume management.
2. mounting the device manually
To mount the device using volume management:
# /etc/init.d/volmgt start
- To start the service
# /etc/init.d/volmgt stop
- To stop the service
NOTE:
Once if the device (cdrom) is mounted using volume management, its possible to eject the media,
before unmounting.

Ravi Mishra

Sun Solaris System Admin Notes 1


The above command will check the configuration file /etc/vold.conf
/etc/vold.conf - Volume Management Configuration file which holds the actions to to be performed.
vold - is the daemon which will be running at the background while the volume management
process is started.
/etc/rmmount.conf

- is the configuration file for the removable media.

NOTE:
1. Volume management (VOLD) features automatic detection of the CD-ROM. However, it does
not detect the presence of diskette that has been inserted in the drive until volcheck command is
run, This command instructs the vold daemon to check the diskette drive for any inserted media.
Volume management can mount ufs, pcfs, hsfs & udfs file system.

To determine the file system:


# mount
# cat /etc/default/fs
# cat /etc/vfstab
# cat /etc/dfs/dfstypes
# fstyp /dev/dsk/c2t1d0s7
To mount the cdrom manually:
First determine the logical name of the device:
# iostat En - will provide the information about the removable media where it is connected.
For eg: to which controller, target.
# iostat en

- will provide the above information, along with the hardware and software errors.

# mount -F <file_system> -o <options> <device_name> <mount_point>


Eg: # mount -F hsfs -o ro /dev/dsk/c2t6d0s0 /mnt/cdrom
This mount the cdrom manually. Only after umounting the device, it's possible to eject the media.
To mount the network resource (NFS):
To mount a file system remotley on destination server first we need to make sure that required dir is
shared from the source FS, and then mount it using nfs type on destination server.
share -F nfs -o rw=162.8.169.103 -d "" /ilx/cf/dump
-- Source System
mount -F nfs -o nfsvers=3 162.8.49.199:/ilx/cf/dump /ilx/ftp/CFguest/dump

-- Destination System

# mount -F <file_system> <source-ip/host-name:/<shared-resource> <mount_point>


Eg: # mount -F nfs 192.168.0.100:/source /current

INSTALLING THE SUN SOLARIS SOFTWARE


Can install the Sun Solaris Operating System by
1. cd / dvd
2. Jumpstart
3. Flash

Ravi Mishra

Sun Solaris System Admin Notes 1


4. NFS
5. WLAN
Sun Solaris Cluster Software Group:
a. Reduced Networking Support Software Group - SUNWCrnet
b. Core System Support Software Group - SUNWCreq
c. End User Solaris Software Group - SUNWCuser
d. Developer Solairs Software Group - SUNWCprog
e. Entire Solaris Software Group - SUNWCall
f. Entire Solaris Software Group with OEM - SUNWCXall
Note: SUNWC = Stanford University Network Worldwide Cluster || Cluster = is a collection
# cat /var/sadm/README
this file provides the information about the old software release, install log files and
new software release.
# cat /var/sadm/softinfo/INST_RELEASE
OS=Solaris
VERSION=10
REV=0
# cat /var/sadm/install_data/install_log
provides number of informations
it also provides the information about the Sun Solaris Software Cluster Group installed.
# cat /var/sadm/system/admin/CLUSTER
CLUSTER=SUNWCall
will only provide the information about the Sun Solaris Software Cluster Group installed.

PACKAGE ADMINISTRATION
#
#
#
#
#

pkgadd = to install/add the packages


pkgrm = to remove the packages
pkginfo = to gather the information about the installed packages
pkgchk = to check the installed packages to the system
pkgtrans = to create a package cluster

NOTE: The format of the packge in Sun Solaris is DATASTREAM.


# pkginfo
will provide all the installed packages, both completely and partially installed packages.
Displays the information about the packages in 3 coloumns.
1st column = provide the information about the category to which the package belongs too.
There are 4 categories available:
System, application, CTL (Complex Text Layout), ALE (Alternate Language Environment)
2nd column = provide the information about the name of the package
3rd column = provide the short description of the package
# pkginfo -p
provides ONLY the PARTIALLY installed packages

Ravi Mishra

Sun Solaris System Admin Notes 1


# pkginfo -l <packge_name>
Will provide the following information:
a. name of the package
b. arch of the system to which the package is installed
c. category of the package
d. base dir to which the package is installed
e. how of disk space it's approximately occupied
f. when the specified package is installed

# pkginfo | wc -l
will list out how many packages is installed to the system
# cat /var/sadm/install/contents
Provide the information about the packages installed to the system
# cd /var/sadm/pkg
Provide what are the packages installed to the system
To install a package:
Let's consider the OS cd/dvd is mounted under /mnt/cdrom
# pkgadd -d <path_of_the_package> <package_name>
# pkgadd -d /mnt/cdrom/Solaris_10/Product SUNWbash
To install a specified package from the current location
# cd /mnt/cdrom/Solaris_10/Product
# pkgadd -d . SUNWbash
To copy the specified package to the default spool directory.
# pkgadd -d /mnt/cdrom/Solaris_10/Product -s SUNWbash
Location of the default spool directory = /var/spool/pkg

To copy the specified package to the to the customised location (/pkg_bkp)


# pkgadd -d /mnt/cdrom/Solaris_10/Product -s /pkg_bkp SUNWbash
To remove the specified package:
# pkgrm <package_name>
For eg:
# pkgrm SUNWbash
Package cluster:
Package cluster is a collection of packages.
# pkgtrans -s <source_of_the_pkg_dir> <name_of_pkg_cluster> <pkg1,pkg2,pkg3>
for eg:
# pkgtrans -s /mnt/cdrom/Solaris_10/Product /test.pkg SUNWbash SUNWman

Ravi Mishra

10

Sun Solaris System Admin Notes 1


will combine the packages and form a software cluster named test.pkg under /
NOTE: Name of the cluster can be anything.
To install a package using a software cluster:
# cd /
# pkgadd test.pkg
It'll prompt for the number of package to be installed.
#pkgchk <pkg_name>
# pkgchk SUNWbash
if the package is installed, nothing will be shown as a output.
But if the package is NOT installed, a error report will be generated
# pkgchk -v SUNWbash
/usr
/usr/bin
/usr/bin/bash
will provide the information about the specified package installed path names, executable file and
directory.
# pkgchk -l SUNWbash
will display the detailed list about the file names associated with the specified package
# pkgchk -l SUNWman | more
Pathname: /usr/man
Type: symbolic link
Source of link: ./share/man
Referenced by the following packages:
SUNWdoc SUNWman
Current status: installed
Pathname: /usr/share
Type: directory
Expected mode: 0755
Expected owner: root
Expected group: sys
Referenced by the following packages:
SUNWocfd SUNWcsu SUNWjdmk-base SUNWesu SUNWTiff
SUNWjpg SUNWgnome-base-libs-shareSUNWgnome-config-shareSUNWgnomevfsshareSUNWgnome-libs-share
SUNWgnome-help-viewer-shareSUNWcacaort SUNWbrg SUNWj5rt
SUNWswmt
SUNWocf
SUNWscpu SUNWdtdst SUNWgnome-panel-shareSUNWswupcl
SUNWxwsvr SUNWjato SUNWpdas SUNWscgui SUNWgnometerminal-share

# pkgchk -p <file_name>
will provide the information about when the file is modified.
# pkgchk -p /etc/shadow
ERROR: /etc/shadow
modtime <11/09/06 10:18:10 PM> expected <07/20/09 11:20:32 AM> actual
file size <296> expected <703> actual
file cksum <20180> expected <48117> actual

# pkgchk -l -p /etc/shadow
Pathname: /etc/shadow
Type: editted file
Expected mode: 0400
Expected owner: root
Expected group: sys
Referenced by the following packages:
SUNWcsr
Current status: installed

Ravi Mishra

11

Sun Solaris System Admin Notes 1


will provide
a. name of the package the specified file is associated with
b. permissionship of the file
c. ownership and group of the file
d. status of the package
Points to remember:
# pkginfo -p
-l
where
-p = provide the partially installed packages
-l = provide the detailed information about the packages installed
# pkgadd -d
to specify the source directory of the package
# pkgtrans -s
to specify the source directory of the package
# pkgchk -v <pacage_name>
to provide the information about the files the specified file is assicated with.
# pkgchk -p <file_name>
-p = to specify the path
will provide the information about the modified time of the file
# pkgchk -l -p <file_name>
-l = to privide the detailed information about the file specified
-p = to specify the path of the file
PATCH ADMINISTRATION
In earlier versions of Solaris OE the format of the patch is .tar But the newer releases from Solaris 8
the format of the patch is .zip
NOTE:
Before installing a patch, it's recommended to check whether patch going to be installed is a right
patch to fix the problem.
It's recommended to have a backup of the installed OS. Since the patch is going to directly
Interact with the kernel (os), the above option is recommended.
The patches informations will be stored to the location /var/sadm/patch
# showrev -p
# pathchadd -p
will display the information about the currently installed patches.
Patches normally come with numbers
105050-01.zip
AB
A = is called as the base code
B = is the revision number of the patch.

Ravi Mishra

12

Sun Solaris System Admin Notes 1


To install a patch:
1. Unzip the downloaded patch.
2. # patchadd <patch_number>
# patchadd 105050-01
NOTE:
Before installing a patch, soon after unzipping the patch,
A README file will be extracted. It's recommended to read that file.
That file will provide the information about, which problem will be fixed by installing the patch,
pre-requestie to install the patch.
# patchadd -d <patch_number>
# patchadd -d 105050-01
will NOT save the patch to the disk. Once the system is rebooted, the information will be vanished.
To remove the installed patch.
# patchrm <patch_number>
# patchrm 105050-01
NOTE:
# smpatch utility can also be used to install the patch.

OPEN BOOT PROMPT (OBP)


OK prompt / OBP - OpenBoot PROM / Boot PROM Monitor Mode / init 0
OBP - Open Boot PROM
BootPROM
init 0
all the above are same
OBP is a firmware.
It can be compared with X-86 bios.
- The possible values of the boot-device parameter include only the following disk, net and cdrom
- Stop key have the impace/effect on OBP only
- Can only control the POST only by using the Sun keyboard
- Sun can replace the NVRAM with the same host id and ehternet address
- Stop+A kay sequence can cause Solaris OS file system corruption which can be difficult to repair.
OK nvramrc
NVRAMRC contents are displayed
OK banner
Displays the system information, including the physical memory, processor, OBP version and the
system model
OK boot net - install
Jumpstart boot. Boot off the network jumpstart server and install/upgrade the operating system.
NOTE: There is a space both before and after the -. The serves as a place holder argument for
command

Ravi Mishra

13

Sun Solaris System Admin Notes 1


OK boot a
Ask me. Interactive mode prompts for the names of the boot files.
NOTE: Helpful in case need to boot off an alternate /etc/system file after kernel unable modifications.
OK boot -r
Reconfigure boot. Boot and search for all attached devices, then build device entries for anything
which does not already exist. Useful when new devices are added to the system.
OK boot -s
Single user. Boots the system to run level 1.
OK boot v / V
Verbose boot. Show good / little debugging information respectively.
OK .enet-addr
Displays the enternet address
OK .version
Display version and date of the boot PROM (prtconf -V in a shell when booted)
OK .registers
Prints registry values defined.
OK .speed
Display processor and bus speeds
OK sync
Call the operating system to write information to hard disk drive
OK firmware-version
Displays major/minor CPU firmware
OK reset-all
Reset entire system [similar to performing a power cycle]
OK set-default auto-boot
Set default value for auto-boot? Option which is TRUE
OK set-defaults
Reset all the PROM settings to the factory settings
OK eject cdrom
Eject cdrom
OK test device
Test the specified device
OK test net
Test the primary network controller
OK test-all
Test all devices available with the self-test capability
OK test scsi
Test the primary SCSI controller
OK watch-net
Monitors network broadcast packets for default interface

Ravi Mishra

14

Sun Solaris System Admin Notes 1


. (DOT) for a good packet
X (Capital X) for a bad packet
OK watch-net-all
Monitors network broadcast packets for all the interfaces
Obdiag
Invokes an optional interactive menu tool which lists all self-test methods available on a system;
provides commands to run self test. (More for servers and very machine specific. Reference the
specific hardware manual for the machine to get additional information on running obdiag.
OK show-devs
Display list of installed and probed devices
OK show-pci-devs
Display all PCI devices
OK show-disks
Display a list of known disks in format for use in creating device alias.
OK show-tapes
Display a list of know tape device drives conneced to the system
OK help boot
Print help information for boot command, similar to man page for OS
OK printenv boot-device
Prints all boot devices configured in order.
OK printenv auto-boot?
Print whether auto-boot is TRUE/FALSE, if true it automatically boots from the boot device shown
from above if found else it will wait at OK/ OBP prompt for manual interference.
OK devalias
Prints alias name assigned to the physical device at the Boot PROM monitor mode
OK nvalias <alias_name> <physical_device_name_along_with_LUN>
To assign the alias name to the physical device
For Ex:
OK nvalias cdrom /pci@8,700000/scsi@6/sd@6,0:f
To assign the alias name to the cdrom.
OK nvunalias <alias_name>
To remove the alias name
OK nvunalias cdrom
OK sifting <part_of_the_command>
eg:
OK sifting bo
It'll act similar to grep command and search for the keyword 'bo" at OK prompt
To search/probe for the devices:
OK setenv auto-boot? FALSE

Ravi Mishra

15

Sun Solaris System Admin Notes 1


OK reset-all
OK probe-scsi
OK probe-ide
OK probe-scsi-all
OK go
Will resume back to the OS, shell, if we have used stop-A key sequence.
# eeprom
- can be used by root user only.
- can be used while the system is in the running state
- is used to change the environmental variables of OK prompt while the system is in the running state.
- This will have a impact once the system is restarted
- Will display only the currently assigned values
NOTE:
whereas, OK printenv
- will display the currently assigned values and the default parameter that can be assigned.
CASE:
auto-boot? false -- Defined
At the OK prompt, then, whenever the system is rebooted, OK boot command has to be executed.
auto-boot? true -- Defined
At the OK prompt, then the system boots from the default device automatically
NOTE:
- Stop keys will function irrespective of the user account. i.e stop keys are independent.
If the machine is at OK prompt, the machine is NOT running, so user account will have no impact.
- It's not recommended to use stop+A to move to Ok prompt, since it'll abort the running process.
- To move to OK prompt, execute # init 0
To disable the stop+A sequence:
1. Edit the file /etc/default/kbd
Output (Only relevant lines are displayed):
# Uncomment the following line to disable keyboard or serial device
# abort sequences:
KEYBOARD_ABORT=disable

2. # kbd -i
- to initiate the changes done
To enable the stop+A sequence:
1. Edit the file /etc/default/kbd
Output (Only relevant lines are displayed):
# Uncomment the following line to disable keyboard or serial device
# abort sequences:
#KEYBOARD_ABORT=disable
2. # kbd -i

Ravi Mishra

16

Sun Solaris System Admin Notes 1


to initiate
This is permanent.
To enable or disable only for the current session:
# kbd -a enable
# kbd -a disable
Command hold down the keys/keys during the power-on sequence:
Stop-A
Abort
Stop-D
Enter detailed diagnostic mode
Stop-N
Reset NVRAM content to default values

BASIC COPARISION: SOLARIS AND LINUX


RUN LEVELS
(INIT)

SOLARIS

LINUX

System maintenance mode

N/A

OK prompt mode/OBP mode

Shutdown

Single User

Single User

Multi user mode without NFS support (Text


Mode)

Default run level

Multi user mode without NFS support


(Text Mode)
Multi user with NFS support in Text
mode

Unused

Unused

Shutdown

Default run level

Restart

Restart

SOLARIS

LINUX

S/s

TYPE

# fdisk -l
Displays the disks & partitions
availability
/dev/hda,/dev/hdb,/dev/sda,/dev/sdb

Disk Admin

# format
Displays the disk availability
/dev/(r)dsk/c#t#d#s#

Mount

# mount /dev/dsk/c#t#d#s# /mnt/slice


# mount -F hsfs /dev/dsk/c#t#d#s#
/mnt/cdrom

File Systems

ufs
# newfs /dev/rdsk/c#t#d#s#

ext3
# mkfs -t ext3 /dev/hda#

Mount
Unmount

/etc/mnttab
/etc/vfstab

/etc/mtab
/etc/fstab

# pkgadd <package>
# pkginfo
# pkgrm <package_name>
Package Admin
Process
Monitoring
Backup &
Restore

Ravi Mishra

# mount /dev/hda# /mnt/new


# mount -t iso9660 /dev/cdrom
/mnt/cdrom

# rpm -ivh <package>


# rpm -qa
# rpm -e <package_name>

# prstat
#uptime,last,who,w = works with both

# top
# free

# ufsdump
# ufsrestore

# dump
# restore

17

Sun Solaris System Admin Notes 1

LINUX DIRECTORY STRUCTURE:


/ = root
/root = root's home directory
/home = non-root user's home directory
/etc = system configuration directory
/dev = logical disk drive informations
/mnt = optional directory to mount the devices
/opt = optional directory to install 3rd party softwares
/usr = unix system resource
/var = system logs
/media = default mount point for optical media (RHEL5 - Red Hat Enterprise Linux 5)
/selinux = security enhanced linux ( Seen in RHEL 5)
/lib = library modules
/bin = non root user executable binaries
/sbin = root user executable binaries
/proc = provides system hardware information & generate the pid's
/lost+found = used at the time of fsck
/boot = have the boot loader information
BOOTUP & SHUTDOWN PROCEDURES
Solaris - Run levels init - to initiate the run-levels
S or s = System maintenance mode
1 = Single user mode (No network support will be available, only text mode is available)
2 = Multi user mode without NFS support (Only text mode is available)
3 = Default run level. Multi user mode with NFS support in GUI mode
4 = Unused
5 = To shutdown the system
6 = To restart the system
0 = OK prompt mode/OBP mode/BootPROM mode/Forth monitor mode

TO SHUTDOWN THE SYSTEM:


# init 5
# shutdown -g 90 -i 5
# poweroff
Where
-g = to specify the grace period
-i = to inform the system to move the specified runlevel
TO RESTART THE SYSTEM:
# init 6
# shutdown -g 30 -i 6
# reboot
BOOTUP PHASES:

Ravi Mishra

18

Sun Solaris System Admin Notes 1


1. Boot PROM phase:
a) PROM runs POST (Power On Self Test). It checks whether all the devices receives the
proper power supply. If not received messages will be displayed at the console
b) Identifies the first boot device or boot device
c) Reads the bootblk from the secondary storage
d) Loads the bootblk from the secondary storage to physical memory
2. Boot Program phase:
a) Bootblk loads secondary boot program (ufsboot)
b) Kernel identifies the hardware spec - 32 bit or 64 bit, X86/sparc and so on
It has 2 part in it, Unix and Genunix
Unix - Independent of hardware
Genunix - Dependent of hardware
3. Kernel Initialization phase:
a) Reads the entry from the file /etc/system
Note: This file is recommended NOT to edit
b) Kernel initiates itself
4. Init phase:
a) Kernel starts
/etc/init -- It has the services that need to be started at the time of boot.
/etc/init.d/ -- Contains the list of services that start at the time of boot.
/etc/inittab -- Reads this file to identify, in which run level the system needs to be
started.
After reading the entry of the file accordingly,
b) It starts rc Scripts (rc = run control scripts)

Solaris Boot Process:


The Boot Process: In general, when a system is turned on, the PROM monitor runs a quick self-test
procedure that checks the hardware and memory on the system. If no errors are found, the system
begins the automatic boot process. The entire boot process is described by four distinct phases:
1) Boot PROM phase 2) Boot Programs phase 3) Kernel Initialization phase 4) init phase

PROM (Programmable ROM) runs POST (Power on


self test)

Ravi Mishra

19

Sun Solaris System Admin Notes 1


BOOT PROM PHASE

FPROM
NVRAM
(Flash PROM)

(User Defined settings)


boot? true)

Generic Device
Drivers
(Vendor Defined Settings)

BOOT PROM (FIRMWARE)

(auto-

Identifies the first boot device or boot device


(boot-device disk net cdrom)

Reads the bootblk from the secondary storage


(sector 1-15)
Loads the bootblk from the sec storage to
physical memory
Bootblk loads Boot Program (ufsboot)
BOOT PROGRAMS PHASE

Kernel identifies H/W spec 32/64 bit, X86/SPARC


and so on
Kernel initializes itself and loads necessary
KERNEL INITLIZATION PHASE modules
Kernel reads configuration file /etc/system
Kernel starts INIT (/etc/init)
INIT PHASE

Kernel reads /etc/inittab file to identify which


runlevel system needs to be started?

Starts appropriate rc (run control) script like rc3.d


or rc2.d
Operating System comes in desired runlevel

# who -r
will provide the following information
a. current run level
b. date & time of the last run level change
c. number of times at this runlevel since the last rebppt
d. previous run level
# who -r
.
run-level 3 Oct 28 18:39

Ravi Mishra

0 S

20

Sun Solaris System Admin Notes 1


#who b
Indicates time and date of the last reboot
# who -b
.
system boot Oct 28 18:39
# init q
# /etc/telinit q
will re-read (re-examine) the /etc/inittab file for any modified / new config.
To change the run level, Just execute init command with desired run levels input but remember 0,5,6
will take the system down as expected, so only use init with 1,2,3 as an option to move to desired run
levels.
# init 2
#/etc/telinit 2
/etc/telinit = is an executable file
# file /etc/telinit
/etc/telinit: ELF 32-bit LSB executable 80386 Version 1, dynamically linked,
stripped
BOOT LOADER GRUB
GRUB - Grand Unified Boot loader, Grub is stored to the /boot directory.
Seen only in X86 arch machines, It can be compared with bootblk in SPARC architecture.
Provides the option to interact with the system to choose an operating system to work in case of more
than one operating system is installed.
Boot Loader: The boot loader is the first software program that runs after we turn on a system. This
program begins the boot process.
Boot archive: Boot archive is a collection of critical files that is used to boot the OS.
Two boot archives are maintained by the system
a. Primary boot archive - Used to boot the Solaris OS on the system
b. Solaris Fail Safe - Used for recovery when the primary boot archive is damaged.
On X86 based systems, the miniroot is copied to the system to be used as failsafe boot archive
# bootadm list-menu
The location for the active GRUB menu is: /boot/grub/menu.lst
default 0
timeout 10
0 Solaris 10 11/06 s10x_u3wos_10 X86
1 Solaris failsafe
From the above output,
The default option is 0 -> Solaris 10 11/06 s10x_u3wos_10 X86
The default sec,that the grub menu displayed to the user is 10 sec.
To make the grub menu displayed until, the option is chosen, edit the /boot/grub/menu.lst File
# vi /boot/grub/menu.lst
# default menu entry to boot
default -1
This makes the grub to be displayed out of time.

Ravi Mishra

21

Sun Solaris System Admin Notes 1


Precedence of before and after grub:
ON -> BIOS -> GRUB (Stage1 & stage2) -> OS kernel (Multi-boot,boot-archive-unix) -> sched
(PID:0) -> init (PID:1) -> SMF (PID:7)-> Invokes the services.
This is how the Grub boots.
stage1 = installed on the first sector of the solaris fdisk partition
stage2 = installed in a reserved area in the solaris fdisk partition. Is the core image of the GRUB.
menu.lst = is typically located to /boot/grub directory. GRUB stage2 file reads the menu.lst file.
How to boot the system to single user mode from grub?
1. Once the grub screen is displayed, use arrow keys to select, then press 'e' to edit accordingly.
For instance
0 Solaris 10 11/06 s10x_u3wos_10 X86
1 Solaris failsafe
if we choose 0, then pressed 'e'
then,
root (hd0,0,a)
kernel /platform/i86pc/multiboot
module /platform/i86pc/boot_archive
now choose the second line and edit as,
To boot the system in desired mode from the grub menu:
kernel /platform/i86pc/multiboot s -- Single user
kernel /platform/i86pc/multiboot r -- Reconfigure
kernel /platform/i86pc/multiboot -m milestone=single-user
kernel /platform/i86pc/multiboot -m verbose
-kernel /platform/i86pc/multiboot a -- Interactive

mode
mode [OK boot -r]
-- Milestone option
Verbose mode [OK boot -v]
mode [OK boot -a]

now press, 'esc' followed by 'b' to boot the system in desired mode.
Properties of Failsafe boot archive:
1. Is self sufficient
2. Can boot on its own
3. Is created by default during OS installation
4. Requires no maintenance

SMF SERVICE MANAGEMENT FACILITY


SMF - Service Management Facility an important feature of Sun Solaris 10 0S.
Runs with the daemon: svc.startd with PID=7
Features of SMF includes,
1. Provides service management via service configuration database [list of services and their
various supported methods].
2. Proves legacy rc script support [old programs will work].
3. Facilitates service dependencies
4. Permits automatic restarts of failed and/or stopped service.

Ravi Mishra

22

Sun Solaris System Admin Notes 1


5. Provides service status information [0nline/offline, dependencies]
6. Causes each defined service to log individually to : /var/svc/log
7. Defines a Fault Management Resource Identifier [FMRI].
FMRI provide categories of services
a. network
b. milestone
8. Can load mutually exclusive services in parallel.
9. SMF support multiple instances of services.
SMF checks the services on the following category:
1. application
2. network
3. devices
4. system
5. platform
6. site
7. milestone

Status of the
Degraded:
Disabled:
Legacy_run:
Maintenance:
manually
Offline:
Offline:
Online:
Uninitialized:

SMF:
Service instance is enabled, but is running at a limited capacity
Services are not enabled and not running
Services are not controlled by SMF, but can be observed. (Started with RC scripts)
This state needs roots interrogation. In this case the services has to be made available
Services are enabled but not running
Service is enabled but the service is not yet running or available to run.
Services are enabled and its running
This state is the initial state for all services before their configuration has been read.

Components of a SMF Service:

Ravi Mishra

23

Sun Solaris System Admin Notes 1

SMF Initialization at Boot:

Primary SMF utilities:


1. # svcs - Lists services and provides additional information
2. # svcadm - Service administration utility,

Ravi Mishra

24

Sun Solaris System Admin Notes 1


3. # svccfg - Service configuration; Permits interaction with services configuration DB, including state
transitions
svc.startd
inetadm

Default service manage/restarter


Default, delegated service re-starter for INETD daemon

Monitoring the services:


# svcs -a
-a option will display all services, including disabled services.
# svcs -a

STATE STIME FMRI


legacy_run 14:42:55 lrc:/etc/rcS_d/S50sk98sol
legacy_run 14:42:59 lrc:/etc/rc2_d/S10lu
legacy_run 14:42:59 lrc:/etc/rc2_d/S20sysetup
legacy_run 14:42:59 lrc:/etc/rc2_d/S40llc2
.
.
.
disabled 14:42:57 svc:/network/rexec:default
disabled 14:42:57 svc:/network/shell:default
disabled 14:42:57 svc:/network/shell:kshell
disabled 14:42:57 svc:/network/talk:default
online 14:42:49 svc:/system/svc/restarter:default
online 14:42:50 svc:/system/installupdates:default
online 14:42:50 svc:/network/pfil:default
online 14:42:50 svc:/milestone/name-services:default
online 14:42:50 svc:/network/loopback:default
online 14:42:50 svc:/system/filesystem/root:default

# svcs
List out that are the services running (online), status of the service, FMRI
# svcs

STATE STIME FMRI


legacy_run 14:42:55 lrc:/etc/rcS_d/S50sk98sol
legacy_run 14:42:59 lrc:/etc/rc2_d/S10lu
legacy_run 14:42:59 lrc:/etc/rc2_d/S20sysetup
legacy_run 14:42:59 lrc:/etc/rc2_d/S40llc2
legacy_run 14:42:59 lrc:/etc/rc2_d/S42ncakmod
legacy_run 14:42:59 lrc:/etc/rc2_d/S47pppd
legacy_run 14:42:59 lrc:/etc/rc2_d/S70uucp
legacy_run 14:42:59 lrc:/etc/rc2_d/S72autoinstall
.
.
.
online 14:42:49 svc:/system/svc/restarter:default
online 14:42:50 svc:/system/installupdates:default
online 14:42:50 svc:/network/pfil:default

# svcs -l
-l option will give detailed information about a service, includes the FMRI, status of the service,
Eg: svcs -l network
# svcs -l <FMRI>
# svcs -l telnet

fmri svc:/network/telnet:default
name Telnet server
enabled true
state online
next_state none
state_time Mon Aug 24 14:42:57 2009
restarter svc:/network/inetd:default

# svcs -d

Ravi Mishra

25

Sun Solaris System Admin Notes 1


-d option lists the services or service instances upon which the given service instance depends.
Eg: svcs -d milestone/network:default
svcs -d milestone/multi_user
# svcs -d milestone/multi-user

STATE STIME FMRI


disabled 14:42:50 svc:/network/ntp:default
disabled 14:42:50 svc:/system/auditd:default
disabled 14:42:50 svc:/system/mdmonitor:default
disabled 14:42:50 svc:/system/rcap:default
online 14:42:50 svc:/milestone/name-services:default
online 14:42:52 svc:/system/name-service-cache:default
online 14:42:52 svc:/system/rmtmpfiles:default
online 14:42:53 svc:/system/power:default

# svcs -D
-D option will display the other services depends on a given service.
# svcs -D milestone/multi-user

STATE STIME FMRI


disabled 14:42:50 svc:/network/dhcp-server:default
disabled 14:42:50 svc:/application/management/common-agent-container-1:default
online 14:43:05 svc:/milestone/multi-user-server:default
online 14:43:28 svc:/system/webconsole:console

# svcs -p
-p option is to view the processes associated with a service instance.
# svcs -p network/inetd:default

STATE STIME FMRI


online 14:42:56 svc:/network/inetd:default
14:42:56 288 inetd

# svcs -x
If a service fails for some reason and cannot be restarted, you can list the service using the -x option.
# svcs -x telnet
svc:/network/telnet:default (Telnet server)
State: online since Mon Aug 24 14:42:57 2009
See: in.telnetd(1M)
See: telnetd(1M)
Impact: None.
SERVICE ADMINISTRATION: [using svcadm]
# svcadm - manipulate service instances
# svcadm enable <FMRI>
-- Starts the service
# svcadm enable telnet
# svcadm disable <FMRI>
# svcadm disable telnet

-- Disables the service

# svcadm enable -t <FMRI>


Starts the service temporary, only for this session, post reboot the service will no longer available
# svcadm enable -t telnet
# svcadm disable -t telnet
# svcs -l telnet
fmri svc:/network/telnet:default
name Telnet server

Ravi Mishra

26

Sun Solaris System Admin Notes 1

enabled false (temporary)


state disabled
next_state none
state_time Mon Aug 24 16:44:23 2009
restarter svc:/network/inetd:default

# svcadm enable -s <FMRI>


Will start all the instances that are associated with specified FMRI
# svcadm enable -s telnet
To re-read the changes performed to the configuration file.
# svcadm restart <FMRI>
# svcadm -v refresh <FMRI>
To re-read the changes performed to the configuration file.
Milestone Services and System Booting:
SMF Milestone
Milestone none
Milestone single-user
Milestone multi-user
Milestone multi-user-server
Milestone all

Run Level
N/A
s/S
2
3
3

OK boot m milestone=none
#svcadm milestone <options>
#svcadm milestone multi-user
#svcadm milestone all
NOTE:
1. The svc.stard daemon can obtain information about the services from the repository. This was
previously the responsibility of init process.
2. svc.stard daemon takes on the role of starting the appropriate process for the achieved run level.
3. A corrupt repository prevents the system from booting.
4. Configuration information about the services and system is stored to /etc/svc/repository.db
To restore when the SMF repository is corrupted:
# cd /lib/svc/bin
# ./restore_repositry
To work with svccfg configuration of smf:
# svccfg
svc:> select network
svc:/milestone/network> select telnet
svc:/network/telnet> listprop
general framework
general/entity_stability astring Unstable
general/restarter fmri svc:/network/inetd:default
inetd framework
inetd/endpoint_type astring stream
inetd/isrpc boolean false
inetd/name astring telnet
inetd/proto astring tcp6
inetd/stability astring Evolving
inetd/wait boolean false

svc:> list will list all services defined under smf repository

Ravi Mishra

27

Sun Solaris System Admin Notes 1


svc:> select <FMRI, like telnet, network, ssh, etc> will select that particular service
svc:> listprop will list properties of above selected FMRI
svc:> setprop <argumenets>:value
Ex:
svc:/network/telnet>
inetd/wait boolean
svc:/network/telnet>
svc:/network/telnet>
inetd/wait boolean

listprop inetd/wait
false
setprop inetd/wait=boolean:"true"
listprop inetd/wait
true

SERVICE ADMINISTRATION: [using inetadm]


# inetadm - observe or configure inetd-controlled services (Mainly network services)
1.INETD is a super-server which proxies connection to servers.
2.INETD services are traditionally defined in /etc/inetd.conf
3.inetadm permits control of key/value of services
/etc/svc - directory have the information about the smf services and its repository database.
/etc/svc/repository.db -- will have the DB about the services. It is used to check the integrity of the
services.
# inetconv - convert inetd.conf entries into smf service manifests, import them into SMF repository
# inetadm - Displays what are the services that are controlled by INETD
Displays detailed information about the FMRI specified.
# inetadm -l <FMRI>
# inetadm l telnet
To disable the specified service
# inetadm -d <FMRI>
# inetadm -d telnet

To enable the specified service


# inetadm -e <FMRI>
# inetadm -e telnet
To display the global settings
# inetadm -p
# inetadm -l telnet
SCOPE

default
default
default
default
default
default
default
default

NAME=VALUE
name="telnet"
endpoint_type="stream"
proto="tcp6"
isrpc=FALSE wait=FALSE
exec="/usr/sbin/in.telnetd"
user="root"
bind_addr=""
bind_fail_max=-1
bind_fail_interval=-1
max_con_rate=-1
max_copies=-1
con_rate_offline=-1
failrate_cnt=40
failrate_interval=60

Ravi Mishra

28

default inherit_env=TRUE
default tcp_trace=FALSE
default tcp_wrappers=TRUE

Sun Solaris System Admin Notes 1

To change the scope values:


# inetadm -m {FMRI | pattern}... {name=value}...
# inetadm -m telnet name="mytelnet"
# inetadm -m telnet wait=FALSE
Will change the name under scope value from telnet to mytelnet and wait argument from TRUE to
FALSE, likewise we can do for other values as well
# inetadm -l telnet
SCOPE

NAME=VALUE
name="mytelnet"
endpoint_type="stream"
proto="tcp6"
isrpc=FALSE
wait=FALSE
exec="/usr/sbin/in.telnetd"
user="root"

To change the default value:


# inetadm -M {name=value}...
# inetadm -M tcp_trace=TRUE
# inetadm -l telnet
default bind_addr="" default
bind_fail_max=-1
default bind_fail_interval=-1
default max_con_rate=-1
default max_copies=-1
default con_rate_offline=-1
default failrate_cnt=40
default failrate_interval=60
default inherit_env=TRUE
default tcp_trace=TRUE
default tcp_wrappers=TRUE

# netservices open
1. Will open or enable all the network related services
2. Needs the system to be restarted.
# netservices open
restarting syslogd
restarting sendmail
restarting wbem
# cd /var/svc/profile/
# ls -l generic.xml
lrwxrwxrwx 1 root root 18 Aug 24 16:59 generic.xml -> ./generic_open.xml
To check:
# svcs -a | grep ftp
online 16:47:14 svc:/network/ftp:default
# netservices limited
1. Will disable all network services except ssh.
2. Need the system to be restarted
# netservices limited
restarting syslogd
restarting sendmail
restarting wbem

Ravi Mishra

29

Sun Solaris System Admin Notes 1


dtlogin needs to be restarted. Restart now? [Y] n
dtlogin not restarted. Restart it to put it in local-mode.
# cd /var/svc/profile/
# ls -l generic.xml
lrwxrwxrwx 1 root root 25 Aug 24 17:02 generic.xml -> ./generic_limited_net.xml

To check:
# svcs -a | grep ftp
disabled 17:02:01 svc:/network/ftp:default
But,
# svcs -a | grep ssh
online 14:42:58 svc:/network/ssh:default
FILE PERMISSIONS
r= read
w=write
x=execute
u = owner of the file
g = group
o = others
a = all
+ = to add the permissions
- = to remove the permissions
= = to assign the permissions
# chmod
# chown
# chgrp

---

To change the file and directory permissions


To change the ownership of the files and directories (only used by root)
-To change the group of the files and directories (only used by root)

# chmod 777 dir1


# chmod a+rwx dir1
# chmod 644 file1
# chmod u+rw,g+r,o+r fil1
# chown -R ravim dir1
The ownership will be changed to the parent directory and for the sub-directories and files inside
"dir1"
-R = recursive
# chgrp -R admin dir1
will change the group to the parent directory and all its sub-directories and files.
# chown R ravim:admin dir2
will change the ownership and group for the parent directory "dir2" and its sub-directories and files.
ADVANCED FILE PERMISSIONS:
1. SETUID
set user id
4
2. SETGID
set group id 2
3. STICKY BIT
sticky bit
4. SUID+SGID+STICKY BIT 7

Ravi Mishra

30

Sun Solaris System Admin Notes 1


SETUID: Effective user of the file is owner of the file
1. When the SUID is assigned to a file, all the users who are accessing the file become the owner
of the file at that moment.
2. SUID will be effective mostly for a script file.
A good example for the SUID is # passwd command
# ls -l /usr/bin/passwd
-r-sr-sr-x 1 root sys 22620 Jan 23 2005 /usr/bin/passwd
# chmod 4644 file1 OR
#chmod u+s file1
To assign the SUID to the file "file1" with the default permission
SUID will have the impact on in the user's/owner's EXECUTIION area.
s => indicates EXECUTION permission is ENABLED
S => indicates EXECUTION permission is DISABLED
NOTE: This is applicable for SGID too.
# chmod 4644
-rwSr--r-- 1
# chmod 4744
-rwsr--r-- 1

file1
OR
#chmod u+s file1
root root 0 Jul 23 14:44 file1
file1
root root 0 Jul 23 14:44 file1

SGID: All files and sub dirs under parent dir with SGID permission assigned will inherit group of its
parent dir
1. SGID will be effective for a directory
2. If SGID permission is assigned to a directory, then the files and sub-dir created under the parent dir
(dir implemented with SGID) will be inheriting the group of the parent directory but if a file/dir is
already present in the parent dir before applying SGID permissions to it than it will retain its original
group permissions whatsoever.
Assign the SGID for the dir dir2
# chmod 2644 dir2 OR
#chmod g+s dir2
drwxr-sr-x 2 root root 512 Jul 23 14:48 dir2
STICKY BIT:
1. It'll be effective for a directory.
2. If a directory is assigned sticky bit permissions, every user in that system has the right to create a
file/directory inside that dir (provided with permission), but only the owner of the file can delete the
file.
NOTE: This can be override by root user.
# chmod 1777 dir3 OR
#chmod +t dir3
drwxrwxrwt 2 root root 512 Jul 23 14:52 dir3
Used to identify what are the files/dir that are having SGID permission.
# find /-user root -perm -2000
/usr/bin/mail
/usr/bin/mailx
/usr/bin/passwd
/usr/bin/write
/usr/lib/sendmail
/usr/openwin/bin/Xprt
/usr/openwin/bin/lbxproxy
/usr/platform/i86pc/sbin/eeprom
/usr/sbin/amd64/prtconf

Used to identify what are the files/dir that are having SUID permission.

Ravi Mishra

31

Sun Solaris System Admin Notes 1


# find /-user root -perm -4000
/usr/bin/amd64/newtask
/usr/bin/amd64/uptime
/usr/bin/amd64/w
/usr/bin/i86/newtask
/usr/bin/i86/uptime
/usr/bin/i86/w
/usr/bin/at
/usr/bin/atq

Used to identify what are the files/dir that are having Sticky bit permission
# find /-user root -perm -1000
USER & GROUP ADMINISTRATION:
/etc/passwd
/etc/shadow
/etc/group
/etc/skel

Holds the information about the user account or user properties


Holds the information about the user's password and password aging information
Holds the information about the group and it's properties
Directory from where the default user properties will be inherited.

/etc/passwd file details


ravim:x:517:1:Ravi Mishra:/export/home/ravim:/bin/sh
A
B C
D
E
F
A - User's login name
B - Refers to the file /etc/shadow
C - User's unique user id
D - User's primary group id
E - Comment about the user
F - User's home directory
G - Parent shell of the user defined by the root
Commands:
# useradd
# userdel
# usermod
# groupadd
# groupdel
# groupmod

to
to
to
to
to
to

create the user account


delete the user account
modify the user account
create the group account
delete the group account
modify the group account

When the # useradd command is executed, the following 2 files will be updated.
1. /etc/passwd
2. /etc/shadow
To create a simple user account:
# useradd -d /export/home/ravim -m ravim
This command will create the user named ravim with the home directory /export/home
# grep ravim /etc/passwd
ravim:x:522:1::/export/home/ravim:/bin/sh
# grep ravim /etc/shadow
ravim:*LK*:::::::

NOTE: Whenever the user is created, that user account will be "locked" intially untill password to the
user is defined.

Ravi Mishra

32

Sun Solaris System Admin Notes 1


To assign password to the user:
# passwd <user_name>
# passwd ravim
Output from the file /etc/shadow:
ravim:o39wAwzjt0BjE:14449::::::
# useradd -m -d <home_dir_path> -u <uid> -g <gid> -c <comment> -s <shell> -G <GID> login_name
Where,
-m = to create the home directory and provide the ownership of the dir to the newly created user
account
-d = to specify the home directory path
-u = to specify the unique user id of the user
-g = to specify the primary group id or group name to which the user belongs too
-c = to specify the comment about the user
-s = to specify the parent shell
-G = to specify the secondary group id or group name to which the user belongs too
login_name = user's login name
NOTE: An user should be a member of only 1 primary group and can be member of 15 secondary
groups. eg:
# useradd -u 5001 -d /export/home/us -s /bin/bash -m -g sun -c "basketball" -G 507,509,510 jordan
here, the user account is created with the following properties
login name = jordan
user uid = 5001
home directory path = /export/home/us
parenth shell = bash
primary group = sun
secondary group(s) = 507,509,510 (tech,linux,windows ref: /etc/group)
comment = basketball
To duplicate the user id to another user:
# useradd -d /export/home/karl_marx -g sales -G windows,linux,sun -c "proxy" -m -s /bin/bash -u 0
-o karl
here
-o - is used to duplicate the user id to another user
NOTE:
1. DO NOT duplicate the user id of root (0) to any other user, if it happens, then, security breach will
happen.
2. We can also assign root privileges to user through Authorization. Ref: RBAC-Topic
To specify the customized path of the skel dir
# useradd -m -d /export/home/kobe -g windows -G sun,sales,linux -c "test" -s /bin/bash k
/etc/skel_basketball kobe
-k - to specify the customized path of the skel dir
NOTE:
.profile file under /etc/skel have a impact when the user login to the system. Hence some scripts can
also be added to that.
# useradd -D
will provide the information about the default property and options of the users to be created.
# useradd -D

Ravi Mishra

33

Sun Solaris System Admin Notes 1


group=other,1 project=default,3 basedir=/home
skel=/etc/skel shell=/bin/sh inactive=0
expire= auths= profiles= roles= limitpriv=
defaultpriv= lock_after_retries=

REMOVE OLD PASSWORD AND ASSIGN BLANK PASSWORD


# passwd -d <user_name>
# passwd -d ravim
will remove the password and assign "blank" password to the user
# grep ravim /etc/shadow
ravim::14452::::::
# passwd -w <warning_days> -n <minmum_days> -x <maximum> <login_name>
# passwd -w 40 -n 30 -x 60 ravim
ravim::14452:30:60:40:::
# useradd -m -d /export/home/ryan -e 12312009 ryan
here
-e = to specify the expire date to the user account. Date will be specified with the mmddyyyy format
ryan:pmk2TEdOcjhXo:14452:40:50:30: :14609:
A
B
C D E FG H
where
A = login name of the user account
B = encrypted password for the user
C = no of days logged in. (Calculated from 1 jan 1970)
D = password minimum age (not to change password until 40 days)
E = password maximum age (have to change the password after 50 days)
F = a warning will be displayed to the user after 30 days to change password
G = number of inactive days
H = expire days
/etc/security/policy.conf
This file is responsible for generating the encrypted password to any user.
This file will have number of cryptographic algorithm to be followed while generating a password to any
user.
Eg: 1, 2a, md5
# crypt(3c) Algorithms Configuration
#
# CRYPT_ALGORITHMS_ALLOW specifies the algorithms that are allowed to
# be used for new passwords. This is enforced only in crypt_gensalt(3c).
#
CRYPT_ALGORITHMS_ALLOW=1,2a,md5

/etc/defult/passwd will provide number of information related to the password security policy
1. defines the length of the password
2. default minimum password age
3. default maximum password age
4. maintaining the history of the password
5. name check (login name cannot be used as the password)
6. dict word ( dictionary word cannot be used a password)
7. alphpa numeric,special characters to password

Ravi Mishra

34

Sun Solaris System Admin Notes 1


Note:
1. Normally the password security policy is not enforced(commented). It can be enabled.
2. If the user accounts are created through CLI, password security policy can be override.
Contents to the file /etc/default/passwd
MAXWEEKS=
MINWEEKS=
PASSLENGTH=6
#NAMECHECK=NO
#HISTORY=0
#MINDIFF=3
#MINALPHA=2
#MINNONALPHA=1
#MINUPPER=0
#MINLOWER=0
#MAXREPEATS=0
#MINSPECIAL=0
#MINDIGIT=0
#WHITESPACE=YES
#DICTIONLIST=
#DICTIONDBDIR=/var/passwd

LOCK USER ACCOUNT


# passwd -l <login_name>
# passwd -l tom
will lock the user account
Note:
Even though the user has the password the account is locked.
# grep tom /etc/shadow
tom:*LK*QK7lo.vinkpQs:14452::::::
UN-LOCK USER ACCOUNT
# passwd -u <login_name>
# passwd -u tom
To unlock the user account
# grep tom /etc/shadow
tom:QK7lo.vinkpQs:14452::::::
PRINT USERS WITH NO PASSWORD ASSIGNED
# logins p will display who are the user's who don't have password.
# logins -p
ravim 2011
ryan 2011
arun 2011
hussain

other
other
other
2011

1
1
1
other

REMOVE USER ACCOUNT


# userdel <login_name>
# userdel tom
This command will only delete the user account, files / dir created by the user in home dir is NOT
deleted.
# userdel -r <login_name>
# userdel -r tom
Will delete the user account along with the user's home dir.

Ravi Mishra

35

Sun Solaris System Admin Notes 1


How to duplicate the user id to another newly creating user?
Step 1:
# useradd -m -d /export/home/redhat -s /bin/bash -g admin -u 3000 redhat
# passwd redhat
this command will create the user account with the following
login name: redhat
home dir/base dir : /export/home/redhat
user id : 3000
primary group : admin
shell: bash
Step 2:
# useradd -m -d /export/home/suse -s /bin/ksh -g solaris -u 3000 -o suse
# passwd suse
this command will create the user account with the following
login name: suse
home dir/base dir : /export/home/suse
user id : 3000 NOTE: Duplicated using the option -o
primary group: solaris
shell: korn
NOTE: DONOT duplicate the root id to any user, if happens it leads to security breech.
MISC COMMANDS
1. # /usr/ucb/vipw -> opens the /etc/passwd file in the text layout. Works only in the init level 3 user
friendly to edit the file
2. # pwconv installs and updates /etc/shadow with information from /etc/passwd
3. # pwck => checks the entry of the file /etc/passwd and if any errors it'll be displayed
4. # grpck => checks the entry of the file /etc/group and if any errors it'll be displayed
5. # echo $? => provides the info status on the command executed
if its 0 -> command is executed successfully, other than 0 -> its shows error occurrence
To add multiple user's to multiple group:
/etc/group file has to be edited
/etc/group example entry to the file
unix:Hsba96iR2vYXI:116:root,bhutia
A
B
C
D
where
A - group name
B - encrypted password to the group
NOTE: Password to the group can be copied from /etc/shadow file.
No command is used to assign the password to the group.
C - group id
D - group members.
NOTE: Only secondary group member names can be seen in the file

Ravi Mishra

36

Sun Solaris System Admin Notes 1


To modify the user login name:
# usermod -l <new-name> <old-name>
# usermod -l rose jack
will change the login name jack to rose.
NOTE: The file ownership will be changed accordingly but the home directory will be owned by the old
owner, which will restrict to create any files in the home dir, hence the permissions & ownership has
to be changed.
/usr/sadm/defadduser this file has the entries of the default parameters of the useradd command
# useradd -D
reads the entry from this file, this file entries can be customized.
# cat /usr/sadm/defadduser

# Default values for useradd. Changed Tue Jul 28 04:28:53 2009


defgroup=1
defgname=other
defparent=/home
defskel=/etc/skel
defshell=/bin/sh
definact=0
defexpire=
defauthorization=
defrole=
defprofile=
defproj=3
defprojname=default
deflimitpriv=
defdefaultpriv=
deflock_after_retries=

# id <login_name>
# id bryant
will provide the information about the user's id and their primary group along with id.
$ id bryant
uid=1028(bryant) gid=110(sun)
# id -a <login_name>
# id -a bryant
will provide the information about the user's id, primary group id and name, secondary group id and
names
USER ACCOUNT DETAILS: Primary Group and Secondary Group
$ id -a bryant
uid=1028(bryant) gid=110(sun) groups=110(sun)
# finger -m <login_name>
# finger <login_name>
# finger bryant
# finger -m bryant
will provide the informations about the user's home dir, parent shell, when they logged in.
$ finger bryant
Login name: bryant In real life: test
Directory: /export/home/kobe Shell: /bin/bash
Never logged in.
No unread mail

Ravi Mishra

37

Sun Solaris System Admin Notes 1


No Plan.
To add a group:
# groupadd <group_name>
# groupadd sun
# groupadd -g 1000 linux
To create a group with duplicate id 1000
# groupadd -g 1000 -o redhat
# groups command to check primary and secondary groups of users
# groups <user_name> will provide the information about to which group the user belong to.
# groups ryan
pgrp1 sgrp1 sgrp2 sgrp3
According to this output, the user ryan belongs to 1 primary group pgrp1 and 3 secondary groups.
# listusers will display the information about the user's available in the system.
# listusers
castro
ravim
ryan
karl
lenin
noaccess No Access User
nobody NFS Anonymous Access User
nobody4 SunOS 4.x NFS Anonymous Access User
rosan
rose
aruns
# listusers -g <group_name> Will display the user's belong the specified group
# listusers -g other
# listusers -g sun
new
old
test

PERFORMANCE MONITORING
#w
will list out the following informations
1. who is logged in to the system
2. where they have logged in
3. when they have logged in
4. what they are doing
5. how much time they were idle
6. cpu utilization for each user's process
# w

7:44am

up 2 day(s),

Ravi Mishra

9:13,

5 users,

load average: 0.35, 0.34, 0.34

38

User
ovoadmin
maheshu
ovoadmin
ovoadmin
ravim

tty
pts/1
pts/9
pts/5
pts/3
pts/10

Sun Solaris System Admin Notes 1

login@
10:06pm
7:14am
10:06pm
2:11am
7:28am

idle
3
31
3
4:24

JCPU

PCPU

what
-bash
-bash
-bash
-bash
w

# who
will listout
1. who is logged into the system
2. where they have logged in
3. when they logged in
4. from where they have logged in (in the case of remote)
# who
ovoadmin
maheshu
ovoadmin
ovoadmin
ravim

pts/1
pts/9
pts/5
pts/3
pts/10

Nov
Nov
Nov
Nov
Nov

1
2
1
2
2

22:06
07:14
22:06
02:11
07:28

(162.8.95.123)
(mlfepp1.feed.ocp.ilx.com)
(162.8.95.123)
(162.8.95.123)
(turnstilel1.ocl.ilx.com)

# whodo
will listout out the information about
1. who are logged and what are they doing
2. what process they are doing
3. the process id of the process
# whodo

Wed Nov 2 07:48:35 EDT 2011


newsfsl1
pts/3
pts/3
pts/3

ravim
7:30
20053
0:00 bash
1998
0:00 whodo

pts/4
pts/4

ovoadmin 22:26
11845
0:01 bash

pts/1
pts/1

ovoadmin 22:26
11798
0:00 bash

# rusers
will list out who are the remote users logged to the syste
# rusers -l <ip_name_of_the_system>
#rusers -l 192.168.0.252
# vmstat
will display the virtual memory status
# pagesize
will display the page size of the system
# uname -a
SunOS news_sol10 5.10 Generic_142910-17 i86pc i386 i86pc
# pagesize
4096
# uname -a
SunOS newss1 5.10 Generic_127111-02 sun4u sparc SUNW,Sun-Fire
# pagesize

Ravi Mishra

39

Sun Solaris System Admin Notes 1


8192
Note:
In case of x86 systems page size = 4096
In case of sparc systems page size = 8192
# last
will display the informations of the system reboot and boot time
It'll read the entry from the file /var/adm/wtmpx (data file)
will also provide the information about who is currently logged in to the system
can also be used with f </var/adm/wtmpx.bkp > option to debug more
# last
root
root
root
root
root
reboot
reboot

reboot
reboot
root
root
root
root
reboot

pts/3
sshd
pts/3
sshd
console
system boot
system down

system boot
system down
pts/3
pts/4
pts/3
console
system boot

blrti2m61165.wks
blrti2m61165.wks
blrti2m61165.wks
blrti2m61165.wks
:0

wtmp begins Thu Sep

:0.0
:0.0
:0.0
:0

Wed
Wed
Mon
Mon
Fri
Fri
Fri

Nov
Nov
Oct
Oct
Oct
Oct
Oct

2
2
31
31
28
28
28

17:12
still logged in
17:12
still logged in
16:31 - 21:10 (04:39)
16:31 - 21:10 (04:39)
18:40
still logged in
18:39
18:36

Thu
Thu
Thu
Thu
Thu
Thu
Thu

Sep
Sep
Sep
Sep
Sep
Sep
Sep

8
8
8
8
8
8
8

20:11
20:10
20:09
20:09
19:44
19:42
19:39

Fri
Fri
Mon
Mon
Wed

Oct
Oct
Oct
Oct
Oct

28
28
24
24
19

18:39
18:36
11:48
11:47
17:47

Sep
Sep
Sep
Sep

13
13
13
13

11:02
11:01
10:58
10:57

20:10
20:09
20:09
20:10

(00:00)
(00:00)
(00:25)
(00:28)

11:02
11:01
10:58
10:57

(00:00)
(00:00)
(00:00)
(00:00)

8 19:39

# last -n 5 reboot
will display last 5 times reboot
# last -n5 reboot
reboot
reboot
reboot
reboot
reboot

system
system
system
system
system

boot
down
boot
down
boot

# last -f /var/adm/wtmpx.bkp -n4 ravim


ravim
ravim
ravim
ravim

sshd
sshd
sshd
sshd

localhost
localhost
localhost
localhost

Tue
Tue
Tue
Tue

# uptime
will display
1. the status of how many hours the system is in running state
2. how many users are logged to the system
3. cpu load average
# uptime
4:53pm up 2:56, 3 users, load average: 0.07, 0.08, 0.06
# /usr/ucb/whoami
will dispaly the effective user, who is currently working
# who am i
will display the real user, who directly login to the system

Ravi Mishra

40

Sun Solaris System Admin Notes 1


# /usr/ucb/whoami
root
# su - ravim
# /usr/ucb/whoami
ravim
# who am i
root pts/3 Jul 30 11:35 (:0.0)
Here,
ravim is the user logged in through "su". He is the effective user where as root is the real user, who
directly logged in to the system.
# su <user_name>
# su kamal
will permit the user's to switch as another user, but cannot take the ownership of the switch user's
home directory.
Note:
1. When root user is trying to switch as any user's system will not prompt for any password.
2. If any non-root user is trying to switch as any other user then the system will prompt for the
password
# su ravim
bash-3.00$ pwd
/
bash-3.00$ touch one two three
touch: two cannot create
touch: three cannot create
# su - <user_name>
# su - ravim
will switch user along with the home directory
# su - ravim
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
-bash-3.00$ pwd
/export/home/ravim
The switch user's log (SULOG) will be stored to the file
/var/adm/sulog
# tail /var/adm/sulog
SU
SU
SU
SU
SU
SU
SU
SU
SU
SU

09/20
09/20
09/20
09/22
09/22
09/22
10/28
11/02
11/02
11/02

14:15
14:15
14:31
11:08
11:08
11:09
18:33
17:58
17:59
17:59

+
+
+
+
+
+
+
+

pts/5 root-suresh
pts/5 root-suresh
pts/5 root-suresh
pts/4 maltesh-root
pts/4 maltesh-root
pts/4 maltesh-root
console root-root
syscon root-ravi
syscon root-ravi
syscon root-ravi

Here this file will provide the following information:


SU = Switch User
Date & Time = when they logged in
+ = implies the successful event login
- = implies the failed login attempt

Ravi Mishra

41

Sun Solaris System Admin Notes 1


pts = terminal where they tried to login
user who executed the command- as which user to login
This file will be updated automatically, whenever the "su" command is executed
/var/adm/loginlog:
1. This file will not be available by default
2. Has to be created manually
3. Has to be owned by "sys' group
4. This file logs/records the 5 consecutive failure logins of any user
5. Permission of the file is 600
# touch /var/adm/loginlog
# chmod 600 /var/adm/loginlog
# chgrp sys /var/adm/loginlog
# cat /var/adm/loginlog

scbose:/dev/pts/11:Wed Jul 29 00:08:56 2009


scbose:/dev/pts/11:Wed Jul 29 00:09:05 2009
scbose:/dev/pts/11:Wed Jul 29 00:09:14 2009
scbose:/dev/pts/11:Wed Jul 29 00:09:23 2009
mpandey:/dev/pts/11:Wed Jul 29 00:10:12 2009
mpandey:/dev/pts/11:Wed Jul 29 00:10:29 2009
mpandey:/dev/pts/11:Wed Jul 29 00:10:40 2009
mpandey:/dev/pts/11:Wed Jul 29 00:10:51 2009
mpandey:/dev/pts/11:Wed Jul 29 00:10:59 2009
hari:/dev/pts/4:Wed Jul 29 10:55:36 2009
hari:/dev/pts/4:Wed Jul 29 10:55:49 2009
hari:/dev/pts/4:Wed Jul 29 10:56:01 2009

# /usr/dt/bin/sdtprocess &
1. will invoke a pop-up menu
2. & - to indicate the shell can be used to do another task
It will provide number of information:
1. Process id of every process
2. Owner of the process
3. cpu utilization to the process
4. Memory utilization to the process
5. What process is running by every user
6. When the process was stated
It will also provide filter options to choose for a particular user.
Note: This command can only be used in the graphical environment / solaris console.
# prstat
will provide/update the following informations
1. process id of every process
2. Owner of the process
3. Cpu utilization to the process
4. Memory utilization to the process
5. What process is running by every user
6. When the process was stated
It will also provide filter options to choose for a particular user.
# prstat
PID
509
790
780
796
712
776
761

USERNAME
root 38M
root 53M
root 47M
root 64M
root 12M
root 48M
root 54M

SIZE RSS STATE


40M sleep 42 0
16M sleep 49 0
9880K sleep 59
27M sleep 59 0
9904K sleep 59
11M sleep 59 0
17M sleep 59 0

Ravi Mishra

PRI NICE TIME CPU PROCESS/NLWP


0:02:09 4.4% Xorg/1
0:00:01 0.1% gnome-terminal/2
0 0:00:04 0.1% mixer_applet2/1
0:00:07 0.1% gedit/1
0 0:00:02 0.0% gconfd-2/1
0:00:01 0.0% clock-applet/1
0:00:01 0.0% gnome-panel/1

42

Sun Solaris System Admin Notes 1


# prstat -U <user_name>
# prstat -U ravim
will display only the process running by the user che
PID USERNAME SIZE RSS STATE PRI NICE
TIME CPU PROCESS/NLWP
28733 ravim 8704K 2680K sleep 59 0 0:00:00 0.0% sshd/1
28741 ravim 2600K 2080K sleep 59 0 0:00:00 0.0% bash/1
Total: 2 processes, 2 lwps, load averages: 15.52, 15.05, 14.84

# prstat -t
will display the summary of the process
# prstat -t
NPROC USERNAME SIZE RSS MEMORY TIME CPU
65 root 945M 348M 17% 0:02:53 8.0%
1 noaccess 175M 92M 4.5% 0:00:12 0.0%
1 che 2456K 1636K 0.1% 0:00:00 0.0%
1 lp 2644K 1076K 0.0% 0:00:00 0.0%
1 smmsp 6644K 1432K 0.1% 0:00:00 0.0%
2 daemon 6216K 3080K 0.1% 0:00:00 0.0%

NOTE:
The process id of sched = 0
The process id of init = 1
The process id of svc.startd (SMF) = 7
9 = starts the svc.configd daemon related to SMF - start the services configuration daemon
# netstat
is used to monitor the network status
1. List connections of all protocol & address to and from the machine.
Address families include:
a. INET - ipv4
b. INET6 - ipv6
c. UNIX - Unix domain Sockets (Solaris/BSD/Linux/HP-UX/IBM-AIX/etc)
Protocols include:
TCP, IP, ICMP (which controls ping, echo), IGMP, RAWIP, UDP (DHCP, TFTP)
2. Lists routing table
3. Lists DHCP status for various interfaces
4. Lists net-to-media table. Network to MAC table
# netstat usage:
# netstat
TCP: IPv4
Local Address Remote Address Swind Send-Q Rwind Recv-Q State
-------------------- -------------------- ----- ------ ----- ------ ------accel1.telnet intel.32961 49640 0 49640 0 ESTABLISHED

Where
1 => hostname of the sender
2 => port/protocol
3 => hostname of the receiver / remote
4 => port/protocol of remote
NOTE:
1. # cat /etc/services
Displays the well known port number and their corresponding services
2. Hostname is displayed while using the # netstat command can be possible only of the
/etc/hosts file is having the entry of the ip-address and corresponding hostname [resolve].

Ravi Mishra

43

Sun Solaris System Admin Notes 1


This file will be indirectly checked.
When issuing the # netstat command it will read the file /etc/nsswith.conf and this file redirect to
read the file /etc/hosts [provided the entry is made].
4.Sockets are found only for TCP connections [connection oriented].
5.Sockets are NOT found for UDP connections since they are connection less.
6.No need to remember all the ports, just grep from /etc/services.
Eg: # grep syslog /etc/services
# netstat a
a.Shows the state of all packets
b.All routing table entries / all interfaces, both physical & logical
c.Returns ALL protocols for ALL address families [TCP/UDP/UNIX].
#netstat -a

UDP: IPv4
Local Address Remote Address State
-------------------- -------------------- ------*.route Idle
*.sunrpc Idle
*.* Unbound
*.32771 Idle

[Output truncated]
# netstat n
a.Shows network addresses as numbers. Normally # netstat displays addresses as symbols.
b.It disables name resolution of hosts and ports and hence displays the ip-address.
TCP: IPv4
Local Address Remote Address Swind Send-Q Rwind Recv-Q State
-------------------- -------------------- ----- ------ ----- ------ ------192.168.0.100.23 192.168.0.19.32961 49640 0 49640 0 ESTABLISHED
192.168.0.100.32921 192.168.0.5.6000 500576 0 49640 0 ESTABLISHED
127.0.0.1.32923

[Output truncated]

127.0.0.1.32879 49152 0 49152 0 ESTABLISHED

# netstat i
a.Returns the state of the physical interfaces. Pay attention to errors/collisions/queue whilst
troubleshooting.
b.When combined with -a options displays report on logical interfaces.
Name Mtu Net/Dest Address Ipkts Ierrs Opkts Oerrs Collis Queue
lo0 8232 loopback localhost 131536 0 131536 0 0 0
hme0 1500 accel1 accel1 186731 0 189733 0 0 0

NOTE:
mtu - Maximum Transmission Unit
In general the loopback address mtu will be high.

# netstat m
a.Show the STREAMS memory [How much TCP packets is working on the system]
# netstat -m

streams allocation:
streams
queues
mblk
dblk
linkblk
syncq

Ravi Mishra

current
549
1038
983
984
5
17

maximum
590
1068
1512
1603
84
25

cumulative
total
29753
45082
22413
9808550
6
37

allocation
failures
0
0
0
0
0
0

44

qband

Sun Solaris System Admin Notes 1


63

1189 Kbytes allocated for streams data

# netstat p
Returns net-to-media information
[MAC/layer-2 information] i.e., to arp table.
# netstat -p
Net to
Device
-----bge0
bge0
bge0

Media Table: IPv4


IP Address
Mask
-------------------- --------------Router.tfn.com
255.255.255.255
news_sol10
255.255.255.255
base-address.mcast.net 240.0.0.0

Flags
Phys Addr
-------- --------------o
00:00:0c:07:ac:b4
SPLA
00:1a:a0:4d:87:c2
SM
01:00:5e:00:00:00

# netstat P <protocol>
Returns active sockets for specified protocol
Eg: # netstat P tcp
Note:
1.Protocols should be specified with small letters
2.The following protocols are only allowed ip|ipv6|icmp|icmpv6|tcp|udp|rawip|raw|igmp
TCP: IPv4
Local Address Remote Address Swind Send-Q Rwind Recv-Q State
-------------------- -------------------- ----- ------ ----- ------ ------accel1.telnet intel.32961 49640 0 49640 0 ESTABLISHED
accel1.32921 192.168.0.5.6000 500576 0 49640 0 ESTABLISHED
localhost.32923
[Output truncated]
localhost.32879 49152 0 49152 0 ESTABLISHED

# netstat r
a.Returns routing table
b.Normally, only interface, host, network & default routes are displayed
c.Combined with -a option, all routes will be displayed, including cache.
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ------ --------192.168.0.0 accel1 U 1 19 hme0
224.0.0.0 accel1 U 1 0 hme0
localhost localhost UH 47 133672 lo0

# netstat D
Returns DNCP configuration [includes releases/renewal etc]
# netstat an f [inet|inet|6|unix]
-f => allows to specify the family address
Eg: # netstat an f inet
Displays only ipv4 information
UDP: IPv4
Local Address Remote Address State
-------------------- -------------------- ------*.520 Idle
*.111 Idle
*.* Unbound
*.32771 Idle
*.* Unbound
[Output truncated]

# ps -ef

Ravi Mishra

45

Sun Solaris System Admin Notes 1


will list out what are the process running
# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 0 0 0 11:31:55 ? 0:51 sched
root 1 0 0 11:32:02 ? 0:00 /sbin/init
root 2 0 0 11:32:02 ? 0:00 pageout
root 3 0 0 11:32:02 ? 0:03 fsflush
daemon 191 1 0 11:32:10 ? 0:00 /usr/sbin/rpcbind
root 7 1 0 11:32:04 ? 0:01 /lib/svc/bin/svc.startd
root 9 1 0 11:32:04 ? 0:02 /lib/svc/bin/svc.configd
root 126 1 0 11:32:08 ? 0:00 /usr/lib/picl/picld

To kill the process:


# kill <process_id>
# pkill <process_id>
# kill 3753
# pkill 3753
will kill the process specified

PERFORMING SYSTEM SECURITY


FTP IMPLEMENTATION:
Wu ftpd => Washington University ftpd daemon
1.
2.
3.
4.

FTPD binds to TCP port 21 and is running by default.


SMF controls FTP service configuration.
# svcs ftp -- Displays the status of the ftp service.
# pkginfo l | grep -i ftp -- Displays the detailed information about ftp service.

FTP Commands:
# ftpcount and # ftpwho [displays the connected users & process information]
# ftpconfig utility is used to setup anonymous/guest ftp
FTP Configuration files:
/etc/ftpd
ftpaccess primary configuration file for wu-ftpd
ftphost allow/deny access to users from hosts
ftpservers allows root to define virtual hosts
ftpusers users listed are NOT permitted(denied) to access the server via ftp
ftpconversions facilitates tar, compress, gzip support
NOTE: By default root user is denied to use ftp.
wu ftp daemon supports 2 types of ftp connections : Active and Passive FTP
ACTIVE FTP
In active mode FTP the client connects from a random unprivileged port (N > 1023) to the FTP server's
command port, port 21. Then, the client starts listening to port N+1 and sends the FTP
command PORT N+1 to the FTP server. The server will then connect back to the client's specified data
port from its local data port, which is port 20.

Ravi Mishra

46

Sun Solaris System Admin Notes 1


From the server-side firewall's standpoint, to support active mode FTP the following communication
channels need to be opened:
FTP server's port 21 from anywhere (Client initiates connection)
FTP server's port 21 to ports > 1023 (Server responds to client's control port)
FTP server's port 20 to ports > 1023 (Server initiates data connection to client's data port)
FTP server's port 20 from ports > 1023 (Client sends ACKs to server's data port)
When drawn out, the connection appears as follows:

In Step 1, the client's command port contacts the server's command port and sends the
command PORT 1027. The server then sends an ACK back to the client's command port in step 2. In
step 3 the server initiates a connection on its local data port to the data port the client specified
earlier. Finally, the client sends an ACK back as shown in step 4.
The main problem with active mode FTP actually falls on the client side. The FTP client doesn't make
the actual connection to the data port of the server--it simply tells the server what port it is listening
on and the server connects back to the specified port on the client. From the client side firewall this
appears to be an outside system initiating a connection to an internal client--something that is usually
blocked.
PASSIVE FTP
In order to resolve the issue of the server initiating the connection to the client a different method for
FTP connections was developed. This was known as passive mode, or PASV, after the command used
by the client to tell the server it is in passive mode.
In passive mode FTP the client initiates both connections to the server, solving the problem of firewalls
filtering the incoming data port connection to the client from the server. When opening an FTP
connection, the client opens two random unprivileged ports locally (N > 1023 and N+1). The first port
contacts the server on port 21, but instead of then issuing a PORT command and allowing the server
to connect back to its data port, the client will issue the PASV command. The result of this is that the
server then opens a random unprivileged port (P > 1023) and sends the PORT P command back to the
client. The client then initiates the connection from port N+1 to port P on the server to transfer data.
From the server-side firewall's standpoint, to support passive mode FTP the following communication
channels need to be opened:
FTP server's port 21 from anywhere (Client initiates connection)
FTP server's port 21 to ports > 1023 (Server responds to client's control port)

Ravi Mishra

47

Sun Solaris System Admin Notes 1


FTP server's ports > 1023 from anywhere (Client initiates data connection to random port specified by
server)
FTP server's ports > 1023 to remote ports > 1023 (Server sends ACKs (and data) to client's data port)
When drawn, a passive mode FTP connection looks like this:

In step 1, the client contacts the server on the command port and issues the PASV command. The
server then replies in step 2 with PORT 2024, telling the client which port it is listening to for the data
connection. In step 3 the client then initiates the data connection from its data port to the specified
server data port. Finally, the server sends back an ACK in step 4 to the client's data port.
While passive mode FTP solves many of the problems from the client side, it opens up a whole range of
problems on the server side. The biggest issue is the need to allow any remote connection to high
numbered ports on the server. Fortunately, many FTP daemons, including the popular WU-FTPD allow
the administrator to specify a range of ports which the FTP server will use.
The second issue involves supporting and troubleshooting clients which do (or do not) support passive
mode. As an example, the command line FTP utility provided with Solaris does not support passive
mode, necessitating a third-party FTP client, such as ncftp.
With the massive popularity of the World Wide Web, many people prefer to use their web browser as an
FTP client. Most browsers only support passive mode when accessing ftp:// URLs. This can either be
good or bad depending on what the servers and firewalls are configured to support.

# ftpcount
Shows current number of users in each ftp server class
-v displays the user counts for ftp server classes defined in virtual host [ftpaccess]
-V display program copyright and version information then terminate
# ftpcount
Service class realusers - 1 users (no maximum)
Service class guestusers - 0 users (no maximum)
Service class anonusers - 0 users (no maximum)

# ftpwho
Shows current process information for each ftp server user
1. Itll display which user is logged in along with the process id
2. Status of the user will be displayed
3. Will also display the password given by the anonymous user
# ftpwho

Service class realusers:


bhagat 1157 0.0 0.2 4852 2628 ? S 12:48:03 0:00 ftpd:

Ravi Mishra

48

192.168.0.157: bhagat: IDLE


- 1 users (no maximum)
Service class guestusers:
- 0 users (no maximum)
Service class anonusers:
- 0 users (no maximum)

Sun Solaris System Admin Notes 1

Here,
a real user named - bhagat is logged through ftp
Note: Login time via ftp is defined in the file /etc/ftpd/ftpaccess Time out in seconds.
Anonymous FTP Configuration:
We need to generate the user name as either ftp or anonymous along with directory.
#ftpconfig /anonFTP
Creating user ftp
Creating directory /anonFTP
Updating directory /anonFTP

# cat /etc/passwd |grep ftp


[permission should be as below]
ftp:x:60009:1:Anonymous FTP:/anonFTP:/bin/true
We need to sync the FTP user name with /etc/shadow file
#pwconv
Change ownership on this directory to others
#chown -R root:other /anonFTP
# ls -ldr /anonFTP
drwxr-xr-x
8 root
other
512 Sep 12 15:55 /anonFTP
Set permission on just created directory with 555 permission
#chmod -R 555 /anonFTP
# ls -ldr /anonFTP
dr-xr-xr-x
8 root
other
512 Sep 12 15:55 /anonFTP
Change the permission for pub directory to 777 where the files will be uploaded and downloaded from
#chmod -R 777 /anonFTP/pub
#ls -ldr /anonFTP/pub
drwxrwxrwx
2 root
other
512 Sep 12 15:55 /anonFTP/pub
Modify /etc/ftpd/ftpaccess file by adding the fallowing line
#vi /etc/ftpd/ftpaccess
upload /anonFTP /pub yes ftp other 0600 nodirs
:wq!
Restart the FTP service
#svcadm disable ftp
#svcs a|grep ftp
#svcadm enable ftp
ftp 172.19.218.213

Name (dtci-fish01:root): ftp


331 Guest login ok, send your complete e-mail address as password.
Password: use enter [no need of password]
ftp>cd pub
ftp>ls -l
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.

Ravi Mishra

49

total 0
-rwxrwxrwx
-rwxrwxrwx
-rwxrwxrwx
-rwxrwxrwx

Sun Solaris System Admin Notes 1


1
1
1
1

root
root
root
root

root
root
root
root

0
0
0
0

Sep
Sep
Sep
Sep

12
12
12
12

16:51
16:51
16:51
16:51

a
b
c
d

Ftpd class support:


Facilitates the grouping of users for the purpose of assigning directives
By default it has three classes:
1. Real users:
a. Can login using shell [ssh/telnet]
b. Can browse the entire directory
2. Guest users:
a. Are temporary users
3. Anonymous user:
a. General public for download capability
All the 3 default classes are defined to the file /etc/ftpd/ftpaccess
Restart the ftp service
# svcadm restart ftp
NOTE: Guest users are similar to real users, except guest users are jailed/chrooted, see below
ftpserver01 $ grep ftponly /etc/passwd
ftp:x:192:192:FTP administration:/ilx/ftp/:/etc/ftponly
VGguest:x:235:235:Guest login account for VG:/ilx/ftp/.//VG:/etc/ftponly
FPguest:x:236:236:Guest login account for FP:/ilx/ftp/.//FP:/etc/ftponly
ZZguest:x:221:221:Guest login account for ZZ:/ilx/ftp/.//ZZ:/etc/ftponly
SWguest:x:569:569:Guest login account for SW:/ilx/ftp/.//SW:/etc/ftponly
TGguest:x:574:574:Guest login account for TG:/ilx/ftp/.//TG:/etc/ftponly
ftpserver01 $ cat /etc/ftponly
-- FTPonly access script
#!/bin/sh
#
# ftponly shell
#
trap "/bin/echo Sorry; exit 0" 1 2 3 4 5 6 7 10 15
#
IFS=""
Admin=ravim@ilx.com
System=`/usr/bin/hostname`
#
/bin/echo
/bin/echo "********************************************************************"
/bin/echo "
You are NOT allowed interactive access to $System."
/bin/echo
/bin/echo "
User accounts are restricted to ftp and web access."
/bin/echo
/bin/echo " Direct questions concerning this policy to $Admin."
/bin/echo "********************************************************************"
/bin/echo
#
# C'ya
#
exit 0

Ravi Mishra

50

Sun Solaris System Admin Notes 1


Denying Anonymous User account:
Ftp Server Fire2 192.168.0.100
# mkdir /ftp_anonymous
bash-3.00# ftpconfig -d /ftp_anonymous/
Updating directory /ftp_anonymous/
bash-3.00# ls /ftp_anonymous/
bin dev etc lib pub usr
bash-3.00# ftpconfig /ftp_anonymous/
Updating directory /ftp_anonymous/
bash-3.00# svcadm restart ftp
bash-3.00# svcs ftp
online 15:24:31 svc:/network/ftp:default
bash-3.00# ftpwho
Service class realusers:
- 0 users (no maximum)
Service class guestusers:
- 0 users (no maximum)
Service class anonusers:
ftp 2096 0.0 0.1 2232 1600 ? S 15:24:48 0:00 ftpd: fire1: anonymous/anonymous"gmail.com: IDLE
1 users (no maximum)

Denied access in ftpusers in Server machine


# vi /etc/ftpd/ftpusers

"/etc/ftpd/ftpusers" 18 lines, 193 characters


# ident "@(#)ftpusers 1.5 04/02/20 SMI"
#
# List of users denied access to the FTP server, see ftpusers(4).
#
daemon
bin
sys
adm
lp uucp
nuucp
smmsp
listen
gdm
webservd
nobody
noaccess
nobody4
anonymous

# ftpwho

Service class
- 0 users (no
Service class
- 0 users (no
Service class
- 0 users (no

realusers:
maximum)
guestusers:
maximum)
anonusers:
maximum)

PROCESS SHCEDULING: AT & CRON


# at => executes the command only once and every user has the right to execute the at command
# at <time>
# at 1030

Ravi Mishra

51

Sun Solaris System Admin Notes 1


Options with at command:
# at now
# at now +2hour
# at now +30min
# at now next week
# at 12pm sunday
# at 12pm aug 31
# atrm <jobid>.a
# atrm 1249026000.a
# at -r 1249026000.a

To remove the scheduled tasks.


# atq
Rank Execution Date Owner Job Queue Job Name
1st Jul 31, 2009 13:10 root 1249026000.a a stdin
# at -l
user = root 1249026000.a Fri Jul 31 13:10:00 2009
/var/spool/cron/atjobs -- directory which holds the information about the scheduled tasks and it's id
/etc/cron.d/at.deny this file will have the login name of the users who are denied to use the at
command.
Here default system user's are listed.
# cat /etc/cron.d/at.deny
daemon
bin
nuucp
listen
nobody
noaccess

/etc/cron.d/at.allow this file will not be present by default it has to be created manually. This file
holds the login name of the users who are having the permission to access the at command.
NOTE:
1. In general system will check for the /etc/cron.d/at.allow file first and then moves to the file
/etc/cron.d/at.deny.
2. If a user is given entry to both the files, then he is permitted to use the commands (in both
at,crontab)
/var/cron/log this file logs the at command scheduling
In the case of crond
We have the file /etc/crond.d/cron.deny
# cat /etc/cron.d/cron.deny
daemon
bin
nuucp
listen
nobody
noaccess

The file /etc/cron.d/cron.allow will not exist, if needed it can be created.


NOTE:
The function of the files remains same at at.allow and at.deny

Ravi Mishra

52

Sun Solaris System Admin Notes 1


# cron => will execute the process recursively it has number of fileds
1. minute field - 0 to 59
2. hour field - 0 to 23
3. day of month - 1 to 31
4. month field - 1 to 12
5. day of the week field- 0 to 6 where 0 stands for Sunday and 6 for Saturday
6. command field - what command has to be executed
# crontab -l
will list out what are the tasks scheduled in the system
# crontab -l <user_name>
# crontab -l ravim will list out what are the tasks scheduled only by the user ravim.
# export EDITOR=vi
# crontab e to edit or to add the schedules to the crond.

PERFORMING SYSTEM SECURITY


NOTE:
By default the Telnet service to the root is denied, and rest users are permitted to login through telnet.
This function is defined in the file /etc/default/login
Output: (Partially added relevant to the topic)
# vi /etc/default/login
# If CONSOLE is set, root can only login on that device.
# Comment this line out to allow remote login by root.
#
CONSOLE=/dev/console

1. By default the file entry will be


CONSOLE=/dev/console
And this entry denies the root access through telnet.
2. To make the root user to access through telnet the file has to be edited as,
#CONSOLE=/dev/console
This entry will allow the root user to access through telnet
3. To deny the root user to login to the local system (console)
The file has to be edited as,
CONSOLE=
This entry will restrict root user to login to the local system.
To view the status of the telnet service: (Solaris - 10)
# svcs telnet
online 12:03:15 svc:/network/telnet:default
To disable the telnet service to the local system:
# svcadm disable telnet
To enable telnet:
# svcadm enable telnet

Ravi Mishra

53

Sun Solaris System Admin Notes 1


# svcs telnet
online 12:34:58 svc:/network/telnet:default
Output: (Partial output relevant to the topic)

# cat /etc/default/login
# PASSREQ determines if login requires a password.
#
PASSREQ=YES

Determines whether password is required at time of login


Output: (Partial output relevant to the topic)

# cat /etc/default/login
# TIMEOUT sets the number of seconds (between 0 and 900) to wait before
# abandoning a login session.
#
TIMEOUT=300

While login through telnet the login prompt will be displayed to 300 sec. It can be decreased.
Output: (Partial output relevant to the topic)
Determine number of retries if the password is wrongly typed.

# cat /etc/default/login
# RETRIES determines the number of failed logins that will be
# allowed before login exits. Default is 5 and maximum is 15.
# If account locking is configured (user_attr(4)/policy.conf(4))
# for a local user's account (passwd(4)/shadow(4)), that account
# will be locked if failed logins equals or exceeds RETRIES.
#
#RETRIES=5

Output: (Partial output relevant to the topic)


# vi /etc/default/telnetd
# Suppress the telnet banner by supplying a null definition.
#
BANNER="Only if u r authenticated, login to the system "
Can edit the message, this will be displayed at the time of telnet login.

PRINTER CONFIGURATION
# printmgr &
=> This above command opens a menu
=> Printer configuration can be menu driven
NOTE:
1. Before configuring the printer make sure about the compatibility with the sun Microsystems.
2. Check the make and the type
3. The port to which the printer is connected physically.
Once the menu is opened,
1. Enable the "confirm actions" from the main menu
2. Select the newly attached printer
a) give the printer name ( can be any name )
b) description can also be anything
c) choose the correct port
(Here we have chosen /dev/pts/7 for our eg. In this case if we want to specify the port choose "other')
d) select the type of the printer

Ravi Mishra

54

Sun Solaris System Admin Notes 1


e) select -> the banner options if required or never print banner
f) user access list -> by default every user is given the right to sent the request to the printer. If
we want to restrict, add the specific users from the user list.
g) apply the changes
# lp <file_name>
eg: # lp check_printer will the print the file named "check_printer" to the default printer
# lpstat -d
displays which is activated as the default printer if we have configured more than one printer
# lpstat -p
displays status of all the printers that are configured to the system
# lpadmin -d <printer_name>
eg: # lpadmin -d hp will activate "hp" as the default printer if we had configured more than one printer.
# reject <printer_name>
eg: # reject hp this command will reject the requests to the printer named "hp"
ie.. hp printer will not accept the requests from any user including the root.
NOTE:
In the above case, printer is physically connected, activated but the request will not be fulfilled or not
accepted.
# reject 5stars_bkp
destination "5stars_bkp" will no longer accept requests
# lp -d 5stars_bkp /etc/shadow
5stars_bkp: requests are not being accepted
# accept 5stars_bkp
destination "5stars_bkp" now accepting requests
# lp -d 5stars_bkp /etc/shadow
request id is 5stars_bkp-12 (1 file(s))
# lpstat -d
system default destination: 5stars
# lpstat -p

printer 5stars is idle. enabled since Fri Jul 31 16:34:22 2009. available.
printer 5stars_bkp is idle. enabled since Fri Jul 31 16:39:54 2009. available.

# lpadmin -d 5stars_bkp
# lpstat -p

printer 5stars is idle. enabled since Fri Jul 31 16:34:22 2009. available.
printer 5stars_bkp is idle. enabled since Fri Jul 31 16:39:54 2009. available.

# lpstat -d
system default destination: 5stars_bkp
# accept <printer_name>
eg: # accept hp
this command will start sending the request to the printer named "hp"
In other words printer starts printing the desired output.

Ravi Mishra

55

Sun Solaris System Admin Notes 1


# disable <printer_name>
eg: # disable hp this command will disable the printer. In other words printer is not activated.
# enable <printer_name>
eg: # enable hp will activate/enable the printer specified.
/var/lp/logs/requests -> provides the information on the print logs which inclues
1. which user given the print request
2. date & time of the request
3. size of the file
4. user id, group id
5. file name
6. location of the file
# lpq
provide the information about the request in the queue.
BACKUP & RESTORE
1. slice 4 and slice 5 with 1 gb each
2. Slice 6 and slice 7 with 2 gb each
Now, we are going to mount slice 4 under /mnt/source. Lets add some data to the slice.
Since we are discussing about OFFLINE backup, lets umount the slice4.
Here let us consider slice6 as the backup media.
It should be a COMPLETE backup since its our first time.
# ufsdump <level_of_the_backup>uf <back_media> <slice_to_be_backedup>
# ufsdump 0uf /dev/rdsk/c1d0s6 /dev/dsk/c1d0s4
Here
0 = level of the backup (Complete backup)
u = to update the information about the backup on the file /etc/dumpdates
f = to specify the device
/dev/rdsk/c1d0s6 = backup media where the backed up information are stored
/dev/dsk/c1d0s4 = is the slice which is having the data to be backed up
# ufsdump 0uf /dev/rdsk/c1d0s6 /dev/dsk/c1d0s4
DUMP:
DUMP:
DUMP:
DUMP:
DUMP:
DUMP:
DUMP:
DUMP:
DUMP:
DUMP:
DUMP:
DUMP:

Date of this level 0 dump: Tue Aug 04 23:08:33 2009


Date of last level 0 dump: the epoch
Dumping /dev/rdsk/c1d0s4 to /dev/rdsk/c1d0s6.
Mapping (Pass I) [regular files]
Mapping (Pass II) [directories]
Writing 32 Kilobyte records
Estimated 16560 blocks (8.09MB).
Dumping (Pass III) [directories]
Dumping (Pass IV) [regular files]
16446 blocks (8.03MB) on 1 volume at 48370 KB/sec
DUMP IS DONE
Level 0 dump on Tue Aug 04 23:08:33 2009

# cat /etc/dumpdates

/dev/rdsk/c1d0s3 0 Mon Aug 3 12:32:52 2009


/dev/rdsk/c1d0s3 1 Mon Aug 3 12:41:49 2009
/dev/rdsk/c1d0s4 0 Tue Aug 4 23:08:33 2009

From this file we can understand,


c1d0s3 had been completely (0) backed up on Aug 3 12:32
c1d0s3 had been incremental backup (1) on Aug 3 12:41

Ravi Mishra

56

Sun Solaris System Admin Notes 1


Now lets mount the slice4 once again at the same mount point.
Do some updates to the created file and create some new file or directory at the mount point.
Then unmount the slice4
Since we are going to discuss on incremental backup, specify the level of the backup whilst backup.
# ufsdump <level_of_the_backup>uf <backup_media> <device_to_be_backedup>
# ufsdump 1uf /dev/rdsk/c1d0s7 /dev/dsk/c1d0s4
here
1 = specifies the level of backup (Incremental)
Only the updated informations is backed up
u = update the file /etc/dumpdates
f = specifies the device
/dev/rdsk/c1d0s7 = is the backup media
/dev/dsk/c1d0s4 = the slice having the data
# ufsdump 0S /dev/dsk/c1d0s4
will display how much of space is required to take a complete backup.
# ufsdump 0S /dev/dsk/c1d0s4
8478720
# ufsdump 1S /dev/dsk/c1d0s4
will display how much of space is required for incremental level(1) backup.
Q. How to restore the data?
NOTE:
1. Backup media need not to be have the file system.
2. Only after restoring the COMPLETE backup, incremental backup can be done.
3. However selected files and directories can also be restored.
4. After restoring a file named "restoresysmtable" will be created at the restored point.
It is not readale and not recommended to delete this file. This file will be used while restoring the
incremental backup.
5. Restore can be done at any point.
# ufsrestore rf <backuped_device>
# ufsrestore rf /dev/rdsk/c1d0s6
where
r = specifies recurssively. will restore all the files and directories that is backed up to the media
/dev/rdsk/c1d0s6
f = specifies the device
# ufsrestore -if /dev/rdsk/c1d0s6
i = interactive
Can be possible to know what are the files and directories are backed up and can be listed out.
Is possible to restore the selected files.
# ufsrestore -if /dev/rdsk/c1d0s6
Now the prompt will be changed.
ufsrestore>
ufsrestore>ls
will list out what are the files and directories that are backed up the media (/dev/rdsk/c1d0s6)

Ravi Mishra

57

Sun Solaris System Admin Notes 1


ONLINE BACKUP OR SNAPSHOT
# fssnap -F <filesystem> -o bs=<any-dir> <mount_point>
Snapshot or online backup is used to take a snapshot of the mounted slice.
# fssnap -F ufs -o bs=/var/tmp /mnt/source
here
-F = specifies the filesystem
-o = to specify the options
bs = backing store. which will hold only the updates of the snapshot
/var/tmp = backing store directory
/mnt/source = mount point or the source to be snapshoted.
This command will create a virtual snap device as follows
/dev/fssnap/0
# fssnap -F ufs -o bs=/var/tmp /backing_store
/dev/fssnap/0
NOTE:
This virtual device (/dev/fssnap/0) can be mounted as READ ONLY.
Hence the virtual device can be mounted as read only
# mount -o ro /dev/dsk/fssnap/0 /mnt/virtual
Then to make a backup of the virtaul device,
# ufsdump 0uf /dev/rdsk/c1d0s7 /dev/fssnap/0
here
0 = complete backup. level of the backup
u = to update the file /etc/dumpdates
f = to specify the device
/dev/rdsk/c1d0s7 = backup media
/dev/fssnap/0 = device to be backed up
# fssanp -i
will display the informations about the snap devices available in the system and their corresponding
source.
# fssnap -i
0 /backing_store
# fssnap -i /dev/fssnap/0
0 /backing_store
will provide the information about which mount point is backed up
# fssnap -d <snap_device>
# fssnap -d /dev/fssnap/0
To delete the specified snap device.
NOTE:
Restoring the data is as similar to normal offline backup.

Ravi Mishra

58

Sun Solaris System Admin Notes 1


TAKING A BACKUP OF A ROOT SLICE:
NOTE:
1. Enter into the system maintenance mode
2. Then check the destination size of the tape/disk
3. Proceed with the backup.
# ufsdump 0uf /dev/rdsk/c1d0s6 /dev/dsk/c1d0s0
here, slice6 is taken as backup device which has nearly 4gb of space
Restoring the root backup
1. Boot from the cd
2. DONOT mount the root slice (ie s0)
3. Create the file system for the root slice
4. Mount the root slice in /a dir
5. Move to the /a dir
6. restore the backedup information
7. a. install the bootblk in the case of SPARC
b. install the grub in the case of X86/X64
8. restart the system.
# cd /
# newfs /dev/rdsk/c1d0s0
# mount /dev/dsk/c1d0s0 /a
# cd /a
# ufsrestore rvf /dev/rdsk/c1d0s6
# rm restoresysmtable
# cd /usr/platform/`uname -m`/lib/fs/ufs
# installboot bootblk /dev/rdsk/c1t1d0s0 -> SPARC
# installgrub -fm /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1d0s0
where
-f => suppresses interaction when overwriting the master boot record
-m => installs GRUB stage1 on the master boot sector interactively

-->> X86/X64 arch

# cd /
# umount /a
# init 6

Ravi Mishra

59