You are on page 1of 6

Solaris Cheat Sheet

Smit:
There is no tool like smit in Solaris, server management is handled through manually
editing config files.

/tmp:
/tmp is volatile in Solaris, it uses virtual memory, if it fills the server freezes. Files in this
directory are deleted at reboot

Restart Server:
# init 6

Shutdown Server:
# init 5

Check ethernet adapters:


# ifconfig -a

Check System config:


# prtdiag -v |more

Check processes running on server:


# ps -ef

Performance checking commands:


# iostat
# mpstat
# vmstat
# top (like topaz)
# /usr/ucb/ps aux

Check filesystems:
# df -h

Find large files:


# find /var -ls -fstype ufs -xdev| sort -rn +6 | head -n 10

(this find command works on Solaris, Linux and AIX. Just change the fstype)

Or you can use du


# du -sh

Log files:
/var/adm/messages There is no function similar to errpt in Solaris you
/var/log/syslog have to search the logs (grep -i error /var/adm/messages)
Solaris Cheat Sheet

See to Solaris version:


# cat /etc/release /etc/release gives more specific OS information.
# uname -a

Change owner/group of file:


# chown user:group filename
# chgrp group filename

Change permissions of file:


# chmod 755 file
# chmod u+rwx

User and group information stored in:


/etc/passwd
/etc/group
/etc/shadow (similar to /etc/security/passwd in AIX)

Filesystems file:
/etc/vfstab (similar to /etc/filesystem in AIX)

Create a soft link:


# ln -s /file/to/be/linked linkname

Create user:
The user home directory varies on some systems (it is in different locations on servers
built by vendors) always check /etc/passwd to see where home directories are located
before building user.

The following example is building my id

UID=10126
Primary group= webdev
Secondary groups = jms and cds
Homedir= /usr/home/pstrader (-m switch automatically creates home dir)
Shell = /usr/bin/bash
Comment=User's Name

# useradd -u 10126 -g webdev -G jms,cds -d /usr/home/pstrader -m -s /usr/bin/bash -c


"Paul Strader" pstrader

Note: if you don't give the ID a password the user cannot log in.

To set (or reset) password:


# passwd pstrader
Solaris Cheat Sheet

Crontab commands:
# crontab -e
# crontab -l

Crontab allow/deny files:


/etc/cron.d/cron.allow
/etc/cron.d/cron.deny

Crontab Syntax:
minute (0-59) hour (0-23) day of the month (1-31) month of the year (1-12), day of the
week (0-6 with 0=Sunday) Command

00,30 * * * * /usr/local/bin/hsmDiskSpaceTrending.sh > /dev/null 2>&1

NFS mount nim03:/install onto Solaris server:


mount -F nfs -o vers=3 nim03:/install /mnt

How to make NFS mount persistent:


Add a tab delimited entry into the filesystem file /etc/vsftab

Here is an example on how to configure a read/write mount point:


# vi /etc/vfstab

lp-media01:/dsu3/agfa - /backup nfs - yes rw,soft

Always make the mount is soft or your server won't come up is the mount is unavailable.

Exporting an NFS filesystem:

Add and entry to /etc/dfs/dfstab

Example to share the /usr/local filesystem on a machine so server1 can mount it in


read/write mode:
share -F nfs -o rw=server1.co.ihc.com -d "comment field" /usr/local/

Then type:
# shareall

To unshared an NFS filesystem


# unshare /filesystem or # unshare all (to unshared everything)

To View shared resources:


# dfshares

Starting NFS Solaris 10:


# svcadm -v enable -r network/nfs/server
# svcadm -v enable -r network/nfs/client
Solaris Cheat Sheet

Volume/Disk Management:

Historically, Solaris didn't have a good native volume management system. There is a
new product, ZFS, that has fixed this, but none of our servers are currently running this
since it is rather new.

The previous product that Solaris shipped is called Solaris Volume Manager (formerly
called Solstice Disk Suite). Generally, I use Solaris volume manager to mirror or
concatenate disks into large volumes, and little else.

A third party product, Veritas Volume Manger, is available as provides functionality


much the same as LVM in AIX and Redhat Linux.

If there is no volume management installed you are reliant on doing the old fashion
partition your disk, create filesystems on the partitions, and mount the filesystems.

You can tell which type to volume management there is on the server (or lack of volume
management) by looking at the mounted devices.

No volume management example:


[root@lp-soadev01]# df -k
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c1t0d0s0 53912637 6160740 47212771 12% /

Veritas Volume Manager Example:


[pstrader@lp-hsmp01]$ df -k
Filesystem kbytes used avail capacity Mounted on
/dev/vx/dsk/bootdg/rootvol
54253718 47334586 6376595 89% /

Solaris Volume Manager:


[pstrader@os1ld]$ df -k
Filesystem kbytes used avail capacity Mounted on
/dev/md/dsk/d0 5170926 123812 4995405 3% /

Servers that use no Volume Management:


lp-soadev01 Since there is no volume management and
lp-soaqa01 these servers aren't attached to the SAN,
lp-soaqa02 there is no way to grow the filesystems
lp-sosprd01 on these servers.
lp-soaprd02
lpv-soastg01

Servers that use Veritas Volume Manager:


HSM Chris Killinger and Ben Barrett can add disk and grow
space on these servers

Servers that use Solaris Volume manager:


lp-miqs Both of these servers are managed by the vendor
Solaris Cheat Sheet

os1ld (AGFA) they will know how to add space.


Command line mount Example:

# mount /dev/dsk/c1t0d0s3 /var


# mount /dev/vx/dsk/bootdg/var /var
# mount /dev/md/dsk/d3 /var

FSCK:
Make sure to do the raw device and fsck multiple times until no errors reported

fsck -Y /dev/rdsk/c1t0d0s3
fsck -Y /dev/vx/rdsk/bootdg/var
fsck -Y /dev/md/rdsk/d3

FSCK vxfs filesystem type (Veritas proprietary filesystem (non-root vols) on HSM:

fsck -F vxfs -o full,nolog /dev/vx/rdsk/pcecho_dg/pcecho_vol

FSCK a vxfs Filesystem (Veritas proprietary filesystem (non-root vols) on HSM:


fsck -F vxfs -o full,nolog /dev/vx/rdsk/exampledg/vol01
pass0 - checking structural files
pass1 - checking inode sanity and blocks
pass2 - checking directory linkage
pass3 - checking reference counts
pass4 - checking resource maps
OK to clear log? (ynq)y
flush fileset headers? (ynq)y
set state to CLEAN? (ynq)y

Swap space:
List swap space:
# swap -l

Create more swap:

Create 2G file named /usr/home/swap/swap1


# mkfile 2048m /usr/home/swap/swap1

Add the swap space:


# swap -a /usr/home/swap/swap1

You will need to add this to /etc/vfstab to make it persistent (remember this is a tab
delimited file)

# vi /etc/vfstab
Solaris Cheat Sheet

swap - /usr/home/swap/swap1 tmpfs - yes -

You might also like