You are on page 1of 19

Solaris Quick Sheet

_ All the following commands are to be run from the OBP and not

the OS. They are only valid on Sparc hardware that uses the openboot

_rmware. The eeprom command can be used from the OS to view or

set openboot _rmware variables.

Show the value of the auto-boot? Variable

printenv auto-boot?

Set the system to not auto boot

setenv auto-boot? False

Restore the system default for auto boot

set-default auto-boot?

Show the default boot device

printenv boot-device

List the actual device path for the disk device alias

devalias disk

List all openboot variables, current, and default values


Show devices seen by openboot


Show help on all OBP commands


Boot the system into single user mode from the CD ROM

boot cdrom -s
Boot the system into single user mode using the default device

boot –s

Reset the system



Install the gcc package

pkgadd -d gcc-3.4.6-sol10-sparc-local

Check to see if gcc is installed on system

pkginfo SMCgcc /or/ pkginfo | grep gcc

Remove the gcc package

pkgrm SMCgcc

Check the installation of the gcc (SMCgcc) package

pkgchk SMCgcc

Show revisions of packages on system

showrev –p

Get expected _le info and source package for a _le

pkgchk -l -p /usr/sfw/bin/gcc

Verify all packages (and _les) on the system

Display information about a package

pkgchk -l SMCgcc
Display version information about an installed package

pkginfo -x SMCgcc
List all patches on the system
showrev -p /or/ patchadd -p
List patches applied to the SUNWckr package

pkgparam SUNWckr PATCHLIST

_ smpatch and updatemanager can be used to manage system


Scan for new devices to the system


List (verbosely) all attachment points (con_gurable hardware)

cfgadm –val

List all disks on system

iostat –En

Tape unit { X = device number, n = no rewind

/dev/rmt/X n

_ The /dev directory contains links to /devices

_ (format) slice ags are:

wm { Writeable Mountable (ie: A _lesystem)

rm { ReadOnly Mountable

wu { Writeable Unmountable (ie: swap)


Show interfaces currently installed on system, speed, and duplex

dladm show-dev { (ndd can be used to adjust speed and duplex)

List network interfaces from the global zone only

ifconfig -aZ
Remove all host speci_c con_guration from the system (and restart)
_ Primary IP con_guration _les

,! IP address for interface. Alternatively use ifconfig.

,! hostname for the system. Alternatively set with hostname.

,! System domain name. (svcadm restart domain after change)

,! gateway for the system. Alternatively set with route.

,! Linked to /etc/inet/hosts. For IPv4 addresses only.

,! For IPv4 and IPv6 addresses. Should be in sync with hosts _le.

,! This is not a symlink to /etc/inet/netmasks.
Temporarily set IP address on hme0

ifconfig hme0 plumb up netmask

Temporarily create an alias on hme0 (hme0:1)

ifconfig hme0:1 plumb up netmask

Create permanent alias on hme0 interface

echo > /etc/hostname.hme0:1

Temporarily set the default route

route add default

Permanently add the same route as above

echo > /etc/defaultrouter

Turn o_ tra_c on qfe3

ifconfig qfe3 down

Disable an Ethernet device (qfe3)

ifconfig qfe3 unplumb

List statistics on all interfaces on system

netstat –i

List all open ports on system

netstat -an | grep LIST

List all open TCP connections

netstat -f inet
Continuously ping a host

ping -s

_ Use the snoop command to capture network packets

User Management
Add a user wfavorit to system (& create home dir) using default options
useradd -m wfavorit
View the default settings for the useradd command
useradd -D
Change the default useradd setting for base directory
useradd -D -b /export/home
Delete the password for user wfavorit, force new password on login
passwd -df wfavorit
List all user accounts that do not have passwords
logins -p
List _le system usage of the /zones _lesystem by user
quot /zones
Display login information for wfavorit
logins -x -l wfavorit
Change the default shell to ksh for user wfavorit
usermod -s /usr/bin/ksh wfavorit
Modify user accounts with usermod and delete accounts with userdel.
Create group accounts with groupadd, modify group accounts with
groupmod, and delete groups with groupdel.
Service Management Facility
List all services known to system and current status
svcs -a
Enable the webmin service (long FMRI)
svcadm enable svc:/application/management/webmin:default
Disable the webmin service (short name)
svcadm disable webmin
List details of the ssh(d) service
svcs -l ssh
Restart the ssh(d) service
svcadm restart ssh
Verify that the AutoFS service is running
svcs system/filesystem/autofs
Verify that the multiuser server milestone has been reached
svcs multi-user-server
Disable the telnetd service (Use -e for enable)
inetadm -d telnet
List services that the multi-user-server milestone is dependent on
svcs -d multi-user-server
List services that depend upon multi-user-server milestone
svcs -D multi-user-server
/etc/vfstab { Filesystem mount table
/var/adm/loginlog { Log of login attempts
/etc/default/* { Important default settings
/etc/system { Kernel modules and con_g
/var/adm/messages { Syslog location
/etc/auto * { Automounter con_g _les
/etc/inet/ipnodes { IPv4 & v6 host _le (read before /etc/hosts)
Inspecting the system
Find the total physical memory in system
prtconf | grep Memory
Find the openboot _rmware version
prtconf -V
List information on all processors in the system
psrinfo -v
Find the size of a disk
iostat -En (or use the format command)
Display info on dump device
List all swap devices
swap -l
Show swap usage
swap -s (Includes physical memory)
Show swap size (per device)
swap -l|grep -v swaplo|awk 'f print $1, $4/2048 "m"g'
Show swap used (per device)
swap -l|grep -v swaplo|awk 'f print $1, ($4-$5)/2048 "m"g'
Show information about a binary (bash in this example)
showrev -c /usr/bin/bash
List time of most recent reboots
last reboot


_ Force the system to look for new devices on restart

touch /reconfigure
_ Mirror root _lesystems (c0t0d0 to c0t1d0)
/, swap, /usr, and /var are on s0, s1, s3, and s4 respectively. s5
and s6 will be used for 10 meg metadb's on each disk. The steps are
shown here with multiple reboots. This is to show the di_erence
between each type of operation. Multiple reboots are not required.
. Duplicate c0t0d0's layout onto c0t1d0
prtvtoc /dev/rdsk/c0t0d0s2 | n
fmthard -s - /dev/rdsk/c0t1d0s2
. Set up two meta databases on each disk
metadb -a -f c0t1d0s5
metadb -a c0t1d0s6
metadb -a c0t0d0s5
metadb -a c0t0d0s6
Note: Multiple dbs can be put in a single slice using -c option.
. Encapsulate / on stripe 0
metainit -f d10 1 1 c0t0d0s0
metainit d0 -m d10
metaroot d0
lockfs -fa
shutdown -i6 -g0 -y
metainit d20 1 1 c0t1d0s0
metattach d0 d20
. Encapsulate /usr on stripe 3 (repeat this step for /var)
metainit -f d13 1 1 c0t0d0s3
metainit d23 1 1 c0t1d0s3
metainit d3 -m d13
vi /etc/vfstab (Put metadevices in place of slices)
shutdown -i6 -g0 -y
metattach d3 d23
. Encapsulate swap
metainit -f d11 1 1 c0t0d0s1
metainit d21 1 1 c0t1d0s1
metainit d1 -m d11
vi /etc/vfstab (Put metadevices in place of swap entry)
shutdown -i6 -g0 -y
metattach d1 d21
dumpadm -d /dev/md/dsk/d1
. Optional: Allow quorum at only 50%
vi /etc/system (Add line: set md:mirrored root flag=1)
. Setup \mirror" alias and boot-device setting in _rmware
ok nvedit
0: devalias mirror /pci@1f,0/pci@1,1/ide@3/disk@1,0
1: (Ctrl-C to exit)
ok nvstore
ok setenv use-nvramrc? true
ok setenv boot-device disk mirror
(This can also be done from the OS using the eeprom command.)
_ Restart the system
shutdown -i6 -g0 -y
_ HUP a process (myappsrv) by name
pgrep myappsrv (Use this to test your REGEX _rst)
pkill -HUP myappsrv
_ Turn on the system locator beacon (turn o_ with -f )
locator -n
_ Mount an ISO image (device /dev/lofi/1 may vary)
lofiadm -a /projects/solaris10 disk2.iso
mount -F hsfs -r /dev/lofi/1 /mnt
umount /mnt
lofiadm -d /dev/lofi/1
_ Check what _le system type is on metadevice d30
fstyp /dev/md/rdsk/d30

Sun Volume Manager

_ Steps for encapsulating root is in tasks section

List (verbose) the status of all metadevices in the system
List (tree-formatted / grep-able) the metadevices in the system
metastat -c
List each metadb, its status and device (with status descriptions)
metadb -i
Create a soft partition (d30) on the metadevice d7
metainit d30 -p d7 10G
Put a _lesystem on the above device
echo y | newfs /dev/md/rdsk/d30
Grow soft partition d30 by another 10 Gig
metattach d30 10g
Grow the _lesystem on the above device (currently mounted on /u01)
growfs -M /u01 /dev/md/rdsk/d30
Find the size of a metadevice called d10
metastat -c d10
Remove all soft partitions on meta device d7
metaclear -p d7
Remove the metadevice d7
metaclear d7
View the parameters (options) for metadevice d0
metaparam d0
Set disk d0 to read roundrobin, write parallel, and pass 1
metaparam -r roundrobin -w parallel -p 1 d0


De_ne a (simple) zpool called projects on a single stripe

zpool create projects c0t1d0s7
De_ne a mirror zpool called datapool on stripe 7 of two disks
zpool create datapool mirror c0t0d0s7 c0t1d0s7
List the zpools and usage stats
zpool list
Remove the zpool called datapool
zpool destroy -f datapool
Create the zfs heirarchy / _lesystems
zfs create datapool/home
List all zfs _lesystems
zfs list
Limit the wfavorite _lesystem to 5 Gig
zfs set quota=5G datapool/home/wfavorite

Performance Monitoring

top-like command
Show (top-like) process listing as well as top users
prstat -a
View continuous disk I/O stats, refreshed every 2 seconds
iostat -xnm 2
View continuous zfs disk I/O stats, refreshed every 2 seconds
zpool iostat -v 2
View continuous network statistics, refreshed every 2 seconds
netstat -i 2
View source of paging activities, refreshed every 2 seconds
vmstat -p 2
View per-processor statistics, refreshed every 2 seconds
mpstat 2
View continuous root (/) _lesystem stats, refreshed every 2 seconds
fsstat / 2
Create snapshot of /var _le system using /u01 as a repository location
fssnap -F ufs -o backing-store=/u01 /var
Mount the previously created snapshot on /mnt
mount -o ro /dev/fssnap/0 /mnt
Delete the snapshot (repository will remain)
fssnap -d /var


_ Change startup parameters for the NFS daemon in /etc/default/nfs

Temporarily export /src directory
share /src
Permanently export by putting share command in /etc/dfs/dfstab
List all exported _lesystems (on local system)
dfshares /or/ showmount -e
Share all _lesystems listed in /etc/dfs/dfstab
Stop sharing all _lesystems (not just those in /etc/dfs/dfstab)
List clients connected to NFS shares on this server
Soft mount the /proj directory from server paris
mount -F nfs -o intr,soft paris:/proj /proj
Show mount points on remote system called paris
showmount -e paris
Begin interactive zone con_guration for (a new) zone called \jubail"
zonecfg -z jubail
List (-v)erbose information on all (-c)on_gured zones
zoneadm list -cv
Boot the zone called \jubail"
zoneadm -z jubail boot
Delete zone and con_guration from system
zoneadm -z jubail uninstall -F
Login to the console of the jubail zone from the global zone
zlogin -C jubail (Exit from session with ~. escape sequence)
Halt the jubail zone (no shutdown scripts will be run)
zoneadm -z jubail halt
Shutdown the jubail zone from the global zone
zlogin jubail shutdown -i0 -g0 -y
List what zone you are currently in
View zone performance statistics (from global zone)
prstat -Z

_ smc is a graphical system management interface.

Additional Help
_ Visit or
Rebuild the windex database for the whatis command
catman -w
Find all instances of \system" in the man _les
whatis system
Access the man page for \system" from section 4 (and not 3c)
man -s 4 system
Find all man pages related to zfs
apropos zfs

Basic Solaris Commands

Quick Reference Card
<Ctrl-X> press <Control> key and type x
italics items to be replaced by your own
Shell Commands
passwd Change password
logout End terminal session

File Hierarchy
cd dir1 Change to directory dir1
ls List files in directory
ls -l List files in detail
mkdir dir1 Create new directory dir1
rmdir dir1 Remove directory dir1
cp f1 f2 Copy file f1 to f2
mv f1 [f2…] dir1 Move files f1 to fn to directory
mv dir1 dir2 Rename directory dir1 as dir2
rm filename Delete (remove) file filename
ln file1 name Create a hard link to file1 called
ln -s file1 name Create a soft link to file1 called
pwd Show path to current directory

Getting Help
man name Show man page for command
man -k subject Show man pages relating to
man -s# subject Show man page relating to
subject in section number #
man -s# Intro Show introductory

File types and Listing

file filename Classify the file
strings filename Show any ASCII strings in a file
cat filename Display contents of file to STDOUT
more filename Display contents of file one
screenful at a time
head filename Display first 10 lines of file
head -n filename Display first n lines of file
tail filename Display last 10 lines of file
tail -n filename Display last n lines of file
tail -f filename Recursively display last 10 lines of
cut Extract character or fields from
wc filename Count lines, words and characters
in file
diff f1 f2 Find differences between two files
diff3 f1 f2 f3 Find differences between 3 files
sort filename Sort file alphabetically by first
uniq Report or filter out repeated lines

STDIN Standard Input, typically the
STDOUT Standard Output, typically the
STDERR Standard Error, where errors are
sent. Typically the screen
comm > file Output of comm creates file
comm < file Contents of file used as input to
comm 2> filename Error messages from comm sent to
comm >> filename Output from comm appended to
cat file <<EOF Create a document called file
data… containing data
comm1 | comm2 Output from comm1 used as input
to comm2
mkfifo name Create a named pipe called name
mknod name p Create a named pipe called name

File Security
chmod mode filename
Change security settings on file
chown user [:group] filename
Change owner [and owning group] of
chgrp group filename
Change owning group of file
umask mode Set default creation permissions
Symbolic modes
Mode Meaning Mode Meaning
u user r read
g group w write
o other x execute
a all u+s setuid
= assign g+s setgid
+ add +t sticky bit
- remove
Octal modes
Base directory mode is 777. Base file mode is 666
user group other
Shell Wildcards
* Any character
? Any single character
[ ] A range of characters

Translations and Searching

tr set1 set2 Translates set1 to set2
sed Powerful text manipulation tool
grep pattern filename
Finds lines containing pattern in
grep -v pattern filename
Finds lines NOT containing
pattern in file
grep -i pattern filename
Finds all lines containing
pattern in file ignoring case
find path condition
Finds files matching condition
from path downwards
find path -inum n Finds hard links, i.e. All files with
the same i-node number
who Displays users on system
who am i Shows real user id
w Displays users on system
id Shows effective username & UID,
and group membership
look word Searches /usr/dict/words for
Regular Expressions
. Any character
^ Start of line
$ End of line
* Any number of the preceding characters
? A single character
[ ] Holds a range
[^ ] Holds a negated range
\( \) Creates a submatch
\1-9 Reference a submatch
telnet hostname [port]
Connects to host and opens a
shell. Optionally on specified port.

ftp hostname Connects to a remote host to

transfer files

ssh hostname [command ]

Makes a secure connection to
host and opens a shell.
Processes and Process Control

ps Displays processes running on a


prstat Displays iterating list of processes

by CPU usage
command & Run command in background
jobs Print list of jobs

fg [%n] Resume foreground job n

bg [%n] Resume background job n

stop %n Suspend background job n

kill [%n] Kill job n

<Ctrl-c> Interrupt process

<Ctrl-z> Suspend current process

kill n Kill process n

kill -9 n Terminate process n

<Ctrl-s> Stop screen scrolling

<Ctrl-q> Resume screen output

sleep n Sleep for n seconds

Shells and Variables

variable=value Create local variable variable

with value value

export variable Make variable an

environmental variable

unset variable Remove environment variable

set Show local variables

env Show environmental variables

alias name1 name2 Create command alias

alias Show command aliases

unalias name1 Remove command alias name1

history Display recent commands

! n Submit recent command n

set -o vi Recall commands, edit and reexecute

using vi commands

\ Escapes special character meanings

set -o emacs Recall commands, edit and re-execute

using emacs commands

Shell Initialization

/etc/profile ($HOME/.profile)
sh, bash, ksh system wide (per user) init
(system wide init has no effect in CDE environment).
/etc/.login ($HOME/.login)
csh, tcsh system wide (per user) init
(system wide init has no effect in CDE environment).
per user csh, tcsh init
(order: /etc/.login $HOME/.→ cshrc → $HOME/.login)
per user ksh init
(order: /etc/profile → $HOME/.profile → $HOME/.kshrc)
per user bash init
(order: /etc/profile → $HOME/.profile → $HOME/.bashrc)

Shell Programming

#!path/to/shell 'sh-bang' is a special string which

indicates that the path following
contains the location of the command
to run the script
Flow Control
sh;bash;ksh csh;tcsh
if [ condition ];
elif [ condition ];
if (condition)
else if (condition)
while [ condition ];
while (condition)
until until [ condition ];
Not available
for for arg in list… ;
foreach arg (list)

Disclaimer: This document is a guide and it includes no express war-

ranties to the suitability, relevance, or compatibility of its contents with
any speci_c system. Research any and all commands that you inict
upon your command line.
A book by
Mohammed Rafique