You are on page 1of 59

UNIX Architecture ----> Hardware ----> Kernel ----> Shell ----> User

General Commands -:
# banner Hi
# id ---> Displays user and group identification for session
# who [am i] ---> Reports information about users who are currently logged on
to a system
who :

root tty1p5 Jul 01 08:01


user1 tty1p4 Jul 01 09:59
user2 tty0p3 Jul 01 10:01

who am i : user2 tty0p3 Jul 01 10:01


whoami :

user2

# passwd ---> Assigns a login password


# echo who are you
# clear
# write username ---> Sends message to username if logged in
# mesg [y|n] ---> Allows or denies "writes" to your terminal
# pwd ---> Present Working Directory
# ls
# ls | more
# ls l grep ^d ----> ^ cape, Starts with 1st letter, grep is a filter command
# ls F
# ls a
# ls ltr ----> Display last modification files and Create a new files. ----> t =
Timestamp, r = Reverse order
# ls -lt ---> Display timestamp

# ls -l
-rw-r--r--

user3

class 37

Jul 24

11:06

f1

-rwxr-xr-x

user3

class 52

Jul 24

11:08

f2

[FileType, Permissions, Links, Owner, Group, Size, Timestamp, Name]


# mkdir <dir-name>
# rmdir <dir-name>
# cp <source> <destination>
# cp R <source> <destination> ----> -R = Recursive, means multiply ---->
Copy sub-directories & files.
# cp p <source> <destination> ----> Copy same time stamp
# mv <source> <destination>
# more <f-name> ----> View the file line by line or page by page
# rm <f-name>
# rm i <f-name>
# rm rf <dir-name> ----> Deleted total sub directory
# cat > <f-name> ----> Ctrl+d
# cat >> <f-name> ----> add new entrees to old file
# cat <f-name> ----> view file
# head -10 <f-name> ----> view first 10 lines, this command used for
monitoring log files
# tail -100 <f-name> ----> view last 10 lines, this command continuously
monitoring last lines / Display the end of file(s)
# wc -lwc <file-name> ---> word coint, -l is line, -w is words and -c is characters
# ln file new-file ---> Link Files
# alias dir=ls
# history
# history -2 ---> In HP-UX List the last two commands.
# history 3 5 ---> List command numbers 3 through 5
# r 4 ---> Run command number 4

Printer -:
# lp report ---> Send requests to a line printer
# lp-n2 memo1 memo2
# lp-dlaser-t"confidential" memo3
# lpstat -t ---> Print spooler status information
# cancle <printer name>
# mkdbm <f-name.dbm> < <f-name.txt>
# mkdbm <f-name.dbm> << <f-name.txt>
File Permissions -:
# chmod 755 <f-name> or <d-name> ---> Change the file access
# chmod u+x,g+x,o+x file
# chown owner:group <f-name> or <d-name> ---> Change the owner and
group of a file / Change the owner of a file
# chgrp group <f-name> or <d-name> ---> Change the group of a file
# umask ---> Change default file access
# umask g=r,o=
# newgrp group-name ---> Switch your group identifier
# su - <user-name> ---> sudo login, - is going to home-directory.
Display variable values -:
# env ---> User Environment.
# PATH=/usr/bin/X11:/usr/bin
# set
# whereis cd ---> Looking for command
# ps -ef ---> Monitoring process
# ps -f
# exec ps -f

<UID> <PID> <PPID> <C> <STIME> <TTY> <TIME> <COMMAND>


# nice -10 cc myprog.c -o myprog
# nice -5 sort * > sort.out &
# kill <id>
Filters -:
# grep am <f-name> ----> check the lines character by character
# grep i am <f-name> ----> -i = ignore casesensitive
# grep v am <f-name> ----> -v = negative patron
# grep l am
# find / -name <f-name> -print ----> find the file
# find / -name atime+90 print --> not open last 90 days -->-atime = accesstime
# find / -name mtime+60 print --->not modify last 60 days -->-mtime = modify
Time
# find / -name atime+90 exec rm { } \ ; ----> delete not open files last 90 days
# du h /etc
# du sh * | sort rn ----> -s = sub-directories
# ff /dev/dsk/c0t0d0s0 ----> display <inode# > <path-name>
# quot af ----> display how much disk space is being used by users
/dev/rdsk/c0t0d0s0 (/); // /dev/rdsk/c0t0s0s4 (usr); // /dev/rdsk/c0t0d0s5 (var)
Sort -:
# sort <f-name>
# sort rn <f-name> ----> -r = Reverse order, -n = numeric order
# sort rn <f-name> > <new f-name>
# sort un <f-name> ----> Find duplicated entries

awk -:
# awk F : {print $1 $7} /etc/passwd ----> # vi /etc/passwd
x1:x:100:100: :/home/x1:/bin/sh
$1 $2 $3 $4 $5

$6

$7

# ls l | awk {print $1,$6}


Sed -:
# sed e s/bash/sh/g /etc/passwd
# sed e s/bash/sh/g /etc/passwd > /home/passwd ----> Create new file
passwd
# sed e 1,10p /etc/passwd ----> print 1 to 10 lines
# sed e 11,$d /etc/passwd ----> deleted 11 to last line of the file print o/p only
Editor -:
vi = Visual editor
sed = Stream editor
EDITOR=vi
export EDITOR
1. Command Mode

2. Insert Mode

3. Append Mode

4. Esc

Ctrl+f ----> Forword page by page Ctrl+b ----> Backword page by page
Esc:$ ----> End of the file Esc:1 ----> first line
Esc:20 ----> go to 20th line
b ----> Curser moves beginning to ending
^ ----> Curser moves ending to beginning
i ----> insert mode
Esc ----> Command mode
a ----> append mode
0 ----> insert a new line
x ----> delete a character

dd ----> delete a line


u ----> undo last deleted
yy ----> copy the lines
10yy ----> copy 10 lines
p ----> paste
cc ----> cut 10
10cc ----> cut 10 lines
/xyz ----> search xyz and n next search
h <-- , j --> doun, k --> up, l -->
w ---> move one word ---->
2w -->
G ---> go to end of line
2G --> go to 2nd line
10G --> go to 10th line
:1, $ s/abc/xyz/g ----> change abc to xyz ----> 1=first line, $=last line,
abc=from, xyz=to change, g=globally, s=search
:w ----> save
:q ----> quit
:wq ----> Save & quit

Configuring Disk Devices :


Whold disk approach
Logical Volume Manager (LVM)
Each partition may contain one of the following : A file system, A swap area, Raw
data, A oot area
SAM is the easiest way to configure a disk using the whole disk approach
SAM --> Disk abd File Systems --> Disk Devices --> Actions --> Add a Disk -->
Not Using LVM
File Systems :
/var/adm --> Common administrative files and log files
/var/spool --> Spooled files used by subsystems such as lp, cron, software
distributor.
/var/tmp --> Temporary files generated by commands in the /usr hierarchy
/var/adm/syslog --> System log files, kernel can log messages here, syslogd
daemon is responsible for writing the log messages, daemon
can be customized with the /etc/syslog.conf file, at boot time
this file is copied to OLDsyslog.log and a new syslog.log is
started. syslog.log file is ASCII file.
/var/adm/sulog --> information of switch user commands. it is a ASCII log file

File System Types:


HFS

High Performance File System

JFS

Journaled File System --> also known as Veritas File System


(VxFS), 10.01 later Online JFS

NFS

Network File System

CDFS CD-ROM File System

Creating New File System:


# newfs -F vxfs /dev/vg01/myfs1 --> creating JFS FS
# newfs -F vxfs -o largfiles /dev/vg01/myfs1 --> creating large FS
# newfs -F hfs /dev/vg01/myfs1 --> creating HFS FS
# newfs -F hfs -o largefiles /dev/vg01/myfs1 --> creating large FS
# mount /dev/vg01/myfs1 /myfs1
# umount /myfs1
# mount -a --> mount all FS ; # umount -a --> unmount all FS
# mount -v --> display mounted FS with FS size, FS (JFS/HFS), mount point
name
A FS cannot be unmounted if any files are open or if any user's current working
directory in that FS, you can use the fuser command to identify which processes
are using a file or file structure.
# fuser -u /dev/vg01/myfs1 --> list process IDs and login names of processes
using
# fuser -uc /opt --> list process IDs and login names of processes that have the
passwd file open.
# fuser -ku /dev/vg01/myfs1 --> kill all process IDs and login users

/etc/fstab :
boot process the /sbin/init.d/localmount script executes the mount -a command
for automatically mounts FS are located in /etc/fstab
Syntax for /etc/fstab :

block:directory:type:options:bckup-frequency:pass-number:comment
type:- cdfs,hfs,nfs,vxfs,swap,swapfs,lofs,ignore
options:- rw,ro,suid,nosuid,quota,noquota
pass-number:- set by the fsck command to determine the order in which fs check
are done.
# fsck -F hfs /dev/vg01/myfs1 --> FS check for shutdown improperly, FS curupt
# fsck -F jfs /dev/vg01/myfs1

SAM : (System Administration Manager)


Advantages: Simplifies complex administration tasks, Minimizes potential for
errors, Provides a built-in help facility.
Disadvantages: Is less flexible than manual confiuration, Is not helpful in some
troubleshooting situations

The root of the overall file system namespace.

/bin

A symbolic link to the /usr/bin directory. It is the directory location


for the binary files of standard system commands.

/dev

The primary directory for logical device names. The contents of this
directory are symbolic links that point to device files in the
/devices directory.

/devices

The primary directory for physical device names.

/etc

The directory that holds host-specific configuration files and


databases for system administration.

/export

The default directory for commonly shared file systems, such as


users home directories, application software, or other shared file
systems.

/home

The default directory or mount point for a users home directory.

/kernel

The directory of platform-independent loadable kernel modules that


are required as part of the boot process.

/mnt

A convenient, temporary mount point for file systems.

/opt

The default directory or mount point for add-on application


packages.

/platform

The directory of platform-dependent loadable kernel modules.

/sbin

The single-user bin directory that contains essential executables


that are used during the booting process and in manual systemfailure recovery.

/tmp

The directory for temporary files. This directory is cleared during the
boot sequence.

/usr

The directory that contains programs, scripts, and libraries that are
used by all system users. The directory name is an acronym for
UNIX system resources.

/var

The directory for varying files, which usually includes temporary,


logging, or status files.

Primary Subdirectories Under the /dev Directory :


Subdirectory
/dev/cua

Description
Dial-out device files for UNIX-to-UNIX Copy Protocol
(UUCP) and Point-to-Point Protocol (PPP)

/dev/dsk

Block disk devices

/dev/fbs

Frame buffer device files

/dev/fd

File descriptors

/dev/md

Logical volume management metadisk devices

/dev/pts

Pseudo terminal devices

/dev/rdsk

Raw disk devices

/dev/rmt

Raw magnetic tape devices

/dev/sound

Audio device and audio-device control files

/dev/term

Serial devices

Primary Subdirectories Under the /etc Directory :


Subdirectory

Description

/etc/acct

Configuration information for the accounting system

/etc/cron.d

Configuration information for the cron utility

/etc/default

Default information for various programs

/etc/inet

Configuration files for network services

/etc/init.d

Scripts for starting and stopping services, used while


changing between run levels

/etc/lib

Dynamic linking libraries needed when the

/usr

file system is not available

/etc/lp

Configuration information for the printer subsystem

/etc/mail

Configuration information for the mail subsystem

Primary Subdirectories Under the /etc (Continued)Directory :


Subdirectory

Description

/etc/nfs

Configuration file for NFS server logging

/etc/opt

Configuration information for optional packages

/etc/rc#.d

Scripts that are when entering or leaving a specific run level

/etc/skel

Default shell initialization files for new user accounts

Contents of the /usr Directory :


Subdirectory

Description

/usr/bin

Standard system commands

/usr/ccs

C-compilation programs and libraries

/usr/demo

Demonstration programs and data

/usr/dt

Directory or mount point for Common Desktop Environment


(CDE) software

/usr/include

Header files (for C programs, and so on)

/usr/java

Directories that contain Java technology programs and


libraries

/usr/kernel

Platform-independent loadable kernel modules that are not


generally required during the boot process

/usr/lib

Architecture-dependent databases, various program


libraries, and binaries that are not invoked directly by the
user

/usr/opt

Configuration information for optional packages

/usr/sbin

System administration commands

/usr/spool

Symbolic link to the /var/spool directory

Note: All files have inode number, data blocks

Types of files:
Regular or ordinary files
Directories
Symbolic links
Device files
Ex:
# cd /etc;ls -l
drwxr-xr-x

adm

drwxr-xr-x

lrwxrwxrwx

adm

512 Apr 3 10:42

acct

root bin

512 Apr 3 10:45

apache

root root

14 Apr 3 11:05

aliases -> ./mail/aliases

-rw-r--r--

root bin

50 Apr 3 10:45

auto_home

-rw-r--r--

root bin

113 Apr 3 10:45

auto_master

# cd /devices/pci@1f,0/pci@1,1/ide@3;ls -l
brw-------

root sys

136, 0 Apr 3 11:11 dad@0,0:a

crw-------

root sys

136, 0 Apr 3 11:11 dad@0,0:a,raw

brw-------

root sys

136, 1 Apr 4 11:06 dad@0,0:b

crw-------

root sys

136, 1 Apr 3 11:11 dad@0,0:b,raw

the first column identifies each file tupe:


-

Regular files

d Directories
l

Symbolic links

b Block-special device files each block 8 kbytes


# ls -l in /dev/dsk
c

# directory points to block-special device

Character-special device files


# ls -l in /dev/pts

each sector 512 bytes

# directory points to character-special device

Symbolic Links:
inode numbers are different
# ls -l /bin
lrwxrwxrwx 1 root root 9 Mar 22 10:39 bin -> ./usr/bin
# ln -s file1 link1

# Creating new symbolic link

Symbolic link contains 9 bytes of data and points to ./usr/bin


Hard Link :
inode numbers are same
# ln file1 file2

# creating new hard link

# find . -inum 1282 : # find's same inode number files


# ls -li /etc/init.d/nfs.server:

# files inode number and who many hard links


associated

# find /etc -inum xxxxx

# xxxxx is inode number, find's same inode


number files

Three different types of file systems :


1. Disk-based file systems
2. Distributed file systems
3. Pseudo file systems
Disk-based file systems :
ufs

UNIX file system in the Solaris OE is based on the


Berkeley fast file system.

hsfs

The High Sierra file system is a special-purpose file system


developed for use on CD-ROM media.

pcfs

The PC file system is a UNIX implementation of the disk


operating system (DOS) file allocation table (FAT32) file system.
The pcfs file system allows the Solaris OE to access PC-DOS

formatted file systems. Users can use UNIX commands for direct
read and write access to PC-DOS files.
udfs

The Universal Disk Format file system is used for optical storage
targeted at DVD and CD-ROM media. The UDF file system
allows universal data exchange and supports read and write
operations.

Distributed file systems :


NFS The network file system allows users to share files among many types
of systems on the network.
Pseudo file systems :
tmpfs

The temporary file system stores files in memory, which avoids


the overhead of writing to a disk-based file system. The tmpfs file
system is created and destroyed every time the system is
rebooted.

swapfs

The swap file system is used by the kernel to manage swap


space on disks.

fdfs

The file descriptor file system provides explicit names for opening
files by using file descriptors (for example, /dev/fd/0, /dev/fd/1,
/dev/fd/2) in the /dev/fd directory.

procfs

The process file system contains a list of active processes in the


/proc directory. The processes are listed by process number.
Information in this directory is used by commands, such as the
ps command.

mntfs

The mount file system provides read-only information from the


kernel about locally mounted file systems.

Creating a New ufs File System :


o To use the disk to store directories or files, a file system must be
created on every disk partition.
o Boot Block : The bootstrap program (bootblk) resides in the 15 disk
sectors (Sectors 115) that follow the VTOC. Only the / (root) file
system has an active boot block.
The ufs Inode :
An inode contains the following information about a file:
o The type of file and the access modes
o The user identification (UID) and group identification (GID) numbers of
the files owner and group
o The size of the file
o The link count
o The time the file was last accessed and modified and the inode
changed
o The total number of data blocks used by or allocated to the file
o Two types of pointers: direct pointers and indirect pointers
# newfs /dev/rdsk/c1t3d0s0 :

# Creating new file system.

newfs: construct a new file system /dev/rdsk/c0d1s0: (y/n)? y


Note This process also creates a lost+found directory for the ufs file system,
which is a directory that is used by the file system check and repair (fsck) utility.

Checking the File System :


# fsck /dev/rdsk/c0d1s0

# Check filesystem

** /dev/rdsk/c0d1s0
** Last Mounted on
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
2 files, 9 used, 47966 free (14 frags, 5994 blocks, 0.0% fragmentation)
# fsck -o f,p /dev/rdsk/c0d1s0 : # f option of the fsck command forces a file
system check, and p option checks and fixes
the file system noninteractively (preen).
/dev/rdsk/c0d1s0: 2 files, 9 used, 47966 free
/dev/rdsk/c0d1s0: (14 frags, 5994 blocks, 0.0% fragmentation)
# fsck /dev/rdsk/c0t0d0s7 : # check a file system using the unmount point
filesystem
# fsck /export/home :

# check a file system using the mount point directory

# newfs NV /dev/rdsk/c0t0d0s5 :

# find out bad super blocks

# fsck -o b=32 /dev/rdsk/c0d1s0 :

# backup superblock number

Alternate super block location: 32.


# newfs -N /dev/rdsk/c0d1s0 :

# view the file system parameters

Monitoring File System :


# df -h, -k, -l, -e, -b, -a
<Filesystem >

<size>

# display the capacity of file systems


<used>

<avail>

<capacity>

<Mounted on>

# du -k, -s, -a : # display the number of disk blocks used by directories and files
# quot -af

(or)

# quot f : # display disk space being used by users on all


mounted file systems,

/dev/rdsk/c0d0s0 (/):
1120970 54185 root
801

46 uucp

62

11 adm

13

13 lp

11

4 bin

4 daemon

8 nobody

2 smmsp

# /etc/vfstab :

# Permanent mount entries and Mounting a File System


Automatically at system boot time

<device to mount><device to fsck><mount point ><FS type><fsck pass><mount


at boot><mount options>
# /etc/mnttab :

# mounted file system table

o The /etc/mnttab file is really an mntfs file system that provides readonly information directly from the kernel about mounted file systems on
the local host.
o Each time a file system is mounted, the mount command adds an entry
to this file. Whenever a file system is unmounted, its entry is removed

from the /etc/mnttab file.


# mount :

# Display currently mounted file systems.

Mounting a Local File System Manually :


# mount /dev/dsk/c0t0d0s7 /export/home
# mount /export/home
# mount -o ro /dev/dsk/c0t0d0s6 /usr :# Mounts the file system as read-only.
[Indicates whether reads and writes are
allowed on the file system]
# mount -o ro,nosuid /dev/dsk/c0t0d0s7 /export/home :
# Prohibits the execution of setuid programs in the file system. This does
not restrict the creation of setuid programs. [Permits the execution of
setuid programs in the file system]
# mount -o noatime /dev/dsk/c0t0d0s7 /export/home :
# Allows and forbids keyboard interrupts to kill a process that is waiting
for an operation on a locked file system.
# mount -o nolargefiles /dev/dsk/c0t0d0s7 /export/home

# Indicates that

logging is not enabled for the ufs file system.


# mount -o logging /dev/dsk/c0t0d0s7 /export/home
# mountall

# mount all file systems listed in the /etc/vfstab.

# mountall -l # mount only the local file systems listed in the /etc/vfstab file
# mount /dev/dsk/c1t4d0s0 /database

# Mount the new file system manually

Determining a File Systems Type :


o The /etc/vfstab file for the FS type field
o The /etc/default/fs file for a local file system type
o The /etc/dfs/fstypes file for a remote file system type

Ex:
# cat /etc/vfstab
#device

device

#to mount

mount

FS

fsck

mount mount

point

type

pass

at boot options

to fsck

#
fd

/dev/fd fd

/proc -

/proc proc

/dev/dsk/c0d0s1 -

no
-

no

swap

no

/dev/dsk/c0d0s0 /dev/rdsk/c0d0s0

swap

/tmp

tmpfs -

yes

ufs

no

# cat /etc/default/fs
LOCAL=ufs
# cat /etc/dfs/fstypes
nfs NFS Utilities
autofs AUTOFS Utilities
cachefs CACHEFS Utilities
# fstyp /dev/rdsk/c0d1s0

# determine a file systems type.

# mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom :


# mount a file system that resides on a CD-ROM
# mount -F pcfs /dev/diskette /pcfs :
# umount /export/home : # unmount file system
# umount /dev/dsk/c0t0d0s7 :
# umountall :

# unmount file system

# umount all file systems listed in the /etc/vfstab

# umountall l : # umount only the local file systems listed in the /etc/vfstab file
# unmount -f /dev/dsk/c0t0d0s6 :

# unmount forces

# fuser -cu mount_point : # displays the name of the file system and the
user login name for each process currently active in
the file system.
# fuser -ck mount_point :

# Kill all processes accessing the file system.

# fuser -c mount_point : # Verify that there are no processes accessing the file
system.
# umount mount_point : # Unmount the file system.
# umount -f mount_point :
# /etc/vold.conf :

# Auto mount CD-ROM Configuration file.

# /etc/rmmount.conf :
# vold :

# unmount CD-ROM Configuration file

# mount CD-ROM

# /etc/init.d/volmgt stop: # Stop and start the services


# /etc/init.d/volmgt start: # Stop and start the services
# pkill -9 vold :

# Kill the vold process

HP-UX
Default File System

Device Configuration :
/dev --> Listing device files with ll comman

Linux
ext2, ext3

Solaris
ufs

brw-r----- 1 root sys 31 0x005000 Feb 10 1999 /dev/dsk/c0t5d0


crw-r----- 1 root sys 31 0x005000 Feb 10 1999 /dev/rdsk/c0t5d0
b or c : device file type;

31 is major# ; 0x005000 is minor# ;

/dev/dsk/c0t5d0 is device file name

c is Character Device Files : character device files transfer data to the


device one character at a time, Devices such as terminals, printers,
modems and tape drivers.

b is Block Device Files : Accessing a device via a block device file, the

system reads and writes data through a buffer in memory, rather than
transferring the data directly to the physical disk

major# : identifies the "kernel driver" that should be used when the
device is accessed.

Minor# : is a 24-bit hexadecimal number, identifies physical location


of the device on the system.
Each physical volume have both a block and a character device file
Listing Device Files:
# ioscan -fun --> list all devices and their associated device files
# ioscan -funC disk -->only list disk class devices and their device files
# ioscan -funC tape --> only list tape drivers and their device files
o/p:

I is instance number

Class I

H/W

disk 0 8/12.2.0

Path

Driver

sdisk CLAIMED

S/WState H/Wtype
DEVICE

SEAGATE

Description
ST32171W

Logical Unit Number (LUN) : most SCSI devices, however, the


LUNnumber will simply be "0"

# /usr/sbin/lssf /dev/rdsk/c1t6d0 --> display device's hardware


address information
Layout of /dev :
/dev -->

Contains all terminal, modem, lan and printer device files

/dev/dsk --> Contains all block disk device files


/dev/rdsk -->Contains all raw disk device files
/dev/rmt --> Contains all tape device files
c#t#d#[other] -->
c = interface card,
t = SCSI target,
d = Device number,
[other] is device information

Physical Disk Structure : Head actuator arm -- Heads -- Platters -- Spindle

A disk platter is divided into sectors, tracks, and cylinders.


Sector
The smallest addressable unit on a platter. One sector can
hold 512 bytes of data. Sectors are also known as disk
blocks.
Track
A series of sectors positioned end-to-end in a circular path.
Cylinder A stack of tracks.
disk slices
Disks are logically divided into individual partitions known as
disk slices. Disk slices are groupings of cylinders that are
commonly used to organize data by function.
c#t#d#s# :
c#
:
t#
:
d#
:
s#
:

SCSI Hard disk


Controller number
Target number
Disk number
Slice number

c#d#s# :

IDD Hard disk

Logical device names: Logical disk device names are symbolic links to the
physical device names kept in the /devices directory.
# ls /dev/dsk
c0t0d0s0 c0t0d0s4 c0t3d0s0 c0t3d0s4 c0t6d0s0 c0t6d0s4
c0t0d0s1 c0t0d0s5 c0t3d0s1 c0t3d0s5 c0t6d0s1 c0t6d0s5
Phyical Device names: Physical device names uniquely identify the physical
location of the hardware devices on the system and are maintained in the
/devices directory.
# ls -l /dev/dsk/c0t0d0s0
lrwxrwxrwx 1 root root 46 Jun 16 19:07
../../devices/pci@1f,0/pci@1,1/ide@3/dad@0,0:a

/dev/dsk/c0t0d0s0

->

List the system's devices :


/etc/path_to_inst : # For each device, the system records its physical name and
instance name in the /etc/path_to_inst file. These names are
used by the kernel to identify every possible device. This file
is read only at boot time.
# prtconf :

# Use the prtconf command to display the systems


configuration information, including the total amount of
memory installed and the configuration of
peripherals, which is formatted as a device tree.

system

# prtconf | grep -v not :

# The grep -v not command is used to omit all lines


containing the word not from the output (such as
driver not attached).

# format :

# Use the format command to display both logical and


physical device names for all currently available disks. To
view the logical and physical devices for currently
available disks

devfsadm Command :
o Many systems are running critical customer applications on a 24-hour,
7-day-a-week basis. It might not be possible to perform a
reconfiguration boot on these systems. In this situation, you can use
the devfsadm command.
o The devfsadm command performs the device reconfiguration process
and updates the /etc/path_to_inst file and the /dev and /devices
directories during reconfiguration events.
Syntax:
#devfsadm -c device_class :

# specific device class, use the -c option.

# devfsadm -c disk
# devfsadm -c disk -c tape -c audio
Syntax:
#devfsadm -i driver_name : # configure only devices for a named driver, use
the -i option.
# devfsadm -i dad : # To configure only those disks supported by the dad driver
# devfsadm -i sd : # To configure only those disks supported by the sd driver
# devfsadm -i st : # To configure devices supported by the st driver

# devfsadm -v
:
# To print the changes made by the devfsadm
command to the /dev and /devices directories
# devfsadm -C
:
# To invoke
unreferenced symbolic links for devices
# format :

cleanup

# Disk partition

Partitioning a Disk :Ex:


# format
Searching for disks...done
Specify disk (enter its number): X # X is number
FORMAT MENU:
disk
type
partition
current
format
fdisk
repair
show
label
analyze
defect
backup
verify
save
volname
!<cmd>
quit
format> partition

- select a disk
- select (define) a disk type
- select (define) a partition table
- describe the current disk
- format and analyze the disk
- run the fdisk program
- repair a defective sector
- translate a disk address
- write label to the disk
- surface analysis
- defect list management
- search for backup labels
- read and display labels
- save new disk/partition definitions
- set 8-character volume name
- execute <cmd>, then return

PARTITION MENU:
0
- change `0' partition
1
- change `1' partition
2
- change `2' partition
3
- change `3' partition
4
- change `4' partition
5
- change `5' partition
6
- change `6' partition
7
- change `7' partition

routines

that

remove

select - select a predefined table


modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
!<cmd> - execute <cmd>, then return
quit
partition> print
Current partition table (original):
Total disk cylinders available: 4158 + 2 (reserved cylinders)
Part
0
1
2
3
0
4
0
5
6
0
7
0
8
1008
9
2016

Tag
Flag
alternates
unassigned
backup
wu
unassigned

Cylinders
Size
Blocks
wm 1 - 102
50.20MB
(102/0/0) 102816
wm 102 - 203
50.20MB
(102/0/0) 102816
0 - 4157 2.00GB
(4158/0/0) 4191264
wm 0
0
(0/0/0)

unassigned

wm

unassigned
unassigned

wm
wm

0
0

0
0

unassigned

wm

boot

wu

0.49MB

(1/0/0)

alternates

wm

0.98MB

(2/0/0)

(0/0/0)
(0/0/0)

0
(0/0/0)
(0/0/0)

partition> 1
Part
Tag Flag Cylinders
Size
Blocks
1 unassigned wm 102 - 203
50.20MB (102/0/0) 102816
Enter partition id tag[unassigned]: ^D
Note:
Part: The slice number. Valid slice numbers are 0 through 7
Tag: A value that indicates how the slice is being used.
0 = unassigned
1 = boot
2 = root
3 = swap
4 = usr
5 = backup
6 = stand

8 = home
Sun StorEdge Volume Manager array tags:
14 = public (region)
15 = private (region)
Flag: 00 wm = The disk slice is writable and mountable.
01 wu = The disk slice is writable and unmountable. This is the default
state of slices dedicated for swap areas.
10 rm = The disk slice is read-only and mountable.
11 ru = The disk slice is read-only and unmountable.
Cylinders:
The starting and ending cylinder number for the disk slice.
Size:
The slice size: Mbytes (MB), Gbytes (GB), blocks (b), or cylinders
(c).
Blocks:
The total number of cylinders and the total number of sectors
per slice.
/etc/format.dat :
# You can save customized partition tables to the
/etc/format.dat file and use them to quickly partition other disks of the same type
on the system.
save a customized partition table :
partition> name
Enter table name (remember quotes): 2gb-disk2
partition> quit
format> save
Saving new disk and partition definitions
Enter file name["./format.dat"]: /etc/format.dat
format>
Using the Customized Partition Table :
format> partition
partition> select
0. 2gb-disk2
1. original
Specify table (enter its number)[1]: 0
partition 0: starting cylinder 1 is out of range
partition> label
Ready to label disk, continue? yes
partition> quit

format> verify

# Verify the partitions

format>quit
Managing Disk Labels :
Viewing the Disk VTOC (volume table of contents): You can use two methods for
locating and viewing a disks label or VTOC:
1. Use the verify command from the format utility
2. Invoke the prtvtoc command from the command line
Ex:
format> verify
Primary label contents:
Volume name = < >
ascii name = <SUN1.3G cyl 1965 alt 2 hd 17 sec 80>
pcyl = 3500
ncyl = 1965
acyl = 2
nhead = 17
nsect = 80
Part Tag Flag Cylinders Size Blocks
0 root wm 0 - 602 400.43MB (603/0/0) 820080
1 swap wm 603 - 693 60.43MB (91/0/0) 123760
2 backup wm 0 - 1964 1.27GB (1965/0/0) 2672400
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 home wm 694 - 1964 844.02MB (1271/0/0) 1728560

# prtvtoc /dev/rdsk/c1t0d0s2 :
* /dev/rdsk/c1t0d0s2 partition map
*
* Dimensions:
* 512 bytes/sector
* 80 sectors/track
* 17 tracks/cylinder
* 1360 sectors/cylinder
* 3500 cylinders
* 1965 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*

# list the VTOC for each of the disks

* First Sector Last


* Partition Tag Flags Sector Count Sector Mount Directory
0 2 00 0 820080 820079
1 3 00 820080 123760 943839
2 5 00 0 2672400 2672399
7 8 00 943840 1728560 2672399
# prtvtoc /dev/rdsk/c1t0d0s2 > /vtoc/c1t0d0 : # save partition output to a file in
the /vtoc directory.
Relabeling a Disk :
First save a disks VTOC to a file by using the prtvtoc command after to relabel
the disk by using the fmthard command
# prtvtoc /dev/rdsk/c1t0d0s2 > /vtoc/c1t0d0 : To save a disks VTOC to a file,
# fmthard -s /vtoc/c1t0d0 /dev/rdsk/c1t0d0s2 :
To write the desired label information, previously saved to a datafile back
to the disk. // Run format, select the disk, and label it with the default partition
table.
# dd if=/dev/zero of=/dev/rdsk/c1t0d0s2 bs=512 count=1 :# cmc&
# GID Administration tool

USER ADMIN

Imp. Files :
/etc/passwd

# Maintain user information

<LoginID>:<passwd>:<UID>:<GID>:<Comment>:<home_directory>:<login_sh
ell>
/etc/shadow

# Maintain user's password information.

<LoginID>:<password>:<lastchg>:<min>:<max>:<warn>:<inactive>:<expire>
/etc/group

# Maintain group information

<groupname>:<group-password>:<GID>:<user name-list>
Commands :
# useradd [-u uid] [-g gid] [-G gid,gid] [-d dir] [-m] [-s shell] [-c
comment] [-k skel-dir] [-o] [-e expire] [-f inactive] <loginname>
# usermod [-u uid] [-o] [-g gid] [-G gid,gid] [-d dir] [-m] [-s shell] [-c
comment] [-l new log name] [-f inactive] [-e expire] <loginname>
# groupadd [-g gid] [-o] <group-name> #[-o is duplicated gid / non-unique
uid or gid]
# groupmod [-g gid] [-o] [-n name] <group-name>
# userdel r <login-name>

# r is Removes users home directory

# groupdel <group-name>
# passwd <user-name>
Options :

-l

# lock the user password

-u

# unlock the user password

-d

# with out passwd login

-n

# minimum password lifetime

-x

# maximum password lifetime

-w

# passwd expire warning

-i

# expired the user password or user a/c disable/inactive

-f

# forces a user change the password at next login

# id <user-name> # Shows user id, name and primary and secondry group's
# finger <user-name>

# shows user information

# chage -l <user-name>

# in Linux shows user password aging.

# newgrp <group-name>

# user can be a member of more than one


group. newgrp command to change to a
different group.

# grpck

# in hp-ux check for the number of fields in

each
entry, and whether all login names appear in
the password file.
# useradd -D

# Display the useradd defaults [group, home,


inactive, expier, shell and skel]

# logins -xl <user-name>

# Find user password aging and user is locked

or
unlocked

[logins- list user and system login

information]
-l <login-name>

# Selects the requested login. Multiple logins can be


specified as a comma-separated list.

-x <login-name>

# Prints an

extended

set

of

information

about

each
selected

user. The extended information includes

home directory, login shell and password aging


information, each displayed on a separate line. The
password information consists of password

status

(PS for password, NP for no password or LK for


locked). If the login is passworded, status is followed
by the date the password was last changed, the
number of days required between changes, and the
number of days allowed before a change is required.
The password aging information shows the time
interval that the user receives a password expiration
warning

message

(when

logging on) before the

password expires.

Password files

HP-UX
/etc/passwd

Linux
/etc/passwd

Solaris
/etc/passwd

Group files

/tcb/files/auth/r/root
/etc/group

/etc/shadow
/etc/group

/etc/shadow
/etc/group

Max # of user ID
Allow/Deny remote login

/etc/logingroup
2147483647
/etc/securetty

65535
/etc/securitty

2147483647
/etc/default/login

{console}

{ttyp1}

{CONSOLE=/dev/consol

99

e}
60001

&

65534

99

(nobody4)
60002
&

65534

User nobody's id#


Group nobody's id#

-2
-2 (nogroup)

(nogroup)

Create new user


Delete user
List users
Modify user account
Useradd default file

Useradd
Userdel
Logins
Usermod

Useradd
Userdel
Usermod
/

useradd
userdel
logines
usermod
/etc/default/passwd

etc/default/usera
Sudo File

dd
/etc/sudoers (or)

Default Shell

visudo
Bourn

Passwd file permissions


Shadow file permissions

POSIX
r-- r-- r--

/bin/bash
rw- r-- r-r-- --- ---

-r-- r-- r-r-- --- ---

Note:
Solaris:
UID / GID numbers for regular users / groups range from 100 to 60000 unique.
1 99 # System accounts
60001 # Nobody
60002 # No Access user
14 GID is Sys. Admin group
Password : 13 Characters, *LK* is Locked account
useradd default's location is /etc/default/passwd
MAXWEEKS=
MINWEEKS=
PASSLENGTH=6
User lock ex:
test:*LK*:13427::::::
User unlock ex:
test:G9HMdpFjiJzSE:13427::::::

Linux :
useradd default's location is /etc/default/useradd
GROUP=501
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
User lock ex:
test:!!$1$8jjA2q6e$t9RvGdLM7bVZJBT6AXH8W.:13430:1:20:2:1::
User unlok ex:
test:$1$8jjA2q6e$t9RvGdLM7bVZJBT6AXH8W.:13430:1:20:2:1::

HP-UX:
Permission on /etc/passwd file is r--r--r-- only
SAM --- Accounts for Users and Groups --- Actions --- Add........
Sudo-permissions :
Linux :
# vi /etc/sudoers (or) visudo
username

ALL=(ALL) command,command,........

root

ALL=(ALL) ALL

User profile's:
Linux :
Born Shell /bin/bash
.bash_history .bash_logout .bash_profile .bashrc .gtkrc .kde/

Shell's:

Linux :
Default shell is Born Shell /bin/bash

Package Administration :
# /var/sadm/install/contents :

# file is a complete record of all the software


packages installed on the local system disk

# grep showrev /var/sadm/install/contents :

# verify that the showrev command is installed on the system disk


Commands:
# pkgadd : # Installs software packages to the system
# pkgrm :

# Removes a package from the system

# pkginfo : # Displays software package information


# pkgchk :

# Checks package installation state

# pkginfo | more : # to display information about software packages installed


on the local systems disk
# pkginfo -l | more : # to view additional information about each software
package installed on the local systems hard drive
# pkginfo -l SUNWman : # to view the information for the SUNWman
software package
# pkginfo | wc l : # To determine how many packages are currently
installed on disk
# pkginfo -d /cdrom/cdrom0/s0/Solaris_9/Product |more:
# To view information about packages that are located on Solaris 9
Software 1 of 2 CD-ROM
# cd /cdrom/cdrom0/Solaris_9/ExtraValue/EarlyAccess/Netscape_6/Packages

# to transfer the SUNWns6m software package from a CD-ROM and


install it on the system
# pkgadd -d . SUNWns6m :
# pkgchk SUNWcarx :

# Addning the software package

# checks the contents and attributes of the


SUNWcarx software package currently installed on
the system

# pkgchk -v SUNWcarx : # to list the files in the SUNWcarx 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 -p /usr/bin/showrev : # to list information of the file


# pkgrm SUNWapchr : # removes the SUNWapchr software package from
the System
Adding Packages by Using a Spool Directory :

For convenience, copy frequently installed software packages from the


Solaris 9 Software CD-ROM to a spool directory on the system.

# /var/spool/pkg : # default installation directory for packages that have been


spooled
# pkgadd -d /cdrom/cdrom0/s0/Solaris_9/Product -s spool SUNWensqr.u
# To copy a package into the spool directory
# ls -al /var/spool/pkg : # To verify that the package exists in the spool directory
# pkgrm -s spool SUNWensqr.u : # To remove software packages from a
spool directory,
# pkgadd -d /cdrom/cdrom0/s0/Solaris_9/Product -s /export/pkg SUNWensqr.u

# pkgrm -s /export/pkg SUNWensqr.u


Package Administration Files and Directories :
/var/sadm/install/contents :

# A software package map of the entire


system

/opt/pkgname : # The preferred location for the installation of unbundled


Packages
/opt/pkgname/bin or /opt/bin : # The preferred location for the executable
files of unbundled packages

/var/opt/pkgname or /etc/opt/pkgname : # The preferred location for log


files of unbundled packages

Patch Administration :
http://sunsolve.sun.com : # To access patch documents through the World
Wide Web
# showrev p:

# information about currently installed patches.

# patchadd p :

# information about currently installed patches.

# /var/sadm/patch :

# information about all patches that are currently


installed on a system

Download patches:
# cd /var/tmp
# ftp sunsolve.sun.com
Name (sunsolve:usera): anonymous
Password:yourpassword
ftp> cd /pub/patches
ftp> get Solaris9.PatchReport
ftp> mget 112605*
ftp> bye
# unzip 105050-01.zip :

# Unzip the patche

# zcat 105050-01.tar.Z | tar xvf - :# zcat command to uncompress the patch


files and the tar command to create the patch
directories
# patchadd

# Installs uncompressed patches to the Solaris OE

# patchrm

# Removes patches installed on the Solaris OE

Installing the patches:


# cd /var/tmp
# patchadd 105050-01
Note: Some of the error codes found in the /usr/sbin/patchadd command
0

# No error.

# Usage error.

# An attempt to apply a patch that has already been applied.


upto 37

# patchrm 105050-01 :

# to remove a patch

Note: Those components of the /var/sadm directory that are updated during the
installation of patch 105050-01.
# /var/sadm/pkg/SUNWhea/pkginfo
# /var/sadm/pkg/SUNWhea/Save/105050-01
# /var/sadm/pkg/SUNWcsu/pkginfo (Update by patch)
# /var/sadm/pkg/SUNWcsu/pkginfo/Save/105050-01/undo.z (Archive
of old files replaced by patch)
# /var/sadm/pkg/patch/105050-01/README.105050-01
# /var/sadm/pkg/patch/105050-01/log

An NFS server is a machine that exports its local directories (makes them
available for client machines to mount using NFS).
Following are the tasks involved in configuring and administering an NFS server.
The first two tasks are the only ones required to get your server up and running.
i)

To Make Directories Available to NFS Clients (Export Directories)

ii)

To Enable NFS Server Capability

iii)

To Remove (Unexport) an Exported Directory

iv)

To Enable PC NFS Server Capability

v)

To Disable NFS Server Capability

i) To Make Directories Available to NFS Clients (Export Directories)


1. Add a line to the /etc/exports file for each directory you want to make available
to NFS clients, If the /etc/exports file does not exist on your system, you will have
to create it. File permissions are 644,
syntax: directory [-option[,option]]
2. If your system is already running as an NFS server, issue the following
command to add the directory to your servers internal list of exported directories:
/usr/sbin/exportfs directory
You can issue the exportfs -i command to add the directory to your servers
internal list of exported directories, without adding the directory to the /etc/exports
file.

ii)

To Enable NFS Server Capability

1. In the /etc/rc.config.d/nfsconf file, make sure the NFS_SERVER and


START_MOUNTD variables are set to 1, as follows:
NFS_SERVER=1
START_MOUNTD=1

2. Issue the following command to run the NFS startup script:


/sbin/init.d/nfs.server start
The NFS startup script uses the variables in /etc/rc.config.d/nfsconf to determine
which processes to start.
The START_MOUNTD variable causes the NFS startup script to start
rpc.mountd, the mount daemon.
iii)

To Remove (Unexport) an Exported Directory

1. On the NFS server, issue the following command for a list of all the NFS
clients that have mounted the directory you want to unexport:
/usr/sbin/showmount -a
2. On every NFS client that has the directory mounted, issue the following
command for a list of the process IDs and user names of everyone using the
mounted directory:
/usr/sbin/fuser -u servername:/directory
3. Warn any users to cd out of the directory, and kill any processes that are using
the directory, or wait until the processes terminate. You can use the following
command to kill all processes using the directory:
/usr/sbin/fuser -ck local_mount_point
4. On every NFS client that has the directory mounted, issue the following
command to unmount the directory:
/usr/sbin/umount local_mount_point
or
/usr/sbin/umount servername:/directory

5. On every NFS client that had the directory mounted, use a text editor to
comment out or remove the line in the /etc/fstab file that lists the directory you
want to unexport.
6. On the NFS server, use a text editor to remove the line in the /etc/exports file
that lists the directory you want to unexport.
7. On the NFS server, issue the following command to unexport the directory:
/usr/sbin/exportfs -u directory
For more information, see the following man pages: showmount(1M), fuser(1M),
umount(1M), and exportfs(1M), make(1), and ypmake(1M).

iv)

To Disable NFS Server Capability

1. On the NFS server, issue the following command for a list of all the NFS
clients that have directories mounted from the NFS server you are planning to
disable:
/usr/sbin/showmount -a
2. On every NFS client listed by the showmount command, issue the following
command for each directory that is mounted from your NFS server:
/usr/sbin/fuser -u servername:/directory
This command lists the process IDs and user names of everyone using the
mounted directory.
3. Warn any users to cd out of the directory, and kill any processes that are using
the directory, or wait until the processes terminate. You can use the following
command to kill all processes using the directory:
/usr/sbin/fuser -ck local_mount_point

4. On every client that has directories mounted from your server, issue the
following command:
/usr/sbin/umount -h servername
5. If your server will be down for a long time, edit the /etc/fstab file on each client
to comment out or remove any NFS mounts from the server you are planning to
disable.
6. Issue the following command on the server to unexport all exported
directories:
/usr/sbin/exportfs -au
7. On the NFS server, edit the /etc/rc.config.d/nfsconf file to set the
NFS_SERVER variable to 0. This prevents the NFS server daemons from
starting up when your system reboots. If your server will be down only a short
time, this step is unnecessary.
NFS_SERVER=0
8. Edit the /etc/inetd.conf file to comment out the line that contains rpc.mountd (if
it exists) and the lines for the other RPC services.
9. Issue the following command to disable NFS server capability:
/sbin/init.d/nfs.server stop

Client:
1. In the /etc/fstab file, use a text editor to add a line for each remote directory
you want mounted on your system. If the /etc/fstab file does not exist, you will
have to create it. A line in the /etc/fstab file has the following

syntax: server:remote_directory local_directory nfs defaults 0 0


or
server:remote_directory local_directory nfs option[,option...] 0 0
2. If your system is already running as an NFS client, issue the following
command to mount each remote directory you have added to the /etc/fstab file:
/usr/sbin/mount local_directory
Or
issue the following command to mount all the directories listed in the /etc/fstab
file: /usr/sbin/mount -a
Example NFS Mount : broccoli:/usr/share/man /usr/share/man NFS ro 0 0
i)

To Enable NFS Client Capability

1. In the /etc/rc.config.d/nfsconf file, make sure the NFS_CLIENT variable is set


to 1, as follows:
NFS_CLIENT=1
2. Run the NFS startup script by issuing the following command:
/sbin/init.d/nfs.client start
Setting the NFS_CLIENT variable to 1 causes the NFS startup script to be run
whenever you reboot your system.

ii)

To Remove (Unmount) a Mounted Directory

1. On the NFS client, issue the following command to determine whether the
directory you want to unmount is currently in use:
/usr/sbin/fuser -cu local_mount_point
This command lists the process IDs and user names of everyone using the

mounted directory.
2. Warn any users to cd out of the directory, and kill any processes that are using
the directory, or wait until the processes terminate. You can use the following
command to kill all processes using the mounted directory:
/usr/sbin/fuser -ck local_mount_point
3. If you want to remove the mounted directory permanently, use an editor to
remove the appropriate line in the /etc/fstab file.
4. Issue the following command at the HP-UX prompt:
/usr/sbin/umount local_mount_point

iii)

To Disable NFS Client Capability

1. On the NFS client, issue the mount(1M) command with no options, to get a list
of all the mounted file systems on the client:
/usr/sbin/mount
2. For every NFS-mounted directory listed by the mount command, issue the
following command to determine whether the directory is currently in use:
/usr/sbin/fuser -cu local_mount_point
This command lists the process IDs and user names of everyone using the
mounted directory.
3. Warn any users to cd out of the directory, and kill any processes that are using
the directory, or wait until the processes terminate. You can use the following
command to kill all processes using the mounted directory:
/usr/sbin/fuser -ck local_mount_point
4. Issue the following command on the client to unmount all NFS-mounted

directories:
/usr/sbin/umount -at nfs
5. Edit the /etc/rc.config.d/nfsconf file on the client to set the NFS_CLIENT
and AUTOMOUNT variables to 0. This prevents the client processes from
starting up again when you reboot the client.
NFS_CLIENT=0
AUTOMOUNT=0
6. Issue the following command to disable NFS client capability:
/sbin/init.d/nfs.client stop
Note:

NFS runs over both UDP and TCP transport protocols. The default

transport protocol is TCP.


NFS version 2 and version 3.
/etc/services :
nfsd 2049/tcp #NFS remote file system
nfsd 2049/udp #NFS remote file system

Troubleshooting Solaris NFS Problems


Some common NFS errors are:
1. The rpcbind failure error
2. The server not responding error
3. The NFS client fails a reboot error
4. The service not responding error
5. The program not registered error

6. The stale file handle error


7. The unknown host error
8. The mount point error
9. The no such file error
10. No such file or directory
Troubleshooting recommendations:
1. The rpcbind failure Error. The following example shows the message
that appears on the client
system during the boot process or in response to an explicit mount
request:
o nfs mount: server1:: RPC: Rpcbind failure
RPC: Timed Out
nfs mount: retrying: /mntpoint
The error in accessing the server is due to:
o The combination of an incorrect Internet address and a correct host
or node name in the hosts database file supporting the client node.
o The hosts database file that supports the client has the correct
server node, but the server node temporarily stops due to an
overload.
To solve the rpcbind failure error condition when the server node is
operational, determine if the server is out of critical resources (for
example, memory, swap, or disk space).
2. The server not responding Error The following message appears during
the boot process or in response to an explicit mount request, and this
message indicates a known server that is inaccessible.
NFS server server2 not responding, still trying
Possible causes for the server not responding error are:
o The network between the local system and the server is down. To
verify that the network is down, enter the ping command (ping
server2).
o

The server ( server2) is down.

The NFS client fails a reboot Error. If you attempt to boot an NFS client
and the client-node stops, waits, and echoes the following message:
Setting default interface for multicast: add net 224.0.0.0: gateway:
client_node_name.
these symptoms might indicate that a client is requesting an NFS mount
using an entry in the /etc/vfstab file, specifying a foreground mount from a

non-operational NFS server.


To solve this error, complete the following steps:
1. To interrupt the failed client node press Stop-A, and boot the client into
single-user mode.
2. Edit the /etc/vfstab file to comment out the NFS mounts.
3. To continue booting to the default run level (normally run level 3), press
Control-D.
4. Determine if all the NFS servers are operational and functioning
properly.
5. After you resolve problems with the NFS servers, remove the comments
from the /etc/vfstab file.
Note If the NFS server is not available, an alternative to commenting out
the entry in the /etc/vfstab file is to use the bg mount option so that the
boot sequence can proceed in parallel with the attempt to perform the
NFS mount.
3. The service not responding Error. The following message appears
during the boot process or in response to an explicit mount request, and
indicates that an accessible server is not running the NFS server
daemons.
nfs mount: dbserver: NFS: Service not responding
nfs mount: retrying: /mntpoint
To solve the service not responding error condition, complete the following
steps:
o

Enter the who -r command on the server to see if it is at run level


3. If the server is not, change to run level 3 by entering the init 3
command.

o Enter the ps -e command on the server to check whether the NFS


server daemons are running. If they are not, start them by using the
/etc/init.d/nfs.server start script.
o The program not registered Error. The following message appears
during the boot process or in response to an explicit mount request and
indicates that an accessible server is not running the mountd
daemon.
nfs mount: dbserver: RPC: Program not registered
nfs mount: retrying: /mntpoint
To solve the program not registered error condition, complete the following
steps:

Enter the who -r command on the server to check that it is at run


level 3. If the server is not, change to run level 3 by performing the
init 3 command.

Enter the pgrep -xl mountd command. If the mountd daemon is not
running, start it using the /etc/init.d/nfs.server script, first with the
stop flag and then with the start flag.

Check the /etc/dfs/dfstab file entries.

o The stale NFS file handle Error. The following message appears when a
process attempts to access a
remote file resource with an out-of-date file handle. A possible cause for
the stale NFS file handle error is that the file resource on the server
moved. To solve the stale NFS file handle error condition, unmount and
mount the resource again on the client.
1. The unknown host Error. The following message indicates that the host
name of the server on the client is missing from the hosts table.
nfs mount: sserver1:: RPC: Unknown host
To solve the unknown host error condition, verify the host name in the
hosts database that supports the client node. Note The preceding
example misspelled the node name server1 as sserver1.
2. The mount point Error. The following message appears during the boot
process or in response to
an explicit mount request and indicates a non-existent mount point.
mount: mount-point /DS9 does not exist.
To solve the mount point error condition, check that the mount point exists
on the client. Check the spelling of the mount point on the command line
or in the /etc/vfstab file on the client, or comment out
the entry and reboot the system.
3. The no such file Error. The following message appears during the boot
process or in response to
an explicit mount request, which indicates that there is an unknown file
resource name on the server.
4. No such file or directory To solve the no such file error condition, check
that the directory exists
on the server. Check the spelling of the directory on the command line or
in the /etc/vfstab file.

Use of NFS Considered Harmful


First of all usage of 'considered harmful" usually signify primitive
fundamentalist stance of the critique. Also this critique is applicable only to
older versions of protocols. NFS v.4 contains some improvements
Following are a few known problems with NFS and suggested workarounds.
a. Time Synchronization
NFS does not synchronize time between client and server, and offers no
mechanism for the client to determine what time the server thinks it is. What this
means is that a client can update a file, and have the timestamp on the file be
either some time long in the past, or even in the future, from its point of view.
While this is generally not an issue if clocks are a few seconds or even a few
minutes off, it can be confusing and misleading to humans. Of even greater
importance is the affect on programs. Programs often do not expect time
difference like this, and may end abnormally or behave strangely, as various
tasks timeout instantly, or take extraordinarily long while to timeout.
Poor time synchronization also makes debugging problems difficult, because
there is no easy way to establish a chronology of events. This is especially
problematic when investigating security issues, such as break in attempts.
Workaround: Use the Network Time Protocol (NTP) religiously. Use of NTP can
result in machines that have extremely small time differences.
Note: The NFS protocol version 3 does have support for the client specifying the
time when updating a file, but this is not widely implemented. Additionally, it does
not help in the case where two clients are accessing the same file from machines
with drifting clocks.
b. File Locking Semantics
Programs use file locking to insure that concurrent access to files does not occur
except when guaranteed to be safe. This prevents data corruption, and allows
handshaking between cooperative processes.
In Unix, the kernel handles file locking. This is required so that if a program is
terminated, any locks that it has are released. It also allows the operations to be
atomic, meaning that a lock cannot be obtained by multiple processes.
Because NFS is stateless, there is no way for the server to keep track of file
locks - it simply does not know what clients there are or what files they are using.
In an effort to solve this, a separate server, the lock daemon, was added.
Typically, each NFS server will run a lock daemon.
The combination of lock daemon and NFS server yields a solution that is almost
like Unix file locking. Unfortunately, file locking is extremely slow, compared to
NFS traffic without file locking (or file locking on a local Unix disk). Of greater
concern is the behaviour of NFS locking on failure.
In the event of server failure (e.g. server reboot or lock daemon restart), all client
locks are lost. However, the clients are not informed of this, and because the

other operations (read, write, and so on) are not visibly interrupted, they have no
reliable way to prevent other clients from obtaining a lock on a file they think they
have locked.
In the event of client failure, the locks are not immediately freed. Nor is there a
timeout. If the client process terminates, the client OS kernel will notify the server,
and the lock will be freed. However, if the client system shuts down abnormally
(e.g. power failure or kernel panic), then the server will not be notified. When the
client reboots and remounts the NFS exports, the server is notified and any client
locks are freed.
If the client does not reboot, for example if a frustrated user hits the power switch
and goes home for the weekend, or if a computer has had a hardware failure and
must wait for replacement parts, then the locks are never freed! In this
unfortunate scenario, the server lock daemon must be restarted, with the same
effects as a server failure.
Workaround: If possible (given program source and skill with code modification),
remove locking and insure no inconsistency occurs via other mechanisms,
possibly using atomic file creation (see below) or some other mechanism for
synchronization. Otherwise, build platforms never fail and have a staff trained on
the implications of NFS file locking failure. If NFS is used only for files that are
never accessed by more than a single client, locking is not an issue.
Note: A status monitor mechanism exists to monitor client status, and free client
locks if a client is unavailable. However, clients may chose not to use this
mechanism, and in many implementations do not.
c. File Locking API
In Unix, there are two flavours of file locking, flock() from BSD and lockf() from
System V. It varies from system to system which of these mechanisms work with
NFS. In Solaris, Sun's Unix variant, lockf() works with NFS, and flock() is
implemented via lockf(). On other systems, the results are less consistent. For
example, on some systems, lockf() is not implemented at all, and flock() does not
support NFS; while on other systems, lockf() supports NFS but flock() does not.
Regardless of the system specifics, programs often assume that if they are
unable to obtain a lock, it is because another program has the lock. This can
cause problems as programs wait for the lock to be freed. Since the reason the
lock fails is because locking is unsupported, the attempt to obtain a lock will
never work. This results in either the applications waiting forever, or aborting their
operation.
These results will also vary with the support of the server. While typically the NFS
server runs an accompanying lock daemon, this is not guaranteed.
Workaround: Upgrade to the latest versions of all operating systems, as they
usually have improved and more consistent locking support. Also, use the lock
daemon. Additionally, try to use only programs written to handle NFS locking
properly, veified either by code review or a vendor compliance statement.

d. Exclusive File Creation


In Unix, when a program creates a file, it may ask for the operation to fail if the
file already exists (as opposed to the default behaviour of using the existing file).
This allows programs to know that, for example, they have a unique file name for
a temporary file. It is also used by various daemons for locking various
operations, e.g. modifying mail folders or print queues.
Unfortunately, NFS does not properly implement this behaviour. A file creation will
sometimes return success even if the file already exists. Programs written to
work on a local file system will experience strange results when they attempt to
update a file after using file creation to lock it, only to discover another file is
modifying it (I have personally seen mailboxes with hundreds of mail messages
corrupted because of this), because it also "locked" the file via the same
mechanism.
Workaround: If possible (given program source and skill with code modification),
use the following method, as documented in the Linux open() manual page:
The solution for performing atomic file locking using a lockfile is to create a
unique file on the same fs (e.g., incorporating hostname and pid), use link(2) to
make a link to the lockfile and use stat(2) on the unique file to check if its link
count has increased to 2. Do not use the return value of the link() call.
This still leaves the issue of client failure unanswered. The suggested solution for
this is to pick a timeout value and assume if a lock is older than a certain
application-specific age that it has been abandoned.
e. Delayed Write Caching
In an effort to improve efficiency, many NFS clients cache writes. This means that
they delay sending small writes to the server, with the idea that if the client
makes another small write in a short amount of time, the client need only send a
single message to the server.
Unix servers typically cache disk writes to local disks the same way. The
difference is that Unix servers also keep track of the state of the file in the cache
memory versus the state on disk, so programs are all presented with a single
view of the file.
In NFS caching, all applications on a single client will typically see the same file
contents. However, applications accessing the file from different clients will not
see the same file for several seconds.
Workaround: It is often possible to disable client write caching. Unfortunately, this
frequently causes unacceptably slow performance, depending on the application.
(Applications that perform I/O of large chunks of data should be unaffected, but
applications that perform lots of small I/O operations will be severely punished.) If
locking is employed, applications can explicitly cooperate and flush files from the
local cache to the server, but see the previous sections on locking when
employing this solution.

f. Read Caching and File Access Time


Unix file systems typically have three times associated with a file: the time of last
modification (file creation or write), the time of last "change" (write or change of
inode information), or the time of last access (file execution or read). NFS file
systems also report this information.
NFS clients perform attribute caching for efficiency reasons. Reading small
amounts of data does not update the access time on the server. This means a
server may report a file has been unaccessed for a much longer time than is
accurate.
This can cause problems as administrators and automatic cleanup software may
delete files that have remained unused for a long time, expecting them to be
stale lock files, abandoned temporary files and so on.
Workaround: Attribute caching may be disabled on the client, but this is usually
not a good idea for performance reasons. Administrators should be trained to
understand the behaviour of NFS regarding file access time. Any programs that
rely on access time information should be modified to use another mechanism.
g. Indestructible Files
In Unix, when a file is opened, the data of that file is accessible to the process
that opened it, even if the file is deleted. The disk blocks the file uses are freed
only when the last process which has it open has closed it.
An NFS server, being stateless, has no way to know what clients have a file
open. Indeed, in NFS clients never really "open" or "close" files. So when a file is
deleted, the server merely frees the space. Woe be unto any client that was
expecting the file contents to be accessible as before, as in the Unix world!
In an effort to minimize this as much as possible, when a client deletes a file, the
operating systems checks if any process on the same client box has it open. If it
does, the client renames the file to a "hidden" file. Any read or write requests
from processes on the client that were to the now-deleted file go to the new file.
This file is named in the form .nfsXXXX, where the XXXX value is determined by
the inode of the deleted file - basically a random value. If a process (such as rm)
attempts to delete this new file from the client, it is replaced by a new .nfsXXXX
file, until the process with the file open closes it.
These files are difficult to get rid of, as the process with the file open needs to be
killed, and it is not easy to determine what that process is. These files may have
unpleasant side effects such as preventing directories from being removed.
If the server or client crashes while a .nfsXXXX file is in use, they will never be
deleted. There is no way for the server or a client to know whether a .nfsXXXX file
is currently being used by a client or not.
Workaround: One should be able to delete .nfsXXXX files from another client,
however if a process writes to the file, it will be created at that time. It would be
best to exit or kill processes using an NFS file before deleting it. Unfortunately,
there is no way to know if an uncooperative process has a file open.

h. User and Group Names and Numbers


NFS uses user and group numbers, rather than names. This means that each
machine that accesses an NFS export needs (or at least should) have the same
user and group identifiers as the NFS export has. Note that this problem is not
unique to NFS, and also applies, for instance, to removable media and archives.
It is most frequently an issue with NFS, however.
Workaround: Either the /etc/passwd and /etc/group files must be synchronized, or
something like NIS needs to be used for this purpose.
i. Superuser Account
NFS has special handling of the superuser account (also known as the root
account). By default, the root user may not update files on an NFS mount.
Normally on a Unix system, root may do anything to any file. When an NFS drive
has been mounted, this is no longer the case. This can confuse scripts and
administrators alike.
To clarify: a normal user (for example "shane" or "billg") can update files that the
superuser ("root") cannot.
Workaround: Enable root access to specific clients for NFS exports, but only in a
trusted environment since NFS is insecure. Therefore, this does not guarantee
that unauthorized client will be unable to access the mount as root.

Backup and Recovery


Tap device type

# 8-mm Cartridge tape 40GB

4-mm DAT Cartridge tape 24GB


Tap device name

# /dev/rmt/#tn

# = Logical tape number [1, 2, 3 ..]


t

= Tape density [ l m h c u ]

n = No rewind
rmt = removable media tape
# cat /etc/dumpdates :

# Show the level of the last backup. Day, date &


time of backup

Backup :
0 9 # Backup levels v

# Verify

# Size estimate l

# Autoload

# Offline u

# Update /etc/dumpdates

# Specify the tape device name.

Backup /export/home directory in this example:


# umount /etc/home
# fsck /export/home
# ufsdump 0uf /dev/rmt/0hn /export/home (or) (destination) (source)
# ufsdump 0uf host2:/dev/rmt/0hn /export/home (remote destination) (source)

Restore :
t

# Lists the table of contents of the backup media.

# Restores the entire fs from the backup media.

# Restores only the files named on the command line

# Invokes an interactive restore.

# Specifics verbose mode

# Specifies the tape device name

restoresymtable file

# is created whenever restoring an entire file system


from a backup tape.

Restore / (root) file system in this example:


ok boot cdrom s :

# Boot single user mode

# newfs /dev/rdsk/c0t0d0s0 :

# Create new FS

# mount /dev/dsk/c0t0d0s0 /abc :

# Mount FS

# cd /abc :
# ufsrestore rf /dev/rmt/0

# restore / (root) FS

# rm restoresymtable
# cd /usr/platform/uname m/lib/fs/ufs
# installboot bootblk /dev/rdsk/c0t0d0s0

# Install the bootblk in sectors


1 15 of the boot disk
# Install boot command

# umount /abc :

# umount /abc

# fsck /dev/rdsk/c0t0d0s0 :

# Check the restored FS

# init 6
Restore /usr & /var file system in this example:
Repeat the steps above, except step 6.
Restore regular file system /export/home in this example:
# newfs /dev/rdsk/c#t#d#S#
# mount /dev/dsk/ c#t#d#S# /mnt
# cd /mnt
# ufsrestore rf /dev/rmt/#
# rm restoresymtable
# cd /
# umount /mnt
# fsck /dev/rdsk/ c#t#d#S#

Check Size of the FS:


# ufsdumo 0s fs-name : # Size of the file system backup can be
determined
(or)
# ufsdump 3s fs-name : # Size of the file system backup can be
determined
Magnetic tape control (mt):
# mt -f /dev/rmt/0 status :

# Dis. Status info. About the tape drive.

rewind :

# Rewinds the tape

offline
fsf

# Rewinds, takes the drive unit off-line by unloading the tape


:

# Forword skips count tape file.

# cat /etc/dumpdates : # Show the level of the last backup. Day, date & time
of Backup
Tar backup: (tar = tape archive) :
$ tar cvf /dev/rmt/0 .

# Backup current directory

$ tar cvf /dev/rmt/0n /etc

# Backup /etc directory

$ tar xvf /dev/rmt/0 :

# Extract all files from tape and place them


into the current directory.

tar - create tape archives and add or extract files

You might also like