Sie sind auf Seite 1von 144

Solaris 10

Introduction to UNIX / Solaris 10

Unix (officially trademarked as UNIX, sometimes also written as UNIX) is a multitasking, multi-
user computer operating system originally developed in 1969 by a group of AT&T employees at
Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy and Joe
Ossanna. The Unix operating system was first developed in assembly language, but by 1973 had
been almost entirely recoded in C, greatly facilitating its further development and porting to
other hardware. Today's Unix system evolution is split into various branches, developed over
time by AT&T as well as various commercial vendors, universities (such as University of
California, Berkeley's BSD), and non-profit organizations.

Solaris is a Unix operating system originally developed by Sun Microsystems. It superseded


their earlier SunOS in 1993. Oracle Solaris, as it is now known, has been owned by Oracle
Corporation since Oracle's acquisition of Sun in January 2010.[2]

Solaris is known for its scalability, especially on SPARC systems, and for originating many
innovative features such as ZFS, SMF and Zones. Solaris supports SPARC-based and x86-based
workstations and servers from Sun and other vendors, with efforts underway to port to
additional platforms.
2
Unix Principles

Everything is a file.

− Including hardware

Configuration data stored in text

Small, single-purpose programs

Ability to chain programs together to perform complex tasks.

3
.
# uname –a -----------------------------------------------Gives all details about the system
# uname –m ----------------------------------------------Displays H/W platform (sun4u)
# uname –p -----------------------------------------------Machine processor architecture (sparc or i386)
# uname –i ------------------------------------------------Machine model architecture (SUNW, Ultra 5_10)
# uname –X -----------------------------------------------Detailed description

# mkdir –p /data/dir ------------------------------------Creates directory and sub directory in one shot


# rmdir –r /data -----------------------------------------Deletes the directory and all its subdirectory and files
# cp –r /data /data1 ------------------------------------It copies the directory

# echo $MANPATH
: /usr/local/samba/man:

# echo $PATH -------------------------------------------Shows environmental path


/usr/sbin:/usr/bin

Grep Command Options


-i Searches for both upper & lower case characters
-l Lists the names of files with matching lines
-n Proceeds each line with the relative line number in the file
-v Inverts the search to display lines that do not match the pattern
-w Searches for the expression as a complete word.

# find /kris –name file1 --------------------------------------------------------Searches for file file1 in /kris directory
# find /ris –name file1 –exec ls –l {} \; -------------------------------------Search and display
# find /kris –type f –size 0 –exec ls –l {} \; --------------------------------Search for the file with size 0
# find /kris –user user1 --------------------------------------------------------Shows file used by user ‘user1’

$ PATH=$PATH:/usr/ccs/bin:/usr/ucb: --------------------------------------It will get appended to the existing path

# ln –s <source filename> <destination filename> -----------------------Creating symbolic link


# ln <source filename> <destination filename> ---------------------------Creating hard link

4
.
File Archives
# tar –cvf bkp.tar file1 file2 -----------Will archive file1 & file2
# tar –tvf bkp.tar -----------------------Shows the table of content
# tar –xvf bkp.tar -----------------------It extracts file from the tar archive
# jar –cvf bkp.tar
# jar –tvf bkp.jar
# jar –xvf bkp.jar
# compress bkp.tar --------------------To compress tar archive
# ls
bkp.tar.z
# uncompress bkp.tar.z ----------------To uncompress tar archive
# gzip bkp.tar ----------------------------To create gzip file
bkp.tar.gz
# gunzip bkp.tar.gz ---------------------To extract the tar archive by gunzip
bkp.tar
# zip out.zip bkp.tar --------------------To create zip archive
# unzip out.zip --------------------------To extract the zip archive

5
Unit 1

 Introducing the Solaris 10 Directory Structure

6
Introducing the Solaris 10 Directory Structure
4. /home – Home Directories
Home directories for all users to store their personal files.
For example: /home/john, /home/nikita

5. /kernel – Kernel Components


Contains kernel components common to all platforms within a particular instruction
set that are needed for booting the system.

6. /sbin – System Binaries


Just like /bin, /sbin also contains binary executables.
But, the commands located under this directory are used typically by system
administrator, for system maintenance purpose.
For example: fdisk, mount, swapadd
1. / – Root
Every single file and directory starts from the root directory.
Only root user has write privilege under this directory.
/ is also the root account home directory.

2. /dev – Device files.


Contains device files.
These include terminal devices, usb, or any device attached to the system.
For example: /dev/tty1, /dev/usbmon0

3. /etc – Configuration files


Contains configuration files required by all programs.
This also contains startup and shutdown shell scripts used to start/stop individual
programs.
For example: /etc/services, /etc/resolv.conf, /etc/inetd.conf
7. /bin – User Binaries
this points to /usr/bin
All binaries are located under /usr/bin.

8. /lib – System Libraries


Contains library files that supports the binaries located under /bin and /sbin
Library filenames are lib*.so.*
For example: libmtsk.so, libncurses.so.5.7

9. /mnt – Mount Directory


Empty folder generally used for mounting file systems.
10. /opt – Optional add-on Applications
opt stands for optional.
Contains add-on applications from individual vendors.
add-on applications should be installed under either /opt/ or /opt/ sub-directory.

11. /platform – Platform Definition files


Contains platform definition files.
For example: /platform/SUNW,SPARC-Enterprise-T3120, /platform/SUNW,Sun-
Blade-T6340

12. /proc – Process Information


Contains information about system process.
This is a pseudo filesystem contains information about running process. For
example: /proc/{pid} directory contains information about the process with that
particular pid.
This is a virtual filesystem with text information about system resources. For
example: /proc/uptime
13. /tmp – Temporary files
Directory that contains temporary files created by system and users.
Files under this directory are deleted when system is rebooted.

14. /usr – User Programs


Contains /usr/bin which is been linked from /bin.
Contains certain other links such as spool, news, man, mail.

15. /var – Variable files


var stands for variable files.
Content of the files that are expected to grow can be found under this directory.
This includes system log files (/var/log); packages and database files (/var/lib);
emails (/var/mail); print queues (/var/spool); temp files needed across reboots
(/var/tmp);
File components:
File Names: File has a name that is associated with an inode.

Inode: is a object that the Solaris OS uses to record information about a file
Inodes are numbered, and each file system contains its own inode list.

Inodes contain two parts:


1. File information, including the file owner, permissions, and size.
2. Pointers to data blocks associated with the file content.

Data Blocks: are disk space units used to store data. ( note: device files donot hold
data)
The character in the first column identifies each file type, as follows:
- Regular files
d Directories
l Symbolic links
b Block-special device files
c Character-special device files
Symbolic Links
A symbolic link is a file that points to another file.
A symbolic link contains the path name of the file to which it
points.
Because symbolic links use path names to point to other files, they
can point to files in other file systems.
The size of a symbolic link always matches the number of
characters in the path name it contains.
# ln –s <filename> <linkname>
Device Files
A device file provides access to a device. the inode
information of device files holds numbers that refer to devices.

A long listing of a device file shows two numbers, separated by a


comma,
These two numbers are called major and minor device numbers.

A major device number identifies the specific device driver required


to access a device. A minor device number identifies the specific
unit of the type that the device driver controls.
A reconfiguration boot creates device files and symbolic links to
the device files automatically.
A relationship exists between the device file and the device it
controls.The major and minor device numbers contained in the
inode establish the relationship.
Device files fall into two categories: character-special devices and
block-special devices. Character-special devices are also called
character or raw devices. Block-special devices are often called
block devices. Device files in these two categories interact with
devices differently.
Character-Special Device Files
The file type “c” identifies character-special device files. Data is
accessed as a data stream.
Block-Special Device Files
The file type “b” identifies block-special device files. For disk devices,
block-special device files call for I/O operations based on a defined
block size. The block size depends on the particular device.
Data transferred between a process and a block-special device is
first stored in a kernel-managed memory-based cache. This
provides better performance when data is being accessed from
block-special devices in a repetitive manner. Also, block devices
allow random seeks to be performed, and character devices do not
Hard Links
A hard link is the association between a file name and an inode. A hard
link is not a separate type of file. Every type of file uses at least one hard
link.
Information in each inode keeps count of the number of file names
associated with it. This is called a link count. In the output from the
ls -l command, the link count appears between the column of file
permissions and the column identifying the owner.
Create new Hard Link:
A new hard link for a file name increments the link count in the
associated inode
# ln file1 file2
# ls –li --- display the inode number
# find . –inum <inode#> -- display files with those inodes
Note: hard links cannot span filesystems ( they have to be in the same
filesystem)
# rm file1 --- removing hard link ( the link count decrement )
Unit 2

 Disk and Storage Management


Disk and Storage Management

Device Naming :
Disks, like other devices of the Solaris 10 operating system, can be
referenced using, three naming conventions:

Physical device name


Logical device name
Instance name

1) Physical Device Name :


When the system is booted, the kernel builds a device hierarchy, referred to
as the device tree, to represent the devices attached to the system. This tree
is a hierarchy of interconnected buses; the devices attached to the buses are
nodes. The root node is the main physical address bus.
driver-name@unit-address:device arguments
driver-name@unit-address:device arguments
1) Driver-name identifies the device name,
2) @unit-address is the physical address of the device in the address space
of the parent,
3) and :device arguments defines additional information regarding the
device software. For example, the following full device address represents
a slice of a SCSI disk drive on a SPARC system:
/sbus@1f,0/esp@0,4000/sd@3,0:a
These name are located under the /devices directory.
2) Logical Device Name :
Logical device names are used with most Solaris file system commands to
refer to devices. Logical device files in the /dev directory are symbolically
linked to physical device files in the /devices directory. Logical device
names are used to access disk devices.
/dev/dsk Block interface to disk devices
/dev/rdsk Raw or character interface to disk devices
/dev/rmt Tape devices
/dev/term Serial-line devices
/dev/cua Dial-out modems
/dev/pts Pseudo terminals

E.g. : /dev/dsk/c0t0d0s0 For raw device /dev/rdsk/c0t0d0s0


/dev/dsk/c0t3d0s0
All logical device names reside under the /dev directory, and the /dev/dsk
subdirectory identifies the device as a block disk device. This block disk
device is addressed as SCSI controller 0, SCSI bus target 3, drive 0, and
slice (partition) 0.

c x Refers to the SCSI controller number


t x Refers to the SCSI bus target number
d x Refers to the disk number
s x Refers to the slice or partition number
3) Instance Name :
Instance names are abbreviated names that are mapped to or associated
with the physical device names of devices. These names allow devices to
be quickly and easily identified without requiring the use of the long and
typically complicated physical device names. An instance name typically
consists of a short driver binding name, such as sd, and an instance
number.
 For example, sd0 could be the instance name of the first SCSI disk or fd0
could be the instance name of the first diskette drive.
Mapping of physical device names with instance names is done in
/etc/path_to_inst file.
The file is rebuilt automatically when System boots in reconfigure mode.
Physical Name Instance No. Driver Binding
“/pci@0,0” 0 “pci”
Disk Management

1) Disk Slices :


Disks are divided into regions called disk slices or disk partitions. A slice
is composed of a single range of contiguous blocks. It is a physical subset
of the disk (except for slice 2,which represents the entire disk).

A UNIX file system is built within these disk slices. The boundaries of a
disk slice are defined when a disk is formatted by using the Solaris format
utility, and the slice information for a particular disk can be viewed by
using the prtvtoc command. Each disk slice appears to the operating
system (and to the system administrator) as though it were a separate disk
drive.

To define a slice,the administrator provides a starting cylinder and an


ending cylinder. A disk can have up to eight slices, named 0 to 7.
Rules while Creating Slices :
Each disk slice holds only one file system.
No file system can span multiple slices.
After a file system is created, its size cannot be increased or decreased
without repartitioning the entire disk and restoring all data from a backup.
Slices cannot span multiple disks; however, multiple swap slices on
separate disks are allowed.

Partitioning Disks
A disk consists of a small disk label, also called a volume table of
contents (VTOC), with the remainder of the disk being divided in to slices.
Once the partition is defined, a file system can be created within the
partition.
The Disk Label, or VTOC
The disk label, or VTOC, contains various geometry data about the disk,
such as sectors per track, tracks per cylinder, available cylinders, and so
on. In addition the disk label contains the partition table.
The following steps show how you can examine information stored on a
disk’s label by using the prtvtoc command:
Become superuser.
Type prtvtoc /dev/rdsk/c#t#d#s# and press Enter.
Information for the disk and slice you specify is displayed. In the
following steps, information is displayed for all of disk :
1. Become superuser.
2. Type prtvtoc /dev/rdsk/c0t3d0s2 and press Enter.
The prtvtoc command shows the number of cylinders and heads, as well
as how the disk’s slices are arranged.
Formatting Disk :
Before you can create a file system on a disk, the disk must be formatted, and you must
divide it into slices by using the Solaris format utility.
Format Utility :
The main reason a system administrator uses the format utility is to divide a disk into disk
slices.
The process of creating slices is as follows:

1.Become superuser.
2. Type format.
The system responds with this:
AVAILABLE DISK SELECTIONS:
0. c0t0d0 at scsibus0 slave 24
sd0: <SUN0207 cyl 1254 alt 2 hd 9 sec 36>.
c0t3d0 at scsibus0 slave 0: test
sd3: <SUN0207 cyl 1254 alt 2 hd 9 sec 36>3.
3. Specify the disk (enter its number).
4. Type partition at the format prompt. The partition menu is displayed.
5. Type print to display the current partition map. The system responds
with this:
partition> print

6. After you partition the disk, you must label it by typing label at the
partition prompt:
partition> label

7. After labeling the disk, type quit to exit the partition menu:
partition> quit
 . The Solaris OS supports the following two disk labels:
The Sun Microsystems, Inc. (SMI) disk label:
− Is typically used in SPARC-based Solaris OSs.
− Is the SPARC volume table of contents (VTOC) label for disks
− and is often called the SMI VTOC disk label.
− Provides support for disks that are less than 1 terabyte.
− Occupies the first sector of a disk in SPARC systems
• Includes a partition table in which you can define up to eight (0
through 7) disk partitions (slices). A starting cylinder and an
ending cylinder define each slice. Whole-cylinder boundaries
determine the sizes of a slices. Slice 2 represents the entire disk.
Slice 2 maintains important data about the entire disk, such as
the size of the actual disk and the total number of cylinders
available for the storage of files and directories.
• Must be used for SPARC-based and Solaris x86/x64-based
systems boot disks.
. Solaris OS systems for the x86/x64 platforms maintain two
partition tables on each disk. The first sector of disks on
x86/x64 systems contains a fixed disk (fdisk) partition table.
The second sector of the Solaris fdisk partition on an x86/x64
system holds the partition table that defines slices within the
Solaris fdisk partition. The label that holds this table is known
as the x86/x64 VTOC.
• The fdisk partition table defines up to four fdisk partitions.
One of these fdisk partitions may be used for the Solaris OS.
Provision is made for up to sixteen slices within a Solaris fdisk
partition, but generally only ten of these are used (eight, plus
two used for platform-specific purposes).
. The extensible firmware interface (EFI) disk label:
 Provides support for disks that are larger than 1 terabyte on
systems that run a 64-bit Solaris kernel.
 Provides support for virtual disk volumes.
 Includes a partition table in which you can define up to ten (0
through 9) disk partitions (slices).
 Is compatible with the UFS. You can create a UFS that is larger
than 1 terabyte.
 Solaris OS systems do not currently boot from disks that use
EFI labels.
Use either SMI or EFI labels if a disk is not being used as a boot disk.
Use either the format or prtvtoc command to check whether a
disk has an SMI VTOC or EFI label.
 EFI Label and VTOC Label Comparison
The EFI disk label differs from the VTOC disk label as follows:
 The EFI label provides support for disks greater than 1
terabyte.
 The EFI label provides usable slices 0-6, where slice 2 is just
another slice.
 Partitions (or slices) cannot overlap with the primary or backup
label, nor with any other partition. The EFI label size is usually 34
sectors, so partitions start at sector 34. This feature means that no
partition can start at sector zero
 For SMI/VTOC labeled disks, you have 8 slices (0 to 7). For EFI
labeled disks, you have 10 slices (0 to 9).
 The default behavior of both EFI and SMI/VTOC labeled disks
are that slice 2 always occupies the entire disk space. For EFI
labeled disks, you can resize slice 2. You cannot do this with
SMI/VTOC labeled disks.
The prtconf Command
 Use the prtconf command to display the system’s configuration
information, including the total amount of memory installed and
the configuration of system peripherals, which is formatted as a
device tree.
 The prtconf command lists all possible instances of devices,
whether the device is attached or not attached to the system.
Use the prtconf and grep commands to list only the attached
devices on the system.
 #prtconf | grep –v not
The prtdiag command
 Use the prtdiag command to display system configuration and
diagnostic information. See the prtdiag(1M) man page for more
information.
 # prtdiag

The format Utility


 Use the format utility to display both logical and physical device
namesfor all currently available disks
 # format
Reconfiguring Devices
 You can cause a system to recognize a newly-added device in a
number of ways, including invoking a reconfiguration boot, or
running the
 # devfsadm
 To invoke cleanup routines that remove unreferenced symbolic
links and device files for devices no longer attached to the
system, perform the command:
 # devfsadm –C

 The reconfiguration boot process adds new device entries to a


system’s
/etc/path_to_inst file, and new symbolic links and device files to the
/dev and /devices directories.
# touch /reconfigure ; init 5 ; power on
.
For x86 partitions:
.
Reading a Disk VTOC Using the prtvtoc Command
# prtvtoc /dev/rdsk/c0t0d0s2

Replacing a Disk:
- Save VTOC information to a file:
- #prtvtoc /dev/rdsk/c0t0d0s2 > /var/tmp/c0t0d0s2.vtoc
- replace the disk with new disk
- copy the VTOC table to the new disk
- #fmthard –s /var/tmp/c0t0d0s2.vtoc /dev/rdsk/c0t0d1s2
.
Extended VTOC:
Prior to the Solaris 10 10/09 release, the Sun disk label limited the
size of the bootable disk to less than 1 Tbyte. Now, installing and
booting from disks in the 1 to 2 Tbytes range is supported with the
64-bit Solaris kernel.

The format -e utility can be used to label a disk of any size with a
VTOC label, but the addressable space is limited to 2 Tbytes.
Unit 3

Interface Configurations
Network Configuration

Important files responsible for the network

/etc/nodename  Hostname of the server eg: bomexport


/etc/hostname.xxn  Hostname of the service or server
/etc/inet/hosts  All IP address and hostname of other servers
/etc/hosts  Symbolic link to /etc/inet/hosts

Either edit these files or else give sys-unconfig or ifconfig in order


to configure the network
Network Configuration by Command Line

1. Enable / Disable the network card


#ifconfig hme0 plumb
#ifconfig hme0 unplumb
ifconfig -a command should show following type of output which means device is enabled
and is ready to configure ip address and netmask :
hme0: flags=842 mtu 1500
inet 0.0.0.0 netmask 0
ether 3:22:11:6d:2e:1f
2. Configuring ipaddress and netmask and making the interface status as up .
#ifconfig hme0 192.9.2.106 netmask 255.255.255.0 up
#ifconfig -a will now show the ip address , netmask and up status as follows :
hme0: flags=843 mtu 1500
inet 192.9.2.106 netmask ffffff00 broadcast 192.9.2.255
ether 3:22:11:6d:2e:1f
The file /etc/netmasks is used to define netmasks for ip addresses .
127.0.0.1, is the standard loop back route and 127.0.0.0 is the default loopback ipaddress
used by the kernel when no interface is configured this will be the only entry displayed by
the system on invoking ifconfig -a command..
3. Configuring Virtual interface
Virtual interface can be configured to enable hme0 reply to more then one
ip addresses. This is possible by using hme0 alias which can be configured
by ifconfig command only . The new alias device name now becomes
hme0:1 hme:2 etc.
#ifconfig hme0:1 172.40.30.4 netmask 255.255.0.0 up
ifconfig -a will show the original hme0 and alias interface :
hme0: flags=843 mtu 1500
inet 192.9.2.106 netmask ffffff00 broadcast 192.9.2.255
ether 3:22:11:6d:2e:1f
hme0:1: flags=842 mtu 1500
inet 172.40.30.4 netmask ffff0000 broadcast 172.40.255.255
Sending ICMP echo_request Packets:
To determine if you can contact another system over the network,
enter the ping command:
# ping solaris12
solaris12 is alive

For the ping command to succeed, the following conditions must


be satisfied on both systems:
− The interface must be plumbed.
− The interface must be configured.
− The interface must be up.
− The interface must be physically connected.
− The interface must have valid routes configured.
Capturing and Inspecting Network Packets:
Use the snoop utility to capture and inspect network packets to
determine what kind of data is transferred between systems.
On one session : #ping solaris12 (from solars36 )
On 2nd session : use snoop
#snoop solaris12 solaris36 -- ( to monitor traffic between sol12
and sol36)
# snoop –a solaris12 solaris36 --- enable audible clicks
Control-C to stop the snoop
The sys-unconfig Command
Use the /usr/sbin/sys-unconfig command to undo a system configuration. Use the
/usr/sbin/sys-unconfig command to restore a system configuration to an
unconfigured state. It will be ready to be reconfigured.
The sys-unconfig command does the following:
Saves the current /etc/inet/hosts file information in the /etc/inet/hosts.saved file.
If the current /etc/vfstab file contains Network File System (NFS) mount entries, it
saves the /etc/vfstab file to the /etc/vfstab.orig file.
Restores the default /etc/inet/hosts file.
Removes the default host name in the /etc/hostname.xxn files for all configured
interfaces.
Removes the default domain name in the /etc/defaultdomain file.
Restores the time zone to PST8PDT in the /etc/TIMEZONE file.
Resets naming services to local files
Removes the /etc/inet/netmasks file.
Removes the /etc/defaultrouter file.
Removes the password set for the root user in the /etc/shadow file.
Removes the /etc/.rootkey file for NIS+.
Executes all system configuration applications. These applications are defined by
prior executions of a sysidconfig -a command.
Removes the /etc/resolv.conf file for DNS clients.
Disables Lightweight Directory Access Protocol (LDAP) by removing:
− The /var/ldap/ldap_client_cache file
− The /var/ldap/ldap_client_file file
− The /var/ldap/ldap_client_cred file
− The /var/ldap/cachemgr.log file
Regenerates keys for the Secure Shell Daemon (sshd).

When the sys-unconfig command is finished, it performs a system shutdown. The


sys-unconfig command is a potentially dangerous utility and can only be run by the
root user.
When you restart the system, a configuration script prompts you to configure the
system information.
Unit 4

 Solaris File System Types


Solaris File System Types

Disk-Based File Systems

UFS : The UNIX file system, The UFS file system is the default disk-based file
system used in Solaris.
HSFS : The High Sierra and ISO 9660 file system. The HSFS file system is used on
CD-ROMs and is a read-only file system.
PCFS : The PC file system, which allows read/write access to data and programs on
DOS-formatted disks written for DOS-based personal computers.

Network-Based File Systems


NFS : Network-based file systems are file systems accessed over the network. Typically,
they reside on one system and are accessed by other systems across the network.
Virtual File Systems
Virtual file systems are virtual or memory-based file systems that create duplicate
paths to other disk-based file systems or provide access to special kernel information
and facilities.

SWAPFS— The Swap file system is used by kernel to manage swap space on disks.
Swap space is used as a virtual memory storage area when the system does not have enough
physical memory to handle current processes.

PROCFS— The Process File System resides in memory. It contains the list of Active
Processes, by process number in /proc directory. Information in this directory is used by
commands such as the ps command.

TMPFS— The temporary file system uses local memory for file system reads and writes.
Because TMPFS uses physical memory and not the disk, access to files in a TMPFS file
system is typically much faster than to files in a UFS file system. Files in the temporary file
system are not permanent; they are deleted when the file system is unmounted and when the
system is shut down or rebooted. TMPFS is the default filesystem type for the /tmp
directory in the Sun OS system software. When memory is insufficient to hold everything in
the temporary file system, theTMPFS file system uses swap space as a temporary backing
store as long as adequate swap space is present.
ufs – Unix FS hsfs – High Sierra FS pcfs – PC FS for DOS FAT32 FS
udfs – Universal Disk Format FS nfs - Network FS
Pseudo FS – Memory based FS tmpfs swapfs procfs
VTOC present in the first sector in the raw disk area.
VTOC - 512 sector
Boot Block - 1-15 sector
Super Block - 16-31
First Cylinder Group - 32
Creating File Systems
# newfs /dev/rdsk/c1d0s0 ---- Creating FS
# newfs –i 16384 /dev/rdsk/c1d0s0 ----- Creating FS with data
block size 16KB
# mount /dev/dsk/c1d0s0 /p1 ----Mounting partition in /p1
directory
# fstyp –v /dev/rdsk/c1d0s0 | head
# fstyp –v /dev/rdsk/c1d0s0 | grep minfree
minfree 6% ---- To know the reserved disk space
# tunefs –m 2 /dev/rdsk/c1d0s0 --- This will reduce the reserved
space to 2%
# umount /p1 ---- To umount a partition.
 Never run the fsck command on a mounted FS. The /, /usr and
/var FS should have the fsck command run on them on single user
mode
# fsck /dev/rdsk/c0td0s7 ----- To check the FS in interactive mode
Checking File Systems – using fsck
A file system can become damaged if it is corrupted from a power failure, a
software error in the kernel, a hardware failure, or an improper shutdown of the
system. The file system check program, fsck, checks the data consistency of a file
system and attempts to correct or repair any inconsistencies or damage found.
The fsck command checks and repairs any problems encountered in file systems
before they are mounted.
The fsck command makes several passes through a file system. During each pass,
the fsck command checks for several types of file system inconsistencies.
− Superblock Consistency
− Cylinder Group block Consistency
− Inode Consistency
− Data Block Consistency
The lost+found Directory --- the fsck command puts files and dirs that are allocated but
unrefrenced in the lost+found dir located in that file system. --- The inode number of
each file is assigned as the file name ---- if the lost+found dir does not exist, the fsck
command creates it.
fsck –
Non-Interactive Mode
During a normal system boot, the fsck command operates in noninteractive mode, which is often
referred to as preen, or silent mode.
In this mode, the fsck command addresses only minor inconsistency problems that can be
corrected. If a more serious inconsistency is found and a decision has to be made, the fsck
program terminates and requests the root password to enter single-user mode. Execute the fsck
command in interactive mode to continue.

Interactive Mode
In interactive mode, the fsck command lists each problem it encounters, followed by
a suggested corrective action in the form of a question that requires a yes or no
response.
Some of the common file system errors that require interactive intervention are:
− Allocated unreferenced file
− Inconsistent link count
− Free block count corruption
− Superblock corruption
# newfs –N /dev/rdsk/c0t0d0s0 --- to list all the alternatve backup superblocks in the
file system

If you use the newfs command with the -T option, the structure
created allows the file system to grow to a multi-terabyte file
system. You can view the file system parameters using this option
without actually creating the file system.

# newfs –N –T /dev/rdsk/c0t0d0s0

to monitor file system use on a regular basis.


− df – Displays the number of free disk blocks
− du – Summarizes disk use
− quot – Summarizes file system ownership ( how much is used by each user)(#quot –af )
Unit 5

ZFS ( Z file system )

ZFS uses the following data structures:


Dnode data structure: this data structure contains pointers to data
blocks.
Znode data structure: this data structure contains information about
the file, including its owner, permissions, and size.

Dnode and znode data structures are called metadata and are stored
dynamically by the ZFS. ZFS implements the ZFS POSIX layer (ZPL)
which is a primary interface for ZFS. The ZPL allows commands you use with
the UFS to work with ZFS. ZFS emulates the UFS inode number.

56
.

#### Zettabyte File system (ZFS) ####

Features:
1. 256 quadrillion( 1 billion ) zettabytes (Terabytes - Petabytes - Exabytes -
Zettabytes(1024 Exabytes))
2. supports RAID-0 & RAID-Z(RAID-5 with enhancements) ( 2-required
virtual devices )
3. Snapshots - read-only copies of file systems or volumes
4. Creates volumes
5. Uses Storage pools to manage storage - aggregates virtual devices
6. File systems attached to pools grow dynamically as storage is added
7. File systems may span multiple physical disks
8. ZFS is transactional -- means copy on write ( COW )
9. ZFS Pools & file systems are auto-mounted. No need to maintain
/etc/vfstab ( pool names should be unique )

57
ZFS commands
Get familiar with command structure and options
$ man zpool
$ man zfs

# cd /
# mkfile 100m disk1 disk2 disk3 disk5
# mkfile 50m disk4
# ls -l disk*
-rw------T 1 root root 104857600 Sep 11 12:15 disk1
-rw------T 1 root root 104857600 Sep 11 12:15 disk2
-rw------T 1 root root 104857600 Sep 11 12:15 disk3
-rw------T 1 root root 52428800 Sep 11 12:15 disk4
-rw------T 1 root root 104857600 Sep 11 12:15 disk5

Create a storage pool and check the size and usage.


# zpool create myzfs /disk1 /disk2
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
58
myzfs 191M 94K 191M 0% ONLINE
.
# zpool status -v
pool: myzfs
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
myzfs ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0
errors: No known data errors

Destroy a zfs storage pool


# zpool destroy myzfs
# zpool list
no pools available

Attempt to create a zfs pool with different size vdevs fails. Using -f options forces it to
occur but only uses space allowed by smallest device.
# zpool create myzfs mirror /disk1 /disk4
invalid vdev specification
use '-f' to override the following errors:
mirror contains devices of different sizes
59
. # zpool create myzfs mirror /disk1 /disk2 /disk3
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
myzfs 95.5M 112K 95.4M 0% ONLINE -

# zpool status -v
pool: myzfs
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0
/disk3 ONLINE 0 0 0

errors: No known data errors


60
.
Detach a device from a mirrored pool.
# zpool detach myzfs /disk3
# zpool status -v
pool: myzfs
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM


myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0

errors: No known data errors

Attach device to pool. This creates a two-way mirror is the pool is not already a mirror, else it adds another mirror,
in this case making it a 3 way mirror
# zpool attach myzfs /disk1 /disk3
# zpool status -v
pool: myzfs
state: ONLINE
scrub: resilver completed with 0 errors
config:

NAME STATE READ WRITE CKSUM


myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0
/disk3 ONLINE 0 0 0

errors: No known data errors

61
.

Attempt to remove a device from a pool. In this case it's a mirror, so we must use "zpool detach".
# zpool remove myzfs /disk3
cannot remove /disk3: only inactive hot spares can be removed
# zpool detach myzfs /disk3
# zpool add myzfs spare /disk3
# zpool status -v

Remove a hot spare from a pool.


# zpool remove myzfs /disk3
# zpool status -v
pool: myzfs
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM


myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0

errors: No known data errors


62
.

Take the specified device offline. No attempt to read or write to the


device will take place until it's brought back online. Use the -t
option to temporarily offline a device. A reboot will bring the device
back online.
# zpool offline myzfs /disk1
# zpool status -v
pool: myzfs
state: DEGRADED
status: One or more devices has been taken offline by the
administrator.

# zpool online myzfs /disk1


# zpool status -v
pool: myzfs
state: ONLINE
scrub: resilver completed with 0 errors
63
.

Replace a disk in a pool with another disk, for example when a disk
fails
# zpool replace myzfs /disk1 /disk3
# zpool status -v
pool: myzfs
state: ONLINE
scrub: resilver completed with 0 errors

Perform a scrub of the storage pool to verify that it checksums


correctly. On mirror or raidz pools, ZFS will automatically repair any
damage. WARNING: scrubbing is I/O intensive.

# zpool scrub myzfs

64
.

Export a pool from the system for importing on another system.

# zpool export myzfs


# zpool list
no pools available

Import a previously exported storage pool. If -d is not specified, this


command searches /dev/dsk. As we're using files in this example,
we need to specify the directory of the files used by the storage
pool.

# zpool import -d / myzfs


# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
myzfs 95.5M 114K 95.4M 0% ONLINE -
65
.

Create a file system and check it with standard df -h command. File


systems are automatically mounted by default under the /zfs
location.

# zfs create myzfs/colin


# df -h
Filesystem kbytes used avail capacity Mounted on
...
myzfs/colin 64M 18K 63M 1% /myzfs/colin

List current zfs file systems.


# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 139K 63.4M 19K /myzfs
myzfs/colin 18K 63.4M 18K /myzfs/colin
66
.

Create a second file system. Note that both file system show 159M available because no quotas
are set. Each "could" grow to fill the pool.

# zfs create myzfs/colin2


# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 172K 159M 21K /myzfs
myzfs/colin 18K 159M 18K /myzfs/colin
myzfs/colin2 18K 159M 18K /myzfs/colin2

Reserve a specified amount of space for a file system ensuring that other users don't take up all
the space
# zfs set reservation=20m myzfs/colin
# zfs list -o reservation
RESERV
none
20M
none .

Set and view quotas


# zfs set quota=20m myzfs/colin2
# zfs list -o quota myzfs/colin myzfs/colin2
QUOTA
none
20M
67
.

Turn on and verify compression


# zfs set compression=on myzfs/colin2
# zfs list -o compression
COMPRESS
off
off
on

Share a filesystem over NFS. There is no need to modify the


/etc/dfs/dfstab as the filesystem will be share automatically on
boot.
# zfs set sharenfs=on myzfs/colin2
# zfs get sharenfs myzfs/colin2
NAME PROPERTY VALUE SOURCE
myzfs/colin2 sharenfs on local

68
.

Create a snapshot called test.


# zfs snapshot myzfs/colin@test
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 20.2M 139M 21K /myzfs
myzfs/colin 18K 159M 18K /myzfs/colin
myzfs/colin@test 0 - 18K -
myzfs/colin2 18K 20.0M 18K /myzfs/colin2
# zfs rollback myzfs/colin@test ---------------- Rollback to a snapshot.

A snapshot is not directly addressable. A clone must be made. The target dataset can be located
anywhere in the ZFS hierarchy, and will be created as the same type as the original.
# zfs clone myzfs/colin@test myzfs/colin3
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 20.2M 139M 21K /myzfs
myzfs/colin 18K 159M 18K /myzfs/colin
myzfs/colin@test 0 - 18K -
myzfs/colin2 18K 20.0M 18K /myzfs/colin2
myzfs/colin3 0 139M 18K /myzfs/colin3

Destroy a filesystem
# zfs destroy myzfs/colin2
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 20.1M 139M 22K /myzfs
myzfs/colin 18K 159M 18K /myzfs/colin
myzfs/colin@test 0 - 18K -
myzfs/colin3 0 139M 18K /myzfs/colin3 69
.

Attempt to destroy a filesystem that had a child. In this case, the snapshot filesystem. We must
either remove the snapshot, or make a clone and promote the clone.
# zfs destroy myzfs/colin
cannot destroy 'myzfs/colin': filesystem has children
use '-r' to destroy the following datasets:
myzfs/colin@test

Promte a clone filesystem to no longer be a dependent on it's "origin" snapshot. This now
associates makes the snapshot a child of the cloned filesystem. We can then delete the original
filesystem.
# zfs promote myzfs/colin3
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 20.1M 139M 21K /myzfs
myzfs/colin 0 159M 18K /myzfs/colin
myzfs/colin3 18K 139M 18K /myzfs/colin3
myzfs/colin3@test 0 - 18K -

# zfs destroy myzfs/colin


# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 147K 159M 21K /myzfs
myzfs/colin3 18K 159M 18K /myzfs/colin3
myzfs/colin3@test 0 - 18K -

70
.

Attempt to destroy a filesystem that had a child. In this case, the snapshot filesystem. We must
either remove the snapshot, or make a clone and promote the clone.
# zfs destroy myzfs/colin
cannot destroy 'myzfs/colin': filesystem has children
use '-r' to destroy the following datasets:
myzfs/colin@test

Promte a clone filesystem to no longer be a dependent on it's "origin" snapshot. This now
associates makes the snapshot a child of the cloned filesystem. We can then delete the original
filesystem.
# zfs promote myzfs/colin3
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 20.1M 139M 21K /myzfs
myzfs/colin 0 159M 18K /myzfs/colin
myzfs/colin3 18K 139M 18K /myzfs/colin3
myzfs/colin3@test 0 - 18K -

# zfs destroy myzfs/colin


# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 147K 159M 21K /myzfs
myzfs/colin3 18K 159M 18K /myzfs/colin3
myzfs/colin3@test 0 - 18K -

71
.

Rename a filesystem, and separately rename the snapshot.


# zfs rename myzfs/colin3 myzfs/bob
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 153K 159M 21K /myzfs
myzfs/bob 18K 159M 18K /myzfs/bob
myzfs/bob@test 0 - 18K -

# zfs rename myzfs/bob@test myzfs/bob@newtest


# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 146K 159M 20K /myzfs
myzfs/bob 18K 159M 18K /myzfs/bob
myzfs/bob@newtest 0 - 18K -

Display properties for the given datasets.


# zfs get all
NAME PROPERTY VALUE SOURCE
myzfs type filesystem -
myzfs creation Tue Sep 11 14:21 2007 -
myzfs used 146K -
myzfs available 159M -
myzfs referenced 20K -
[...]

Can't destroy a pool with active filesystems


# zpool destroy myzfs
cannot destroy 'myzfs': pool is not empty
use '-f' to force destruction anyway .

Unmount a ZFS file system


# zfs unmount myzfs/bob
# df -h
myzfs 159M 20K 159M 1% /myzfs
72
.

Mount a ZFS filesystem. This is usually automatically done on boot.

# zfs mount myzfs/bob


# df -h
myzfs 159M 20K 159M 1% /myzfs
myzfs/bob 159M 18K 159M 1% /myzfs/bob

Create a stream representation of the snapshot and redirect it to zfs receive. In this example I've redirected to the localhost for illustration
purposes. This can be used to backup to a remote host, or even to a local file.
# zfs send myzfs/bob@newtest | ssh localhost zfs receive myzfs/backup
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 172K 159M 20K /myzfs
myzfs/backup 18K 159M 18K /myzfs/backup
myzfs/backup@newtest 0 - 18K -
myzfs/bob 18K 159M 18K /myzfs/bob
myzfs/bob@newtest 0 - 18K -

Display the command history of all storage pools. This can be limited to a single pool by specifying its name on the command line. The
history is only stored for existing pools. Once you've destroyed the pool, you'll no longer have access to it's history.

# zpool history
History for 'myzfs':
2012-09-11.15:35:50 zpool create myzfs mirror /disk1 /disk2 /disk3
2012-09-11.15:36:00 zpool detach myzfs /disk3
2012-09-11.15:36:10 zpool attach myzfs /disk1 /disk3
2012-09-11.15:36:53 zpool detach myzfs /disk3
2012-09-11.15:36:59 zpool add myzfs spare /disk3

Use the -f option to destroy a pool with files systems created.


# zpool destroy -f myzfs
# zpool status -v
no pools available 73
Unit 6

Perform Mounts and Unmounts

74
To Create a File System
Using Format we can create a partition on the specific disks identified.
The default File System Includes

0 root
1 Swap
2 Entire Disk
3
4
5 /usr
6 /opt
7 /home

After Partition we can construct a file System using newfs or mkfs command
which will create UFS File System on a specific partition.
E.g. newfs /dev/rdsk/c0t0d0s7
To check the File System consistency use fsck
E.g : fsck –y /dev/rdsk/c0t0d0s7
Mounting The File System
mount Mounts specified file systems and remote resources.
mountall Mounts all file systems specified in a file system table (/etc/vfstab).
umount Unmounts specified file systems and remote resources.
umountall Unmounts all file systems specified in a file system table.

/etc/vfstab contain the information of File System to be mounted at boot


/etc/mnttab contain the information of File System mounted or not

Eg : mount /dev/dsk/c0t0d0s7 /data

fstyp /dev/rdsk/c0t0d0s6
Ufs

/usr/sbin/fuser [options ]<file>| <filesystem>


Unit 7 & 8

Packages and Patches

77
Software Package Commands

 All bundled and unbundled software is distributed as packages in the Solaris 2.x
environment. During installation selected software packages are added
automatically from the CDROM Devices

• Packages contain:

– Files describing the package


– Files describing the relation to the target system eg. Disk space required
– The actual files to be installed
– Scripts to be run before and after the installation ( or during removal)
– Packages can be added using pkgadd command.
• The pkginfo Command

− pkginfo is used to display software information.

− # pkginfo | more “ Displays the current packages installed”

− # pkginfo -d /cdrom/cdrom0/Solaris2.8 | more “ Displays the package listing from


the cdrom”

− # pkginfo -d /cdrom/cdrom0/ SUNWaudio


“Displays detailed info about a package including the packaging size in blocks”.
− Use # df -k command prior to installation of a package to check disk space”

The pkgadd Command

 The pkgadd command is used to add software packages to the system.


 Command syntax is pkgadd -d <package>
# pkgadd –d /cdrom/cdrom0 SUNWaudio
 The pkgrm command can be used to remove any packages
# pkgrm SUNWaudio
/var/sadm/install/contents file has all the details about installed packages.
 # grep showrev /var/sadm/install/contents Will show whether showrev
package is installed or not
/var/sadm/pkg directory maintains a record of all installed packages
 # pkginfo | more Will show all installed packages
 # pkginfo –l SUNWman Shows information about SUNWman package
 # pkginfo –d /cdrom/cdrom0/s0/Solaris_10/Product | more --- To view
info about pkg in CD
 # pkgadd –d /cdrom/cdrom0/Solaris_10/Product SUNWxip
 # pkgchk SUNWman ---If the pkgchk command doesn’t display a
message, it indicates the package was installed successfully
 # pkgchk –v SUNWzip ---To list the files contained in a software package
 # pkgchk –p /etc/shadow ---To determine if the contents and attributes
of a file have changed since it was installed with its software package
 # pkgchk –l SUNWman --- Lists info about selected files that make up a
package
 # pkgrm SUNWzip ---- Will remove the SUNWzip package
Patches Management

 Patches are identified with an eight-digit number.


 The first six digits identify the base patch, and the last two digits identify the
revision. For example, patch number 11906-01

 # unzip 110906-01.zip
 # patchadd 110906-01

 Multiple patches canbe installed by


 # patchadd –M /var/spool/patch 108529-05 108653-23 10876-07
 OR
 # patchadd –M /var/spool/patch /var/spool/patch/patchlist

 NOTE: If we specify the –d command-line argument on the patchadd command,


the files are not backed up, and the patch cannot be removed.
 Patchadd command will Fail for Following Reasons
 A package being patched is not installed.
 The patch requires another patch that is not installed.
 The patch is incompatible with another patch already installed.
 The current version or a higher version of the patch is already installed.
 The architecture of the patch and the system do not match.

 Which Patches Are Installed


Two commands can be used to generate a list of installed patches for a
standalone system:
 showrev –p
 patchadd -p
When you remove a patch, the patchrm command restores all files
that were modified or replaced by that patch, unless
 The patch was installed with the patchadd –d option (Which
instructs the patchadd command not to save copies of files being
updated or replaced)
 The patch is required by the another patch
 The patch has been obsoleted by a later patch
# patchrm 105050-01 ----- Will remove patch

Installing Patch Cluster


 # cd 10_Recommended
 # ./install_cluster
 /var/sadm/install_data/Solaris_10_Recommended_log
Unit 9 , 10 , 11

Boot Prom Commands


GRUB ( Grand Unified Bootloader )
Boot and Shutdown

84
Init Levels / Run Levels

init (short for initialization) is a program for Unix-based computer operating systems that
parent of all other processes. It runs as a daemon and typically has PID 1. The boot loader
starts the kernel and the kernel starts init. If one were to delete init without a replacement, the
system would encounter a kernel panic on the next reboot.

Init refers the /etc/inittab file


Run Levels

The following lists the 6 Run Levels in Sun Solaris. These are often different mostly from
the linux run levels

0 - Open Boot prompt (OBP) also called OK prompt. The system is taken down to PROM
monitor or Security monitor state. It is safe to power off the hardware.

1,s,S - Single-User or Administrative mode where user logins are disabled. Also minimal
Kernel functions and minimal required file systems are mounted (/ and /usr).

2 - Multi-User mode without Networking (No NFS)

3 - Multi-User mode with Networking (Default)

4 - Not in use

5 - Shut-down and power OFF. Power OFF supported on Sun 4m & Sun 4u architecture.
More like a boot -a where the system is taken down to run level 0 and then an interactive
boot.

6 - Reboot. takes the system down to run level 0 and then back to the default run level (3)
Unit 12

SMF – Service Management Facility

87
Unit 13

USER Administration

88
User & Group Management

Adding User Accounts from the Command Line


You can add new user accounts on the local system by using the useradd
command. This command adds an entry for the new user into the /etc/passwd and
/etc/shadow files,

The syntax for the useradd command is as follows:


useradd [-c comment] [-d dir] [-e expire] [-f inactive] [-g group] \ [ -G group [ ,
group...]] [ -m [-k skel_dir]] [-u uid [-o]] \ [-s shell] [-A authorization [,authorization...]]
[-P profile [,profile...]] \[-R role [,role...]] [-p projname] [-K key=value] <loginname>

The following example creates a new login account for don:

useradd -u 3000 -g other -d /export/home/don -m -s /bin/sh -c “DON, ext. 1234” don


The next step would be to set a password for the account using
the passwd command as follows:

# passwd <username>
passwd: Changing password for <username>
New Password: <ENTER PASSWORD>
Re-enter new Password: <RE_ENTER PASSWD>
passwd: password successfully changed for <username>

Options that can be used with the passwd command are


Option Description
-s <name> Shows password attributes for a particular user. When used with the -a option,
attributes for all user accounts are displayed.
-d <name> Deletes password for name and unlocks the account. The login name is not prompted
for a password.
-e <name> Changes the login shell, in the /etc/passwd file, for a user.
-f <name> Forces the user to change passwords at the next login by expiring the
password.
-h <name> Changes the home directory, in the /etc/passwd file, for a user.
-l <name> Lock a user’s account. Use the -d or -u option to unlock the account.
-N <name> Makes the password entry for <name> a value that cannot be used for
login but does
not lock the account.
-u <name> Unlocks a locked account.

To force a user to change his or her password at the next login, type
# passwd -f <username>
passwd: password information changed for <username>
Modifying User Accounts from the Command Line
You use the usermod command to modify existing user accounts from the command line. You
can use usermod to modify most of the options that were used when the account was originally
created.
The following is the syntax for the usermod command:
usermod [ -u uid [-o]] [-g group] [ -G group [ , group...]] [ -d dir [-m]] [-s shell] [-c comment] [-l
new_name] [-f inactive] [-e expire] [-A authorization2 [, authorization]] [-P profile [, profile]] [-R
role [, role]] [-K key=value] <loginname>

 usermod Command Options


-l <new-login-name> Changes a user’s login name on a specified account
-m Moves the user’s home directory to the new location specified with the -d option
 The following example changes the login name for user don to nod:
usermod -d /export/home/nod -m -s /bin/ksh -l nod don
This example also changes the home directory to /export/home/don and default shell
to /bin/ksh.
 To set a user’s account expiration date, you enter this:
usermod -e 10/15/2006 nod
Deleting User Accounts from the Command Line
You use the userdel command to delete a user’s login account from the system. You can specify
options to save or remove the user’s home directory. The syntax for the userdel command
is as follows:

userdel [-r] <login-name>

-r removes the user’s home directory from the local file system. If this option is not specified,
only the login is removed; the home directory remains intact.

Make sure you know where the user’s home directory is located before removing it. Some users
have / as their home directory, and removing their home directory would remove important
system files.
CAUTION
The following example removes the login account for nod but does not remove the home
directory:
userdel nod
Adding Group Accounts from the Command Line

You use the groupadd command to add new group accounts on the local system. This command
adds an entry to the /etc/group file. The syntax for the groupadd command is as

follows:

groupadd [-g <gid>] -o <group-name>

Option Description
-g <gid> Assigns the GID <gid> for the new group.
-o Allows the GID to be duplicated. In other words, more than one group with
group-name can share the same GID.

The following example adds to the system a new group named acct with a GID of 1000:
groupadd -g 1000 acct
Modifying Group Accounts from the Command Line

You use the groupmod command to modify the definitions of a specified group. The syntax for
the groupmod command is as follows:

groupmod [-g <gid>] -o [-n <name>] <group-name>

groupmod Command Options

-g <gid> Assigns the new GID <gid> for the group.


-o Allows the GID to be duplicated. In other words, more than one group with group-name can
share the same GID.
-n <name> Specifies a new name for the group.

The following example changes the engrg group GID from 200 to 2000:
groupmod -g 2000 engrg
Deleting Group Accounts from the Command Line

You use the groupdel command to delete a group account from the local system. The syntax
for the groupdel command is as follows:
groupdel <group-name>

Assigning a GID

If the -g option is not used to specify a GID, the GID defaults to the next available

number above the highest number currently assigned. For example, if group IDs 100, 110, and 200
are already assigned to group names, the next GID that is automatically assigned is 201.
/etc/skel --- Template files get copied once user id is created.
 By default /etc/skel/.profile file don’t have any content.

Profile Order
/etc/motd file ---- Message of the day
/etc/profile
/$HOME/.profile
Unit 14

Controlling System Processes

Jobs scheduling using cron.


Controlling System Processes

# prstat Displays info about active process (5 sec refresh interval)


Options for prstat command
-c . Continuously prints new reports below previous reports
-n nproc Restricts the number of output lines
-p pidlist Reports only on process that have PID
-t Reports total usage summary for each users

# kill –signal PID


# pkill –signal process
# pgrep –l mail To know PID
# pkill sendmail To kill sendmail process
# ps –e | grep mail To know PID
# kill 314 To kill mail process
# kill signal PID PID PID
Controlling System Processes

# pkill signal process process


Default signal is 15
1 SIGHUP Hnagup Stop & start with the same pid
2 SIGNT Interrupt
9 SIGKILL Kill Kill forcibly
15 SIGTERM Terminate Kill properly
# pkill -1 (or) –HUP sendmail
# kill –SIGTERM (or) -15 <pid>
# kill –SIGKILL (or) -9 <pid>
# kill –SIGHUP (or) -1 (or) –HUP <pid>
# renice –n -10 195 ---- To change priority
-20 Highest priority for a process
0 Neutral priority
+20 Least priority
# psrinfo shows how long the system is running
.

# ps –e Shows all system process


# ps –ef Default process details with command or service name
# ps –ef | grep cron To view specific process
Jobs scheduling using crontab

Setting up cron jobs in Unix and Solaris


cron is a unix, solaris utility that allows tasks to be automatically run in the background at
regular intervals by the cron daemon. These tasks are often termed as cron jobs in unix ,
solaris. Crontab (CRON TABle) is a file which contains the schedule of cron entries to be
run and at specified times.
This document covers following aspects of Unix cron jobs
1. Crontab Restrictions
2. Crontab Commands
3. Crontab file – syntax
4. Crontab Example
5. Generate log file for crontab activity
1. Crontab Restrictions

You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow.
If that file does not exist, you can use
crontab if your name does not appear in the file /usr/lib/cron/cron.deny.
If only cron.deny exists and is empty, all users can use crontab. If neither file
exists, only the root user can use crontab. The allow/deny files consist of one user
name per line.

2. Crontab Commands


export EDITOR=vi ;to specify a editor to open crontab file.
crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file. (This option is
only available on a few systems.)
3. Crontab file

Crontab syntax :
A crontab file has five fields for specifying day , date and time followed by the command to
be run at that interval.
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)

4. Crontab Example


A line in crontab file like below removes the tmp files from /home/someuser/tmp each day at
6:30 PM.
30 18 * * * rm /home/someuser/tmp/*
5. Generate log file

To collect the cron execution execution log in a file :


30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log
# at 9:00 pm
at> find /export/home/user2 –name core rm {} \;
at> Ctrl+D
# at now
at> banner “welcome” > /dev/pts/4
at> ctrl+d
#
# at –l 1016078400.a Reports jobs schedule
# atq Shows the at jobs queue
# ls –l /var/spool/cron/atjobs Directory contains the at jobs
# at –r 1016078400.a To remove the at job
/etc/cron.d/at.deny We can add username to this file to deny access to at
jobs
/etc/cron.d/at.allow We can add username to this file to allow access to at
jobs
If neither file at.allow & at.deny file does not exist only the root user can use
the at command.
Unit 15

Solaris 10 Installation
Solaris 10 Installation

Minimum System Requirements

The computer must meet the following requirements before you can install Solaris
10 using the interactive installation method:

The system must have a minimum of 128MB of RAM (256MB is recommended).


Sufficient memory requirements are determined by several factors, including the
number of active users and applications you plan to run.

The media is distributed on CD-ROM and DVD only, so a CD-ROM or DVD-ROM


drive is required either locally or on the network. You can use all of the Solaris
installation methods to install the system from a networked CD-ROM or DVD-ROM.

A minimum of 6.8 or grater GB of disk space is required. Processor speed – 200


MHz or greater. Also, remember to add disk space to support your environment's
swap space requirements.
When upgrading the operating system, you must have an empty
512MB slice on the disk. The swap slice is preferred, but you can
use any slice that will not be used in the upgrade such as root (/),
/usr, /var, and /opt.

The system must be a SPARC-based or supported x86/x64-based


system.
Solaris 10 Installation Methods

Methods of Installing the Solaris 10 Software

You can use one of seven methods to install the Solaris software:
Solaris Interactive installation using the graphical user interface
(GUI)
Solaris Interactive installation using the command line interface
(CLI)
Solaris JumpStart
Solaris Custom JumpStart
Solaris Flash Archives
Solaris WAN Boot Installation
Solaris Upgrade Method
Solaris 10 Installation

Before You Begin

Perform the following tasks before you begin your installation.


Ensure that you have the following media.
− For a DVD installation, the Solaris 10 Operating System for SPARC Platforms
DVD

Verify that your system meets the minimum requirements.


Your system should meet the following requirements.
− Memory – 128 Mbytes or greater
− Disk space – 6.8 Gbytes or greater
− Processor speed – 200 MHz or greater
Gather the information you need to install the Solaris OS.
− For a nonnetworked system, gather the following information.

• Host name of the system that you are installing

• Language and locales that you intend to use on the system


− For a networked system, gather the following information.

• Host name of the system that you are installing

• Language and locales that you intend to use on the system

• Host IP address

• Subnet mask

• Type of name service (for example, DNS, NIS, or NIS+)

• Domain name

• Host name of the name server

• Host IP address of the name server

• Root password
Solaris 10 Installation :

1) Solaris 10 SPARC Version:


2) Solaris 10 x86 Version :

Software Groups :
1.reduced network support software group (SUNWCrnet)
2.core system support software group (SUNWCreq)
3.end user system support software group (SUNWCuser)
4.developer software group (SUNWCprog)
5.entire system support software group (SUNWCall)
6.entire + OEM software group (SUNWCXall)

cat /var/sadm/system/admin/CLUSTER
Unit 16

Backing Up a Mounted File System With a


UFS Snapshot

 Create a UFS snapshot


 Backup the snapshot file
The UFS Copy on Write Snapshots feature ----
provides to use a point-in-time copy of a ufs file system, called a
snapshot, ----- to create an online backup.
You can create the backup while the file system is mounted and the
system is in multiuser mode.

the fssnap Command::


to create, query, or delete temporary readonly snapshots of ufs file
systems.

# fssnap -F ufs -o bs=backing_store_path /file-system


# fssnap -F ufs -o bs=/var/tmp /export/home /dev/fssnap/0

-d --- deletes the snapshot associated with the given file system
-i> displays the state of snapshot
The snapshot subsystem saves file system data in a file called a
backing-store file before the data is overwritten. Some important
aspects of a backing-store file are:
A backing-store file is a bit-mapped file that takes up disk space
until you delete the UFS snapshot.
The size of the backing-store file varies with the amount of activity on the file
system being captured.
The destination path that you specify on the fssnap command line
must have enough free space to hold the backing-store file.
The location of the backing-store file must be different from that of the file system
you want to capture in a UFS snapshot.
A backing-store file can reside on different types of file systems,
including another ufs file system or a mounted nfs file system.

The fssnap command creates the backing-store file and two read-only virtual
devices. The block virtual device, /dev/fssnap/0, can be mounted as a read-only file
system.
The raw virtual device, /dev/rfssnap/0, can be used for raw read-only access to a
file system.
These virtual devices can be backed up with any of the existing Solaris OS backup
commands. The backup created from a virtual device is a backup of the original file
system when the UFS snapshot was taken.
note – If the backing-store file runs out of disk space, the system
automatically deletes the UFS snapshot, which causes the backup
to fail.
The active ufs file system is not affected. Check the
/var/adm/messages file for possible UFS snapshot errors.
Note – You can force an unmount of an active ufs file system, for
which a snapshot exists (for example, with the umount -f
command). This action deletes the appropriate snapshot
automatically.

The following example creates a snapshot of the /export/home file


system, and limits the backing-store file to 500 Mbytes.
# fssnap -F ufs -o bs=/var/tmp,maxsize=500m /export/home /dev/fssnap/0

# fssnap –i --- to display list of current snapshots


# fssnap –i /export/home --- to check details of snapshot
Backing up the UFS Snapshot File

Use the tar command or the ufsdump command to back up a UFS


snapshot.
Using the tar Command to Back Up a Snapshot File
If you use the tar command to back up the UFS snapshot, mount the
snapshot before backing it up. The following procedure demonstrates
how to do this type of mount.

1. Create the mount point for the block virtual device.


# mkdir -p /backups/home.bkup
2. Mount the block virtual device to the mount point.
# mount -F ufs -o ro /dev/fssnap/0 /backups/home.bkup
3. Change directory to the mount point.
# cd /backups/home.bkup
4. Use the tar command to write the data to tape.
# tar cvf /dev/rmt/0 .
Using the ufsdump Command
If you use the ufsdump command to back up a UFS snapshot, you
can specify the raw virtual device during the backup.
# ufsdump 0uf /dev/rmt/0 /dev/rfssnap/0
Verify that the UFS snapshot is backed up.
# ufsrestore tf /dev/rmt/0
Performing an Incremental Backup Using a UFS Snapshot
Incremental backups of snapshots contain files that were modified
since the last UFS snapshot. Use the ufsdump command with the N
option to create an incremental UFS snapshot, which writes the
name of the device being backed up, rather than the name of the
snapshot device to the /etc/dumpdates file.

Note – Use the N argument when backing up a snapshot. This


argument ensures proper updates to the /etc/dumpdates file.

# ufsdump 1ufN /dev/rmt/0 /dev/rdsk/c1t0d0s0


/dev/rfssnap/0
Next you would verify that the UFS snapshot is backed up to tape.
# ufsrestore tf /dev/rmt/0
Incremental backups of snapshots
# fssnap –o bs=/var/tmp /extra
#fssnap –i
#fssnap –i /extra
#mkdir /extrasnap
#mount –o ro /dev/fssnap/0 /extrasnap
#df –k | grep extra
#vi /extra/file1 ---- create a new file or edit the existing file
#df –k | grep extra -- it shows change in filesystem size and not the snapshot
/dev/dsk/c1t0d0s0 1294023 20 1242243 1% /extra
/dev/fssnap/0 1294023 9 1242254 1% /extrasnap
# ufsdump 0ufN /dev/rmt/0 /dev/rdsk/c1t0d0s0 /dev/rfssnap/0
# ufsrestore tf /dev/rmt/0
Unmount the back up device and remove the snapshot.
# umount /extrasnap
# fssnap -d /extra
# rm /var/tmp/snapshot0
Make some changes to the /extra file system, such as copying some files, and then
re-create the snapshot.
# cp file1 file5
# cp file1 file6
# fssnap -o bs=/var/tmp /extra
/dev/fssnap/0
#
Re-mount the snapshot device, and compare the size of the file
system and the snapshot device.
# mount -o ro /dev/fssnap/0 /extrasnap
# df -k |grep extra
/dev/dsk/c1t0d0s0 1294023 46 1242217 1% /extra
/dev/fssnap/0 1294023 46 1242217 1% /extrasnap

Perform an incremental backup with the N option of the ufsdump


command.
# ufsdump 1ufN /dev/rmt/0 /dev/rdsk/c1t0d0s0 /dev/rfssnap/0
Verify the backup.
# ufsrestore tf /dev/rmt/0
2.
7 ./file5
8 ./file6
The backup of the snapshot contains only the files that were added since the previous Level 0 backup.
Deleting a UFS Snapshot
First, unmount the snapshot device, and then delete the
snapshot. Finally, remove the backing-store file.
# umount /dev/fssnap/0
# fssnap -d /export/home
# rm /backing_store_file
Backing Up File System to Extra Disk Drive

Backup the /dev/dsk/c0t0d0s7 -- /export/home to the new disk


On the new disk create a mount point /extra
#newfs /dev/rdsk/c0t1d0s0
#fsck /dev/rdsk/c0t1d0s0
#mkdir /extra
#mount /dev/dsk/c0t1d0s0 /extra

#umount /export/home
#ufsdump 0uf /extra/dump_export_home_0 /export/home

# mount /export/home
# cp –r /tmp /export/home --- copy new files in the /export/home
# umount /export/home

Create the incremental backup


#ufsdump 1uf /extra/dump_export_home_1 /export/home

# more /etc/dumpdates ---- shows the incremental backup entries

# mount /export/home
Restoring a Regular File System

When you restore an entire file system from a backup tape, the system creates a restoresymtable
file.
The ufsrestore command uses the restoresymtable file for check-pointing or passing information
between incremental restores. You can remove the restoresymtable file when the restore is
complete.

Make the new filesystem /export/home


Mount /export/home
#cd /export/home
# ufsrestore rf /extra

To restore file1 and file2 from backup


#ufsrestore ivf /extra
Ufsrestore>cd dir1
Ufsrestore>ls
Ufsrestore >add file1 file2
Ufsrestore >ls
Ufsrestore >extract
Ufsrestore >quit
Unit 16

Performance Monitoring
PERFORMANCE MONITORING

Sun Solaris provides following tools to monitor system


performance:-
Various areas that can be monitored for performance bottleneck
are CPU, Memory, Disk, user applications.

 iostat
 sar
 mpstat
 prstat
 vmstat
 top
IOSTAT
It interactively reports cpu, disk, terminal activity & CPU utilization.
Iostat is primarily used to investigate disk activity & disk hardware
errors .

Some important options and their meaning:-

-c time spent in user,system,wait & idle.


-d for each disk reports kb trs/sec, trs/sec, avg service time.
-e displays soft, hard, transport erros.
-E display all device errors.
-M display o/p in Mb/sec
-p per partition statistics.
-x extended output
 # iostat -xntpd
 extended device statistics
 r/s w/s kr/s kw/s %w %b device
 0.5 1.1 5.2 3.5 1 1 d1
 0.0 0.0 0.1 0.1 0 0 d2
 0.0 0.0 0.0 0.0 92 98 c1t1d0s2
 0.0 0.0 0.0 0.0 0 0 c1t1d0s7

 The most important headers to be observed in above o/p are %w & %b.

 %w - Percent of time transactions waiting for


 service.
 %b - Percent of time disk is busy.
Generally during peak hours, %w & %b can shoot to around
100%, but if it is consistingly above 90%, than various reasons like
disk problem, application or DB sitting on that disk, configuration
issues need to be investigated.

# iostat –xntpd 2 10000 …….. will check the IO health every 2


seconds for 10000 iterations.
# iostat -en
---- errors ---
s/w h/w
0 0 d1
0 0 d2
0 0 d10
1 3 c5t600015D000046000000000000000D4B5d0
1 2 c5t600015D000046000000000000000D4C2d0
1 50 c5t600015D0000460000000000000005739d0
1 2 c5t600015D000046000000000000000761Bd0
0 0 rmt/0

The most important header in above output to be observed is h/w. High


value under this header indicates potential disk failure.
 Sar
System Activity Report(sar) – Reports the slice of time spent in user,
system, wait IO activity & idle time.
Some important options of sar command and their meaning is given
below:-
-d Reports activity for all block devices. Shows if block device was
busy servicing request.
-p For paging activity. May help to indicate paging space bottle
necks.
-r Reports free memory & paging space. Size show is in no.of
8kb pages.
-u Reports the time slice that CPU is spending on User, System,
IO Wait activity & Idle time.
# sar -u
SunOS 5.9 Generic_118558-14 sun4u 09/17/2006
00:00:00 %usr %sys %wio %idle
00:10:00 85 5 10 0
00:15:00 75 15 10 0
00:40:00 90 2 6 2
00:45:00 90 2 7 1
00:55:00 86 10 2 2
Average 80 10 7 3
The above output clearly shows that CPU has no idle time, may be CPU is the
bottleneck and upgrade is required.
But in similar output instead of %usr if %wio is high than the issue would be with
disk and not CPU.

Also high USR% can point to issues related to application design.


# sar –r

SunOS 5.9 Generic_118558-14 sun4u 09/17/2006

00:00:00 freemem freeswap


00:10:00 178687 14885660
00:15:00 175120 14836572

Average 109424 13647124

Memory & swap space is shown in 8k pages.


The above output is very much useful in investigating following:-
Mpstat
mpstat reports statistics for all the individual processors.
CPU minf mjf usr sys wt idl
 0 69 11 15 4 8 73
 1 12 0 3 2 2 93
 2 9 0 3 1 1 94
 3 12 0 3 1 1 95
 4 64 0 10 6 5 79
 5 25 0 5 2 3 91
 6 13 0 3 4 1 91

The above output shows that the system is having total 6 CPU’s.
For every CPU it shows the Idle time.
 TOP
Displays and automatically updates information about top cpu processes.

Some of the important information displayed by top is as follows :-

Total processes
Sleeping processes
CPU idle state
Usr%
Iowait%
Memory
free memory
Swap in use
Swap free
Sample output of top :-

last pid: 11549; load averages: 0.45, 19:55:42


301 processes: 300 sleeping, 1 on cpu
CPU states: 95.1% idle, 1.6% user, 1.3% kernel, 2.0% iowait,
0.0% swap
Memory: 24G real, 14G free, 8382M swap in use, 23G swap free

PID USERNAME PRI NICE STATE TIME CPU COMMAND


11451 oracle 59 0 sleep 0:02 0.35% oracle
 11334 oracle 59 0 sleep 0:02 0.31% oracle
 11495 oracle 59 0 sleep 0:04 0.19% oracle
 11336 oracle 59 0 sleep 0:02 0.11% oracle
 11474 oracle 59 0 sleep 0:02 0.10% oracle
UNIT 17

Network service configuration - ssh, ftp, sendmail, dns, nfs


Network Services

 ssh
 ftp
 sendmail
 dns
 nfs
1) SSH :
/etc/ssh/sshd_config
Service : svc:/network/ssh:default

2) FTP :
/etc/ftpd/ftpusers
Service : svc:/network/ftp:default

3) SENDMAIL :
/etc/mail/sendmail.cf
Service : svc:/network/smtp:sendmail
svc:/network/sendmail-client:default
4) DNS :
/etc/resolve.conf  nameserver & search
Service : svc:/network/dns/client:default
svc:/network/dns/server:default

5) NFS :
NFS - Network File System
Allows the multiple computers to use the same file, to reduce
storage cost, provide data consistency & reliability.
NFS daemon starts only when the system enters the run level 3
Command Operation
1 /etc/init.d/nfs.server start | stop  To start & stop the NFS service manually
2 share –F nfs –o <ro/rw> <path>  To share a file for NFS service
3 mount –F nfs <hostname>:<path> <mount point>  To mount the shared file
4 unshare –F nfs <path>  To unshared a file from NFS service
5 shareall -F nfs To share all resources listed in/etc/dfs/dfstab
6 unshareall –F nfs  To un-share all resources listed as above
7 dfshares –F nfs <host>  To display the currently shared NFS
8 dfmounts -F nfs <host>  To display the NFS mounted resources
9 mountall -r -F nfs  To mount all remote file resources
10 umountall -r -F nfs To un-mount all remote file resources
NFS Files Details :
1 /etc/dfs/dfstab  Local resources that as to share at boot time
2 /etc/dfs/sharetab  Currently shared local resources – auto
entry
3 /etc/dfs/fstypes  Default file-system for remote file system
4 /etc/rmtab  FS that remotely mounted by NFS – auto entry
5 /etc/dfs/nfslog.conf  NFS logging configuration file
6 /etc/default/nfslogd  Configuration files for the nfslogd
daemon

Das könnte Ihnen auch gefallen