Command Line Scripts

For Calculate 5th column of ls -l output:

root@vidyavathi # ls -l
total 2
-rw-r--r-- 1 root root 0 Sep 22 17:40 datadg01
drwxr-xr-x 2 root root 96 Sep 22 16:49 lost+found
-rw-r--r-- 1 root root 38 Sep 22 16:53 nila
root@vidyavathi # ls -l | ls -l | awk 'BEGIN{SUM=0} {SUM=SUM+$5} END{print "Column 5 Total =" SUM}'
Column 5 Total =134
root@vidyavathi #

Performing Boot and Shutdown Procedures

Run Levels

0 -- ok mode
s or S Solaris OE single user mode with critical FS mounted
1 -- Single user administrative state with access to all FS available
2 -- Multiuser can access the system . All sys daemons are running except NFS
3 -- Multiuser operations with NFS & N/W resource available
4 -- Reserved
5 -- Poweroff
6 -- Reboot

# who –r -- Shows current run level

Boot Sequence

1. Boot PROM phase
2. Boot program phase
3. Kernel initialization phase
4. init phase

/etc/inittab -- id(S3) rstat(3) action(wait) Contains details about init levels

/etc/vfstab /etc/inittab /etc/system -- Important Files

/etc/system -- moddir root device and root FS config exclude forceload set

-- Always make a copy of /etc/system file before you edit the same. In case of problem , issue the interactive boot command : boot –a. When prompting for system file. Enter the path of backup file for /dev/null for a null configuration file.

/etc/init.d -- Directory contains many process or services like volume management

/sbin -- Each run level has an associated rc scripts located in this directory (eg /sbin/rc0)
The RC scripts rc0, rc5 & rc6 are hard linked to each other. Run control scripts
are located in /etc/init.d directory and these files are hard-linked to corresponding run control sctipts in the .etc.rc#.d directories.


Creating New Run Control Scripts

Create the script in the /etc/init.d directory and create links in the appropriate /etc/rc#.d directory for the run level in which the service is to be started and stop.

# vi /etc/init.d/filename
# chmod 744 /etc/init.d/filename
# chgrp sys /etc/init.d/filename
# cd /etc/init.d
# ln filename /etc/rc#.d/S##filename
# ln filename /etc/rc#.d/K##filename
# /etc/init.d/filename start -- To test the filename

# init 2 -- Switch the run level to 2

# shutdown -- Will moves to maintenance mode
# shutdown –y –g300 –i6 “The system is being rebooted” -- Reboots after 300 seconds.
Default is 60 sec
# shutdown –i0 (or) i5 (or) –i6

# halt -- Shutdown the system immediately to ok prompt
# poweroff -- Equivalent to init5
# reboot -- Equivalent to init6 -- These 3 commands won’t ececute rc0 kill scripts.
# reboot -- -r -- Reconfigration reboot.

Executing Boot PROM Commands

# /usr/platform/’uname –m’/sbin/prtdiag –v -- To know the OpenBoot version

Stop+D -- Press this keys when system power is turned ON to switch to diagnostic mode
This key sequence is not available on a serial port terminal
Stop+N -- Press while the system is turned ON to set the NVRAM parameters to default
Stop+A -- To get into boot PROM

-- /etc/default/kbd - Remove the comment for the line KEYBOARD_ABORT=disable to
turn off Stop+A function inside OS. Then issue the command kbd –I


ok go -- To comeout of PROM prompt

ok banner -- Shows system configuration

ok printenv -- Shows all variables

ok reset-all -- Will save the changes and clear the buffer & reboot the system

ok .registers -- Displays the contents of the registers

ok show-devs -- Shows all device with physical path
ok devalias -- Shows currently available devices

 In sparc if we change values. There is no option to come out without saving.

ok probe-ide -- Shows ide details and device connected
ok probe-scsi -- Shows scsi details and device connected
ok probe-scsi-all -- Identifies devices on all all SCSI buses
ok probe-fcal-all -- Identifies devices on all fibre channel loops

ok nvalias /pci@if,......................
ok nvunalias -- To delete alias name

ok show-disks -- Desplays and allows a selection of device paths
ok show-ttys
ok show-displays
ok show-nets
ok show-tapes

ok help -- Shows list of help
ok help floppy eject
ok test -- Runs self-test on specified systems

ok sync -- Manually attempts to flush memory and synchronize FS

ok boot -- Boot the system
ok boot –r -- Detect new devices (Reconfiguration boot)
ok boot –s -- Single user mode
ok boot –v -- Verbose mode – boot the system and shows the background details
ok boot –a -- Interactive mode. Prompt user for user input for all the process at boot time
ok boot –rv (or) –sv
ok boot –x -- Boot with Non-Cluster mode
ok boot –m milestone=single-user -- Boot in single usermode (Solaris10)

ok printenv auto-boot?
auto-boot?=false
ok printenv boot-device -- To know the variable details
boot-device=disk
ok setenv auto-boot? True -- To change value to true for “auto-boot?” variable
auto-boot?=true
ok printenv diag-switch?
Diag-switch?=false
ok setenv diag-switch? True

ok set-defaults -- Reset all settings to factory default
ok setenv boot-device disk cdrom net
ok set-default boot-device -- Will reset the default value of boot-device variable

ok power-off -- Will switch off the system immediately

ok watch-net
ok watch-net-all -- Monitors ethernet packets on Interface
ok sifting -- Syntax of the command.
Inside OS

# eeprom -- Equivalent to printenv
# eeprom auto-boot
Auto-boot?=true
# eeprom auto-boot?=false
# eeprom diag-switch?=true

Managing Software Patches

Solaris9/PatchReport A summary of all patches for the solaris 9 OE release
9_Recommended.README Instruction for how to intall the recommended patch.

# showrev –p (or) # patchadd –p -- Will show installed patches

-- /var/sadm/patch - Info about all patches that are currently installed.

Patch Name 6 digit number-revision number (117753-01)

# /usr/bin/zcat 105050-01.tar.z | tar xvf -

# cd /var/tmp
# patchadd 105050-01 -- Will add patch

--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 9_Recommended
# ./install_cluster

-- /var/sadm/install_data/Solaris_9_Recommended_log

Package Administrtaion

/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_9/Product | more -- To view info about pkg in CD

# pkgadd –d /cdrom/cdrom0/Solaris_9/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 diles that make up a package

# pkgrm SUNWzip -- Will remove the SUNWzip package


# pkgadd –d /cdrom/cdrom0/Solaris_9/Product –s spool SUNWzip
It will dump the SUNWzip package to /var/spool/pkg folder. Alternate path can be given instead of spool like /pkg etc.,

# pkgrm –s spool SUNWman -- Will delete the dumped SUNWman package from spool directory

# admintool & -- Tool (GUI) used to add users, printers, groups, softwares etc.,
# prodreg & -- Tool (GUI) to view installed packages as well as to install & uninstall packages.

Mounts & Unmounts

# mount -- Lists all of the mounted FS in the /etc/mnttab file

VFSTAB -- Virtual File System Tab /etc/vfstab
device to mount device to fsck mount point FS type fsck pass mount at boot mount options

-- /etc/mnttab file is an mntfs file that provides read-only info about mounted FS on the local host

-- The /etc/vfstab file lists all the FS to be automatically mounted at system boot time, with the exception of the /etc/mnttab and /var/run FS

# mount /dev/dsk/c0t0d0s7 /export/home

Mount Options : read/write, setuid, intr, nologging and largefiles, xattr and onerror.

# mount –o option,option,… device_name mount_point
# mount -o ro /dev/dsk/c0d0s7 /p3 -- Mount the partition read only.
# mount –o ro,nosuid /dev/dsk/c0t0d0s7 /export/home -- Prohibit execution of setuid pgm.

In solaris 2GB is the large file limit. Use of nolargefiles option fails if the FS to be mounted contains large files.

# mount -o nolargefiles,noatime /dev/dsk/c0d0s7 /p3
nolargefiles -- Won’t allow large files in this partition
noatime -- Modification time stamp won’t get updated.

# mountall -- Mounted local FS listed in the /etc/vfstab file
# mountall –l -- If any FS has entry in the fsck pass field as – or 0 then it will get mounted without fsck checking. Otherwise fsck carried out before mounting

# fstype /dev/rdsk/c0t0d0s7 -- To know the FS type

# mount –F hsfs –o ro /dev/dsk/c0t6d0s0 /cdrom -- To mount CD-Drive
# mount –F pcfs /dev/diskette /pcfs

# umount /export/home or umount /dev/dsk/c0t0d0s7
# umountall -- Will unmount local FS listed in /etc/mnttab except /, /usr, /proc, /dev/fd, /var, /var/run & /tmp
# umountall –l -- To verify the FS listed in the /etc/mnttab

# fuser –c /p3 -- Will show the process running on the partition
# fuser –ck /p3 -- Will kill the user processes

# umount –f /p3 -- Force the partition to unmount

# TERM=sun
# export TERM -- Executes this 2 command to enable the VI editor to work properly

# ps –ef | grep vold
Vold is the daemon taking care of auto mounting CD-Rom.

# volcheck -- Will check any media present in CD-Rom or Floppy drive

# /floppy/floppy0 -- Floppy get mounted here automatically
# /cdrom/cdrom0 -- CD-Rom get mounted here automatically

# /etc/init.d/volmgt stop (or) start

# eject cdrom -- Will eject the CD-Rom if the vold is running

# fdformat –t dos /dev/rdiskette -- To format a floppy with DOS mode

# fdformat -- To format the floppy in Solaris Format.

Managing the Solaris OE File System

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 mntfs

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 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
# fsck -o f,p /dev/rdsk/c0t0d0s7 -- f - forces p - preen or Non interactive mode
# fsck -y /dev/rdsk/c0t0d0s7 -- It answers that to all questions we said yes with -y option
# newfs -N /dev/rdsk/c0t0d0s7 -- To view the locations of alternative backup superblocks
# fsck -o b=32 /dev/rdsk/c0t0d0s7 -- Will retrieve the corrupted partition.
# dd if=/dev/zero of=/dev/rdsk/c0d0s7 bs=512 count=32 -- It will corrupt the partition
# df -- Shows disk detail in blocks# df -k (in KB) # df -h -- Displays disk allocation in MB & GB# df -e -- Points only the number of files free
# du -k -- Displays disk use in KB# du -s -- Displays only the summary in 512 bytes blocks. Using the s and k options together shows summary in KB# du -h /opt -- Shows the disk usage by the directory
# quot -a -- Reports on all mounted file systems# quot -f -- Include the number of files# quot -h /export/home -- Shows disk usage userwise in the particular directory

Managing Local Disk Devices

Disk Slices

0 / 1 swap 2 Entire Disk 5 /opt 6 /usr 7 /export/home

/dev – Logical Device Names /devices – Physical Device Names

/etc/path_to_inst -- For each device, the system records its physical and instance name

# prtconf -- Shows system information including memory size

# devfsadm -- Will search and configure new devices added.
# devfsadm –c disk
# devfsadm –i
# devfsadm –v -- To print changes made to the /dev and /devices directory
# devfsadm –c -- To invoke cleanup routines that remove unreferenced symbolic links for devices


# format
Format> label -- To store partition details.
Format> fdisk -- To create partitions
Format> verify -- Display partition details
Format> partition -- To get into partition menu
Format> save -- Saving new disk and partition :/etc/format.dat
Partition> 0 -- Change 0 partition
select -- Select a predefined table
modify -- Modify a predefined partition table
name -- Name the current table
print -- Displays the current table
label -- Write partition map and label to the disk

# prtvtoc /dev/rdsk/c1t0d0s2 -- To view disk table
# prtvtoc /dev/rdsk/c1d0s2 > /in -- To save disk partition details to /in file

# fmthard –s /in /dev/rdsk/c1d0s2 -- To load partition detail from file to disk

Introducing the Solaris OE Directory Hirerarchy

- /bin Symbolic link to /usr/bin contains binary files of standard system commands
- /kernel Platform independent lodable kernel modules
- /platform Platform dependable lodable kernel modules
- /sbin Single user bin directory contains essential executables
- /usr Contains programs, scripts and libraries that are used by all system users
- Unix System Resources
- /var Directory of varying files, includes temporary, logging, or status files

- /dev/cua Dial out device files for UUCP & PPP
- /dev/dsk Block disk devices /dev/rdsk Raw disk devices
- /dev/pts Psuedo terminal devices /dev/md Metadisk devices
- /dev/term Serial devices /dev/sound Audio device files
- /dev/rmt Raw magnetic tape devices

- /etc/cron.d Config info for cron utility /etc/default Default info for various prog.
- /etc/inet Config files - network services /etc/init.d Scripts to stop & start services
- /etc/lp Config info for printer /etc/nfs Config info for NFS server logging
- /etc/rc#.d Scripts for various run levels /etc/skel Default shell initialization files

- /usr/bin Standard system command /usr/sbin System administration commands
- /usr/kernel Platform independent lodable kernel module

Vethathiri Wallpaper


Vethathiri Maharishi - Wallpaper 1024 x 768

Vethathiri Wallpaper

Vethathiri Maharishi - Wallpaper 1024 x 768