Prasad Koyi

001-347-349-KOYI (5694)

Solaris

AI server
————-
IPS repository
——————–
#zpool list
rpool
solrepo
#df -h /solrepo
#zfs set atime=off solrepo
#pkgrepo create /solrepo

— copy below files in to /var/tmp

sol-11_1-repo-full.iso-a
sol-11_1-repo-full.iso-b

— validate download using “digest”

#digest -a mds sol-11_1-repo-full.iso-a
#digest -a mds sol-11_1-repo-full.iso-b

— combine iso files

cat sol-11_1-repo-full.iso-a sol-11_1-repo-full.iso-b > sol-11_1-repo-full.iso

— mount iso file

#mount -f hsfs /solrepo/sol-11_1-repo-full.iso /mnt
#rsync -aP /mnt/repo /solrepo/
#umount /mnt

— build search index

#pkgrepo -s /solrepo refresh

— publish origin

#cd /var/tmp
#pkg set-publisher -G ‘*’ -M ‘*” -g /solarepo solaris

— configure repository

#svccfg -s application/pkg/server setprop pkg/inst_root=/solrepo
#svccfg -s application/pkg/server setprop pkg/readonly=true

–check your work

#svcprop -p pkg/inst_root application/pkg/server

— start pkg service

#svcadm -refresh application/pkg/server
#svcadm enable application/pkg/server

— verify packages on repo

#pkg list -g /solrepo |grep -i vrts

— set repo with http service

#pkg publisher

#pkg set-publisher -O http://192.168.2.31 solaris

— enable DNS multi cast

#svcadm enable dns/multicast
#svcs dns/multicast

— check IP

#ipadm
#getent netmasks 192.168.2.0

#vi /etc/netmasks — add netmask if no output

#netstat -rn

#nslookup <hostname>

————
Install AI server pkgs
————

#pkg install install/installadm

#pkg list |grep install/installadm

#installadm create-service -n <servicename> -p solaris=http://192.168.2.31/ -i 192.168.2.51 -c 1

* solaris=http://192.168.2.31/ — repository
* 192.168.2.51 — PXE client
* -c 1 — only one IP allocated to client

— verify installer service

#installadm list
#installadm list -m — manifest details

— add the client MAC address

#installadm list -c — clients details
#installadm create-client -e <MAC> -n <service>

#cat /etc/inet/dhcpd4.conf |tail -10

host 000C29C44245 {
hardware ethernet 00:0C:29:C4:42:45;
if option arch = 00:00 {
filename “01000C29C44245.bios”;
} else if option arch = 00:07 {
filename “01000C29C44245.uefi”;
}
}

— verify

#installadm list -c

— verify below services online

#svcs -a |egrep “dhcp/server:ipv4|install/server:default”

— update default manifest

#installadm export -n <service> -m orig_default > /root/orig_default1.xml

#vi /root/orig_default1.xml

origin name=”http://192.168.2.31&#8243; ( from origin name=”http://pkg.oracle.com/solaris/release&#8221;)

#installadm update-manifest -n <service> -m orig_default -f /root/orig_default1.xml

———
on the client machine

ok boot net:dhcp – install

— select AI install ( loads kernal, boot archive, OS)
————————————————————————-
jump start
—————————————————————————

Get the mac address of the client.

login into the jumpstart server:

(files check, profiles1,rules, sysidcfg)

1. mkdir /jump /conf
2. copy the Solaris image
> cd /cdrom/cdrom0/solaris10/Tools
> ./setup_install_server /jump

3. edit /etd/hosts file — add ip of client
4. edit /etc/ethers file — add mac of client

create profiles1,rules, sysidcfg

5. create rules — add client info

6. edit sysidcfg — modify password etc
7. create profile1 disk structure

8. edit /etc/dfs/dfstab (share install path and conf
9. restart nfs server

copy check file in to /conf

run ./check

you will see profiles1,rules, sysidcfg,rules.ok,check files

10 go to imgae (/jump/Solaris10/Misc
./add_install_client -c serverIP:/conf -p serverIP:/conf clientname i86pc

(make sure rarp, bootparams are proper and up and running).

11.run snoop command to check network is established or nnot
login in to client console and check progress.

————————————————————————————————————-

Oracle solaris 11 virtualization
————————————————————————————————————-

zfs create -o mount=/zones rpool/zones — create mount point
zfs list rpool/zones

dladm create-vnic -l net0 vnic1

create zone:
————–
#zonecfg -z zone1
>create
>set zonepath=/zone/zone1
>add net
>set physical=vinc1
>end
>exit

#zoneadm list -cv

create profile for zone:
————————-
sysconfig create-profile -o zone1-profile.xml

popup GUI

F2 — name — network — IP — DNS — LDAP – timezome – rootpassword — usr etc

Install Zone
————
zoneadm -z zone1 install -c /root/zone1-profile.xml

zoneadm list -cv

boot zone
———
zoneadm -z zone1 boot
zoneadm list -cv

login
——
zlogin -C zone1 (zuser/password) (we can’t login as root in to zone)

ipadm — check IP

su – –> switch to root

# ps -ef|less

Install some thing on zone:
———————————————–

apache web server

#pkg install apache-22
#svcadm enable apache22
#svcs apache22

open web browser (ip) verify

#vi /var/apache2/2.2/htdocs/index.html

————————————————-
~. — exit from zone console
clone zone
———–
From global zone:

1. shutdown zone1 — zoneadm -z zone1 halt
2. create VNIC and configure zone2
— create Zone
— create profile
— clone — zoneadm -z zone2 clone -c /root/zone2-profile.xml zone1
— boot zone2

#zlogin zone2
#ipadm
#svcs apache22
–goto browser and verify (put zone2 IP after changing IP in index.html file)

craete cloud:
—————–

1. start zone 1

#zonestat 2– stats
—————————————————————————————————————-

ZFS
—————————————————————————————————————-

Zpool, ZFS — 2 terms

craete pool
————

1.format — check disks

2.zpool create java1 c0 c1 c2
3.zpool status

4.df -k (you can check)

zfs list
zfs create java1/home

vdevs — one or more physical devs

files from — vdevs

raidz1/2 — like raid 5 /6

logs: ZIL Slog,typycally SSD.
Cache:L2ARC (read cache) typycally SSD.

————————————-

dynamic RAID,mirror,raidz1 (raid5),raidz2 (raid 6- dual parity)

#zpool create mypool disk1 disk2 disk3 — dynamic RAID

#zpool create mypool mirror disk1 disk2 mirror disk3 disk4 — RAID1+0

#zpool create mypool mirror disk1 disk2
mirror disk3 disk4
raidz disk5 disk6 disk7 disk8
log disk9
cache disk10
spare disk11 disk12 — ( hybrid pool 1/1/5+0)

note: disk1,2,3,4 are vdevs.

# File (Min 128MB) can be used instead of physical disks.

play with pools:
——————

zpool create java raidz c0t0d0 c1t0d0 c2t0d0 mirror c4t0d0 c5t0d0

zpool java

create vdev
————–
cd /vdev

mkfile 256m vdev1
mkfile 256m vdev2
mkfile 256m vdev3
mkfile 256m vdev4
mkfile 256m vdev5

zpool create java raidz /vdev/file1 /vdev/file2 /vdev/file3 mirror /vdev/file4 /vdev/file5
scrub:
—–
*zpool scrub should run periodically (through cron, run weekly).
*pools can be imported and expoterted.during boot pools will be exported.
*a device rebuild is known as a resilver.

#zpool replace <old> <new>
#zpool online <dev> or zpool offline <dev>
#zpool attach or zpool detach — you can add or remove from redundant group (mirror).

growing zpool
————-

zpool add mypool mirror c6t0d0 c7t0do

zpool add mypool spare c6t0d0 c7t0do

zpool add mypool log c6t0d0

zpool add mypool raidz2 c6t0d0 c7t0do c8t0d0 ( you can’t shrink pool)

zpool add <vdev>

zpool properties:

#zpool get all <pool>

(size, used,availa etc)
deligation
ACL’s
mod is wait
snapshots — on
auto replace — off (this should be on for spare replace).
health

#zpool history <zpool> — will display all transactions.

* zfs reserves 1/64 of pool size
* raidz1 — 1 drive
* raidz2 — 2 drives

dynamic — 4 *100GB — 400/1.016 ~ 390GB
raidz1 — — 4 *100GB — 300GB = 295GB
raidz2 — — 4 *100GB — 200GB = 195GB

mirror and raidz1/2 disks size should be same.

————————————————————————————————————-

Data sets

————————————————————————————————————-

create data set:

* File system data set:
* stubs: like home directories
* mount: pool/ds/name
* zvol /dev/zvol/rdsk/pool/ds

you can use iscsi non-zfs local FS such as UFS,ext2,xfs etcc
you can create sparse known as thin provisioning (disk is not allocated until it required)
properties: (native read, native read/write, user properties(custom)

#zfs create mypool/dataset
#zfs get all <dataset>
#zfs set key=value pool/ds

play:
————————————————————–

#zfs list — show all Data Sets

—– prasad (DS name)

#touch file1

#zfs create prasad=/home (prasad from zfs lis)
#zfs list
#zfs get all prasad

(128k is default block size).sharenfs,mount and you can change block size too..
atime — access time.
reference quota
primary cache (metadata)
secondary cache (pool cache device)

#zfs set atime=off prasad

——————————————————————-

snapshots:
———

* point intime copy of data set
* roll back (once roll back all data sets destroyed)
* @symbol create
* mount point is hidden

clone Data set:
—————-

*clone turns a snapshot in to separate read-write data set.
* clone acts as normal data set, no disk space.

play:
————-
zfs create prasad=/home/fil1
zfs create prasad=/home/fil2
zfs create prasad=/home/fil3
zfs create prasad=/home/fil4
zfs create prasad=/home/fil5
zfs list

#zfs set set=100mb prasad=/home
#zfs list
#zfs snapshot prasad=/home/fil1
#zfs list

replication:
————–

#zfs send pool/ds@123 | ssh root@sys zfs recv pool/dsbackup
share dataset using “on” on zfs

———————————————————————————————-

* you can use arc tools for memory.

* I/O requests are treated as transaction

#fsstat — virtual file system stats
#iostat — regular physical device stat.

——————————————————————————————–

LDOMS:
———————
Install LDOM software
logical domain
control domain
basic guest domain

————————–

LDOM supports: solaris 10,11 ( solaris 8 and 9 can run on zone level).

— ILOM — connect physical host

— access firmware using RJ45 socket

— root/changme (T5120)

— uname -a
— cat /etc/release

ILOM:
—–

>start /SYS (ILOM)

>start /SP/console (T5129)

>show /SP/network

>set /SP/network
open browser — update firmware

once login:

OK boot net

#psrinfo -v — processor info
Install LDOM:
————–

Make sure firmware is supported.

on solaris 10
# cd /root/
#ls
V24253-01.zip
#unzip V24253-01.zip

#cd OVM_server_sparc*

#cat REAFME file and install recommended patches

#./Install/install-ldm

#svcs -l ldmd

#ldm list
primary — all resources (control domain)

service — control services
I/o — network interfaces or PCI etc
guest — a virtual machine that uses the service provided by service domains it is manged by control domain.
create services:
—————————————————–

1. virtual disks

#ldm add-vds primary-vds0 primary

2. virtual console

#ldm add-vcc port-range=5000-5100 primary-vcc0 primary

3.virtual switch

#ldm add-vsw net-dev=e1000g0 primary-vsw0 primary

4.display all

#ldm list-services
craete control domain:
————————
one MAU
one CPU
2GB RAM

#ldm list-bindings

#ldm list-bindings > /root/initial_bindings.txt

#ldm set-mau 1 primary
#ldm set-vcpu 8 primary
#ldm start-reconf primary
#ldm set-memory 2G primary
#reboot
#ldm list-bindings primary

virtual n/w config:

#svcadm enable vntsd

#dladm show-link
#ifconfig e1000g0 down
#ifconfig e1000g0 unplumb

#ifconfig vsw0 plumb
#ifconfig vsw0 up
#ifconfig -a
#mv /etc/hostname.e1000g0 /etc/hostname.vsw0

#ldm ls -o network primary — display info

save ldm config using “ldm add-config primary-initial”

guest domain:
——————–

#ldm list-devices

#zpool status
#zfs list
#zfs create rpool/ldomvols
#zfs create -s -V 100g rpool/ldomvols/goldvol
#ldm add-vdsdev /dev/zvol/dsk/rpool/ldomvols/goldvol golddisk@primary-vds0

#ldm add-domain prasad
#ldm add-mau 1 prasad
#ldm add-vcpu 8 prasad
#ldm add-memory 3G prasda
#ldm add-vnet vnet0 primary-vsw0 prasad
#ldm add-vidk prasaddisk1 golddisk@primary-vds0 prasad
#ldm set-var auto-boot\?=true
#ldm set-vat boot-device=prasaddisk1 prasad
#ldm bind-domain prasad

#ldm list-bindings prasad

#ldm start prasad
#ldm list

login into LDOM (guest domain):

#telnet localhost 5000

[0] OK show-disks

[0] OK boot net

install OS:
—————–
#ldm list-devices

#ldm list

#telnet localhost 5000

[0] OK show-disks

[0] OK

features from T3-2 series.

* multi pathing (evem I/O domain failed)
* IPMP
—————————————————————————————-
IPMP
—————————————————————————————-

in.mpathd
/etc/default/mpathd
#ipmpstat

IPMP route:
———-
#netstat -rn
#route -p delete default gateway -ifp interface
#route -p add default gateway
#netstat -rn

#svcadm restart routing-setup

example:
# netstat -nr
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
————- ———— ——– —– ———– ——–
default 10.153.125.1 UG 107 176682262 net0
10.153.125.0 10.153.125.222 U 22 137738792 net0

# route -p delete default 10.153.125.1 -ifp net0
# route -p add default 10.153.125.1

# netstat -nr
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
————- ———— ——– —– ———– ——–
default 10.153.125.1 UG 107 176682262
10.153.125.0 10.153.125.222 U 22 137738792 net0

Plan:
——
— each NIc should have uniq MAC
–same set of stream module (check using

#ifconfig net0 modlist

–push the modules of each interface in the standard order

#ifconfig net0 modinsert vpnmod@3

–use same IP address format
— determine type of failure
— ensure all interfaces in IPMP group are connected to same local network.

how to configure:
——————-
# ipadm create-ipmp ipmp-interface
# ipadm create-ip under-interface
# ipadm add-ipmp -i under-interface1 [-i under-interface2 …] ipmp-interface
———————–
example:

# ipadm create-ipmp ipmp0
# ipadm create-ip net0
# ipadm create-ip net1
# ipadm create-ip net2

# ipadm add-ipmp -i net0 -i net1 -i net2 ipmp0
———————-

active active IPMP group
———————–

# ipadm create-ipmp ipmp-interface
# ipadm create-ip under-interface
# ipadm add-ipmp -i under-interface1 [-i under-interface2 …] ipmp-interface

# ipadm create-addr -a address ipmp-interface ( if you want to add another IP)
# ipadm create-addr -a address under-interface1 ( on failure of existing one)

# ipadm set-ifprop -p standby=on under-interface ( set properties)

————————-
# ipmpstat -g — display status
# ipmpstat -t — display details

————————————————————————–
VLAN’s
—————————————————————————-

#dladm show-link

#dladm create-vlan -l link -v vid <vlan-name>

#dladm show-vlan

# ipadm create-ip interface

——–

— combine link agrregate

# ipadm show-if
# ipadm delete-ip net0
# ipadm delete-ip net1
# ipadm delete-ip net2
# ipadm delete-ip net3

# dladm create-aggr -P L2,L3 -l net0 -l net1 -l net2 -l net3 default0

# dladm show-link

# dladm create-vlan -v 2 -l default0 orange0
# dladm create-vlan -v 3 -l default0 green0
# dladm create-vlan -v 4 -l default0 blue0
# dladm create-vlan -v 5 -l default0 white0
# dladm create-vlan -v 6 -l default0 yellow0
# dladm create-vlan -v 7 -l default0 red0
# dladm create-vlan -v 8 -l default0 cyan0

# dladm show-vlan
LINK VID OVER FLAGS
orange0 2 default0 —–
green0 3 default0 —–
blue0 4 default0 —–
white0 5 default0 —–
yellow0 6 default0 —–
red0 7 default0 —–
cyan0 8 default0 —–

# ipadm create-ip orange0
# ipadm create-ip green0
# ipadm create-ip blue0
# ipadm create-ip white0
# ipadm create-ip yellow0
# ipadm create-ip red0
# ipadm create-ip cyan0

# ipadm create-addr -a address orange0
# ipadm create-addr -a address green0
# ipadm create-addr -a address blue0
# ipadm create-addr -a address white0
# ipadm create-addr -a address yellow0
# ipadm create-addr -a address red0
# ipadm create-addr -a address cyan0

————————————————————————–

how to install OS on guest domain using DVD:
——————————————
— stop vol mgmt daemon

#svcadm disable volfs

— unbind guest domain

#ldm stop Gdomain
#ldm unbind Gdomain

— add DVD

#ldm add-vdsdev /dev/dsk/c0t0d0s2 dvd_vol@primary-vds0
# ldm add-vdisk vdisk_cd_media dvd_vol@primary-vds0 Gdomain

# ldm list-bindings

— bind guest domain

# ldm bind Gdomain
# ldm start Gdomain

login in to guest domain

telnet local 5000

OK devaliases
ok boot vdisk_cd_media:f

————————————————————
Oracle RAC 11g install
————————————————————

1. Create OS groups using the command below. Enter these commands as the ‘root’ user:

#/usr/sbin/groupadd -g 501 oinstall
#/usr/sbin/groupadd -g 502 dba
#/usr/sbin/groupadd -g 503 oper
#/usr/sbin/groupadd -g 504 asmadmin
#/usr/sbin/groupadd -g 506 asmdba
#/usr/sbin/groupadd -g 507 asmoper

2. Create the users that will own the Oracle software using the commands:

#/usr/sbin/useradd -u 501 -c “Oracle Grid Infrastructure Owner” -g oinstall -G asmadmin,asmdba,asmoper grid
#/usr/sbin/useradd -u 502 -c “Oracle RDBMS Owner” -g oinstall -G dba,oper,asmdba oracle

# passwd grid
#passwd oracle

3. Configuring Kernel Parameter:

—kernel parameter settings to /etc/sysctl.conf.

kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6553600
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

#/sbin/sysctl -p

— repeat above kernal steps on all cluster nodes.

— change shell limits.( lines to the /etc/security/limits.conf file:)

grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

— Add or edit the following line in the /etc/pam.d/login file, if it does not already exist:

session required pam_limits.so

— Make the following changes to the default shell startup file, add the following lines to the /etc/profile

if [[ $USER = “oracle” ] || [ $USER = “grid” ]]; then
if [ $SHELL = “/bin/ksh” ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
————————-

Creating the directories.
———————————–

1. Create the Oracle Inventory Director:

To create the Oracle Inventory directory, enter the following commands as the root user:

# mkdir -p /u01/app/oraInventory
# chown -R grid:oinstall /u01/app/oraInventory
# chmod -R 775 /u01/app/oraInventory

2.Creating the Oracle Grid Infrastructure Home Directory:

# mkdir -p /u01/11.2.0/grid
# chown -R grid:oinstall /u01/11.2.0/grid
# chmod -R 775 /u01/11.2.0/grid

3.Creating the Oracle Base Directory

To create the Oracle Base directory, enter the following commands as the root user:

# mkdir -p /u01/app/oracle
# mkdir /u01/app/oracle/cfgtoollogs #needed to ensure that dbca is able to run after the rdbms installation.
# chown -R oracle:oinstall /u01/app/oracle
# chmod -R 775 /u01/app/oracle

4. Creating the Oracle RDBMS Home Directory

To create the Oracle RDBMS Home directory, enter the following commands as the root user:

# mkdir -p /u01/app/oracle/product/11.2.0/db_1
# chown -R oracle:oinstall /u01/app/oracle/product/11.2.0/db_1
# chmod -R 775 /u01/app/oracle/product/11.2.0/db_1

Check OS Software Requirements

The OUI will check for missing packages during the install and you will have the opportunity to install them at that point during the prechecks. Nevertheless
you might want to validate that all required packages have been installed prior to launching the OUI.

NOTE: These Requirements are for 64-bit versions of Oracle Enterprise Linux 5 and RedHat? Enterprise Linux 5. Requirements for other supported platforms can
be found in My Oracle Support ExtNote:169706.1.

The following command can be run on the system to list the currently installed packages:

rpm -q –qf ‘%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n’ binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
gcc \
gcc-c++ \
glibc \
glibc-common \
unixODBC-devel

————————

oracleasm-2.6.18-194.el5-2.0.5-1.el5.i686.rpm
oracleasmlib-2.0.4-1.el5.i386.rpm
oracleasm-support-2.1.7-1.el5.i386.rpm
—————————————–

once installed

login in to oracle
——————-
#sqlplus

>select instance_name,host_name from v$instance;

>conn system/manger@test.com:1521/test.com

>select instance_name,host_name from v$instance;
—————————————————————————————–

4.

——————————————————————————————————

Debugging

truss -f -p <pid of a shell>
/* Using multiple windows, this can be used to trace setuid/setgid programs */

truss executable
/* Trace doing of given command ( useful debugging ) */

Disk Commands
/bin/mount -F hsfs -o ro /dev/sr0 /cdrom
/* Mount an ISO 9660 CDROM */

/usr/bin/iostat -E
/* Command to display drives statistics */

du -ad /var | sort -nr
/* Report the the disk used in /var in reverse order */

du -k .
/* Report disk usage in Kilobytes */

du -sk * | sort -nr | head
/* Shows the top ten largest files/directories */

du -sk *|sort -k1,1n
/* Reports total disk space used in Kilobytes in present directory */

du -sk .
/* Report total disk usage in Kilobytes */

du -sk `ls -A` | sort -nr | head
/* Shows the ten largest files/directories (including hidden ones) */

mount -F hsfs -o ro `lofiadm -a /export/temp/software.iso` /mnt
/* Mount an ISO Image */

newfs -Nv /dev/rdsk/c0t0d0s1
/* To view the superfblocks available */

One-liner to copy a partition table
/* prtvtoc /dev/dsk/c1t2d0s2 | fmthard -s – /dev/rdsk/c1t3d0s2 */

prtvtoc /dev/rdsk/c0t0d0s2
/* Disk geometry and partitioning info */

prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s – /dev/rdsk/c0t1d0s2
/* Copy partition table from one disk to another */
Driver Parameters
ndd /dev/ip ip_forwarding
/* Show the ip_forwarding variable in the kernel */

ndd /dev/ip ip_forwarding 1
/* Set the ip_forwarding variable in the kernel */

ndd /dev/ip \?
/* Show all IP variables set in the kernel */

File Manipulation
bzcat mydir.tar.bz2 | tar xvf –
/* Untar and bunzip2 in a single command */

tar cvf – ./mydir | bzip2 – >> mydir.tar.bz2
/* Create ‘tar’ archive and ‘bzip2’ in a single command */

File System

cat /dev/null > filename
/* Zero’s out the file without breaking pipe */

cksum [filename]
/* View the checksum value for the given file */

dd if=/dev/rdsk/… of=/dev/rdsk/… bs=4096
/* Make a mirror image of your boot disk */

df -k | grep dg| awk ‘{print $6}’ |xargs -n 1 umount
/* Unmount all file systems in disk group dg */

fsck -F ufs -o b=97472 /dev/rdsk/c0t0d0s0
/* Check and repair a UFS filesystem on c0t0d0s0, using an alternate superblock */

fsck -F ufs -y /dev/rdsk/c0t0d0s0
/* Check a UFS filesystem on c0t0d0s0, repair any problems without prompting. */

fsck -F ufs /dev/rdsk/c0t0d0s0
/* Check a UFS filesystem on c0t0d0s0 */

gzip -d -c tarball.tgz | (cd /[dir];tar xf – ) &
/* Unpacking tarballs to diff location */

ln [-fhns] <source file> <destination file>
/* Creating hard links and soft links */

ls -1d [directory]/*
/* List only subdirectories – 1 per line */

ls -al | awk ‘$3 == “oracle” || $3 == “root” {print $9}’
/* List all file names by testing owner */

ls -l | sort +4n
/* List files by size */

ls -la | awk ‘{ print $5,” “,$9 }’ | sort -rn
/* File sizes of current directory */

ls -lR | awk ‘{total +=$5};END {print “Total size: ” total/1024/1024 “MB” }’
/* Recursive directory size calculations in MB */

mkisofs -l -L -r -o [image-name].iso [directory]
/* Create an ISO image of a directory */

mount -F ufs -o rw,remount /
/* Used to remount root to make it writeable */

mount -o remount,logging /spare
/* Re-mount the ro file system rw and turn on ufs logging */

mount DOS fdisk partition from Solaris
/* mount -f pcfs /dev/dsk/c0d0p1 /export/dos */

mv [filename]{,.new_suffix}
/* Renaming file */

tail -f <path to file>
/* Follow updates to a file in real time */

tar cf – . | (cd /newdir ; tar xf -)
/* Recursively copy files and their permissions */

tar cvf filename.tar
/* Create a tape (tar) archive */

tar xvf filename.tar
/* Extract a tape (tar) archive */

File Transfer
find . -depth | cpio -pdmv /path/tobe/copied/to
/* Fast alternative to cp -pr */

find . -follow | cpio -pdumL /path/tobe/copied/to
/* Copy with symbolic links to be followed */

General

mailx -H -u <username>
/* List out mail headers for specified user */

ps -ef | grep -i $@
/* Access common commands quicker */

Hardware
cfgadm
/* Verify reconfigurable hardware resources */

prtpicl -v | grep sync-speed
/* Discover SCSI sync speed */

Kernel
/usr/sbin/modinfo
/* Display kernel module information */

/usr/sbin/modload <module>
/* Load a kernel module */

/usr/sbin/modunload -i <module id>
/* Unload a kernel module */

/usr/sbin/sysdef
/* Show system kernal tunable details */

nm -x /dev/ksyms | grep OBJ | more
/* Tuneable kernel parameters */

update_drv -f [driver name]
/* Force a driver to reread it’s .conf file without reloading the driver */

Memory
pagesize -a
/* Available page sizes for Solaris 9 */

prtconf | grep Mem
/* Display Memory Size of the local machine. */

Network Information
arp -a
/* Ethernet address arp table */

arp -d myhost
/* Delete an ethernet address arp table entry */

ndd /dev/arp arp_cache_report
/* Prints ARP table in cache with IP and MAC address */

netstat -a | grep EST | wc -l
/* Displays number active established connections to the localhost */

netstat -a | more
/* Show the state of all the sockets on a machine */

netstat -i
/* Show the state of the interfaces used for TCP/IP traffice */

netstat -k hme0
/* Undocumented netstat command */

netstat -np
/* Similar to arp -a without name resolution */

netstat -r
/* Show the state of the network routing table for TCP/IP traffic */

netstat -rn
/* Displays routing information but bypasses hostname lookup. */

snoop -S -ta [machine]
/* Snoop for network packets and get size and time stamp entries. */

traceroute <ipaddress>
/* Follow the route to the ipaddress */

Network Tuning
/sbin/ifconfig hme0:1 inet 10.210.xx.xxx netmask 255.255.0.0 broadcast 10.210.xxx.xxx
/* Virtual Interfaces */

/sbin/ifconfig hme0:1 up
/* Bring virtual interface up */

/usr/sbin/ndd -set /dev/hme adv_100fdx_cap 1
/* Nailling to 100Mbps */

ifconfig eth0 10.1.1.1 netmask 255.255.255.255
/* Add an Interface */

ifconfig eth0 mtu 1500
/* Change MTU of interface */

ndd -set /dev/ip ip_addrs_per_if 1-8192
/* To set more than 256 virtual ip addresses. */

ndd -set /dev/tcp tcp_recv_hiwat 65535
/* Increase TCP-receivebuffers on Sol2.5.1 systems with 100BaseTx */

ndd -set /dev/tcp tcp_xmit_hiwat 65535
/* Increase TCP-transmitbuffers on Sol2.5.1 systems with 100BaseTx */
Processes
/usr/proc/bin/ptree <pid>
/* Print the parent/child process ‘tree’ of a process */

/usr/proc/bin/pwdx <pid>
/* Print the working directory of a process */

/usr/ucb/ps -aux | more
/* Displays CPU % usage for each process in ascending order */

/usr/ucb/ps -auxww | grep <process name>
/* Gives the full listing of the process (long listing) */

coreadm -i core.%f.%p
/* Append program name and process id to core file names */

fuser -uc /var
/* Processes that are running from /var */

ipcs
/* Report inter-process communication facilities status */

kill -HUP `ps -ef | grep [p]roccess | awk ‘{print $2}’`
/* HUP any related process in one step */

lsof -i TCP:25
/* Mapping port with process */

pfiles <pid>
/* Shows processes’ current open files */

pkill -n <name>
/* Kill a process by name */

prstat -a
/* An alternative for top command */

ps -edf -o pcpu,pid,user,args
/* Nicely formatted ‘ps’ */

ps -ef | grep -i <string> | awk ‘{ print $2 }’
/* Creates list of running PID by <string> */

ps -ef | grep -i <string> | awk ‘{ print $2 }’
/* Creates list of running PID by */

ps -ef | grep <process name> | grep -v grep | cut -c 10-15 | xargs kill -9
/* Find and kill all instances of a given process */

ps -ef | more
/* Show all processes running */

ps -ef|grep -v “0:00″|more
/* Gives you a list of any process with CPU time more than 0:00 */

ps -eo pid,args
/* List processes in simplified format */

ps -fu oracle|grep pmon
/* See which instances of Oracle are running */

top -b 1
/* Returns the process utilizing the most cpu and quits */

Resource Management
/usr/bin/ldd [filename]
/* List the dynamic dependencies of executable files */

/usr/proc/bin/pmap pid
/* Report address space map a process occupies */

Route Configuration
route add net 128.50.0.0 128.50.1.6 1
/* Add a route to the routing table */

route change 128.50.0.0 128.50.1.5
/* Changes the destination address for a route */

route delete net 128.50.0.0 128.50.1.6
/* Delete a route from the routing table */

route flush
/* Flush the routing table, which will remove all entries */

route get [hostname]
/* Which interface will be used to contact hostname */

route monitor
/* Monitor routing table lookup misses and changes */

Searching Items
cat <filename> | awk ‘{if (substr($1,1,1) == ‘#’) print $0 }’
/* Print all lines in a file beginning with a specific character */

egrep “patterna|patternb” <filename>
/* Search for multiple patterns within the same file */

find <start_path> -name “<file_name>” -exec rm -rf {} \;
/* Recursively finds files by name and automatically removes them */

find . -type f -print | xargs grep -i [PATTERN]
/* Recursive grep on files */

find . ! -mtime -<days> | /usr/bin/xargs rm -rf
/* Finds and removes files older than <days> specified */

find . -exec egrep -li “str” {} \;
/* Find a string in files starting cwd */

find . -mtime -1 -type f
/* Find recently modified files */

find . -type f -exec grep “<sub-string>” {} \; -print
/* Find files (and content) containing <sub-string> within directory tree */

find . -type f -exec grep -l “<sub-string>” {} \;
/* Find files (and content) containing <sub-string> within directory tree */

find ./ \! -type f -exec ls -l {} \;|grep -v ‘^[l|p|s|-]’|grep -v ‘total’ | wc -l
/* Find number of directories under the current directory */

find / -fstype nfs -prune -o fstype autofs -prune -o -name filename -print
/* find without traversing NFS mounted file systems */

find / -mtime <# of days>
/* Find files modified during the past # of days */

find / -perm -2 -a ! -type l
/* Find files writable by ‘others’ */

find / -type f |xargs ls -s | sort -rn |more
/* List files taking up the most system space */

find / -user <username>
/* Find all files owned by <username> */

find / -xdev -type f -ls|sort -nr -k 7,7
/* Find largest files in a file system */

find / | grep [file mask]
/* Fast way to search for files */

find /proc/*/fd -links 0 -type f -size +2000 -ls
/* Find large files moved or deleted and held open by a process */

grep <full_path_to_filename> /var/sadm/install/contents| awk ‘{ print $1 ‘ ‘ $10 }’
/* Find which package contains a particular file */

ls -lR | grep <sub_string>
/* Fast alternative to find. */

pkgchk -l -p /absolute/path/todir
/* Which package does this file belong to? */

Security

find / -perm -0777 -type d -ls
/* Find all your writable directories */

find / -type f -perm -2000 -print
/* Find all SGID files */

find / -type f -perm -4000 -print
/* find all SUID files */

Setting Term Options
stty erase ^?
/* Set the delete key to delete a character */

stty erase ^H
/* Set the backspace to delete a character */

stty sane
/* Reset terminal after viewing a binary file. */

tput rmacs
/* Reset to standard char set */

Snoop
snoop -d pcelx0
/* Watch all the packets on a device */

snoop -i /tmp/mylog -o /tmp/newlog host1
/* Filter out all the host1 packets and write them to a new logfile */

snoop -i /tmp/mylog -v -p101
/* Show verbose info on packet number 101 in the logfile */

snoop -i /tmp/mylog host1 host2
/* View packets from a logfile between hosts1 and host2 */
snoop -o /tmp/mylog pcelx0
/* Save all the packets from a device to a logfile */

snoop -s 120
/* Return the first 120 bytes in the packet header */

snoop -v arp
/* Capture arp broadcasts on your network */

snoop port [port-number]
/* Monitor particular port for traffic */

Swap Files
mkfile -nv 10m /export/disk1/myswap
/* Makes an empty 10 Megabyte swapfile in /export/disk */

mkfile -v 10m /export/disk1/myswap
/* Makes a 10 Megabyte swapfile in /export/disk */

Swap Space
swap -a /export/disk1/swapfile
/* Add a swap file */

swap -d /dev/dsk/c0t0d0s4
/* Delete a swap device */

swap -l
/* List the current swap devices */

swap -s
/* List the amount of swap space available */

System Configuration
/usr/sbin/eeprom auto-boot? false
/* Changes eeprom autoboot? setting without going to Ok prompt */

/usr/sbin/eeprom diag-switch? true
/* Set the system to perform diagnostics on the next reboot. */

/usr/sbin/eeprom local-mac-address?=true
/* Multiple Port Network Card Setting */

/usr/sbin/grpck
/* Check /etc/group file syntax */
/usr/sbin/pwck
/* Check /etc/passwd file syntax */

/usr/sbin/sys-unconfig
/* Clear host specific network configuration information */

/usr/sbin/useradd
/* Add a new user to the system */

drvconfig ; disks
/* Adding hot-plug disks to system */

System Information/Monitoring

/usr/sbin/eeprom
/* Show eeprom parameters */

/usr/sbin/prtconf -vp
/* Show system configuration details */

coreadm -e log
/* Report global core */
grep “\-root” /var/adm/sulog | grep -v \+ | tail -25
/* List most recent attempts to switch to superuser account. */

isainfo -bv
/* Quickly checkout if machine is in 32 or 64 bit mode */

last
/* Tells who was or still is on the system */

prtconf -pv | grep banner-name |awk -F\’ ‘ { print $2 } ‘ | head -1
/* Show actual model name of machine */

prtconf -vp | grep bootpath
/* Determine which root disk you are booted from. */

prtdiag -v
/* System Diagnostics */

prtpicl -v | grep wwn
/* A command to find persistent binding of storage */

psradm -f [processor id]
/* Take processor offline */

psrinfo | wc -l
/* Display number of processors */

sar -u
/* Report CPU Utilization */

sar [ -aA ] [ -o filename ] t [ n ]
/* Provides cumulative reports about system activity. */

showrev -p
/* Show a list of patches installed */

telnet <remote machine> 13 | grep ‘:’
/* Get the time on remote Unix machine */

uname -a
/* Displays system information */

uname -X
/* Displays system information */

vmstat 10
/* Displays summary of what the system is doing every 10 seconds */

who -b
/* Displays the date of the last system reboot. */

ypcat hosts | sort -n -t. +0 -1 +1 -2 +2 -3 +3 -4
/* Take the input of “ypcat hosts” or “cat /etc/inet/hosts” and sort by IP. */