Common Unix Commands

Swap Information regarding the swap area
Sysinfo Display system information i.e cpu, memory, etc
Services Display, start and stop services
NFS Information on NFS i.e starting, stopping, etc
Disk Displaying disk information i.e type, serial number, etc
Kernel Modules Displaying and modifing kernel parameters
Networking Display and configuring network parameters
Patching / Packages Installing and removing patches and software packages
Accounts Setting up and removing user accounts
NTP Network Time Protocol
Log Files Location to common log files
Security Security information
Misc Other stuff i.e shutdown, timezone, run level, etc

swap

  Solaris Red Hat HP
display swap swap -l
swap -s
cat /proc/swaps (detailed)
swapon -s
swapinfo (displayed in KB)
swapinfo -m (display in Mb)
swapinfo -tm (total / Mb)
adding swap

mkfile 5m /var/swapfile
swap -a /var/swapfile

update /etc/vfstab

device:
create partition with fdisk (type 82)
file:
dd if=/dev/zero of=/var/swapfile bs=1024 count=65536

mkswap <device>|<file>
swapon <device>|<file>

update /etc/fstab

Create logical volume or filesystem

swapon <device> | -f <logical device>
swapon -p 3 <device> | -f <logical device>

update /etc/fstab

Note: -p = priority swap number
removing swap update /etc/vfstab
swap -d
swapoff <device>|<file>

Remove device or file as normal
remove entry from /etc/fstab
reboot

sysinfo

  Solaris Red Hat HP
Server type /usr/platform/`uname -i`/sbin/prtdiag -v  

model
uname -a

Hardware Info prtdiag -v
prtpicl -v [-c <class>]
prtconf -D
lspci
lsusb
 
Memory /usr/platform/`uname -i`/sbin/prtdiag -v
prtconf | grep -i mem
cat /proc/meminfo (detailed)
free -om
dmesg | grep -i physical
/usr/sam/lbin/getmem
/opt/ignite/bin/print_manifest
CPU (type, number, etc) /usr/platform/`uname -i`/sbin/prtdiag -v cat /proc/cpuinfo (detailed) /opt/ignite/bin/print_manifest
sam -> performance monitors -> system properties
Disk Drives

format
prtvtoc <device>

format -e (to convert EFI (zfs) to SMI)

fdisk -l
sfdisk -l (advanced server)
parted <device> print
partprobe <device>
ioscan -funC disk
Disk serial Number, type, etc format
iostat -En
luxadm inq <disk> (A5x00 disk arrays)
hdparm -i /dev/hda
hdparm -I /dev/hda (detailed)

cat /proc/ide/ide0/hda/model
diskinfo -v /dev/rdsk/c0t4d0 (detailed but no serial number)
/opt/ignite/bin/print_manifest (no serial number)
Disk disk partitions prtvtoc <device>

fdisk -l
sfdisk -l (advanced server)

cat /proc/partitions (very high level)

 

lifls -Clv <device>
List Raw Partitions n/a raw -qa n/a
Tune Filesystems tunefs
fstyp -v <device>
tune2fs
tune2fs -l /dev/sda1
tunefs
Kernel 32 or 64 isainfo -kv (solaris 9+)
isalist (sparc v9 will be listed first)
uname -a
uname -m
getconf -a |grep -i 'long_bit'

getconf KERNEL_BITS ( version 11)

HPUX < version 11 all 32 bit

Note: determine if system supports 64 bit
getconf HW_CPU_SUPP_BITS

Display Firmware At the OK prompt type banner boot into the BIOS (normally F2 or F12)

workstations:
reboot
enter PDC
type: IN (information menu)
type: FV (Firmware Version)

servers:

Trace system calls truss -p <pid> strace -p <pid>

download and install tusc

tusc -p <pid>

Display IRQ, IO ports and DMA n/a /proc/interrupts
/proc/ioports
/proc/dma
n/a

Services

  Solaris 10 Red Hat HP
display services

svcs -a
inetadm -l

service --status-all n/a
start services svcadm enable nfs service nfs start n/a
stop services svcadm disable nfs service nfs stop n/a
reload service svcadm refresh nfs service nfs reload n/a
restart service svcadm restart nfs service nfs restart n/a
service status svcs nfs service nfs staus n/a
service dependencies svcs -d network n/a n/a
service dependants svcs -D network n/a n/a
service logging, etc /var/svc/log
/var/svc/manifest
/lib/svc/method
n/a n/a

NFS

  Solaris Red Hat HP
NFS Daemons server: mountd, nfsd
client: statd, lockd

/etc/dfs/dfstab
/etc/dfs/sharetab
server: rpc.mountd,nfsd
client: rpc.statd, lockd
server: rpc.mountd, nfsd
client: rpc.statd, lockd

/etc/exports
display nfs shares dfshares
showmount -e localhost
showmount -e localhost showmount -e localhost
cat /etc/xtab (currently exported)
create nfs share /etc/dfs/dfstab (edit and add share)
share <path>
redhat-config-nfs (GUI)

/etc/exports (edit and add share)
/sbin/service nfs reload

/etc/rc.config.d/nfsconf (edit)
/etc/exports (edit and add share)
exportfs -a

uncreate nfs share unshare <path>
/etc/dfs/dfstab (edit and remove share)
/etc/exports (edit and remove share)
/sbin/service nfs reload
/etc/rc.config.d/nfsconf (edit)
exportfs -au (unshare all)
exportfs -u /home/vallep
/etc/exports (edit and remove share)
nfs start

/etc/init.d/nfs.server start
/etc/init.d/nfs.client start

svcadm enable nfs/server
svcadm disable nfs/server

/sbin/service nfs start /sbin/init.d/nfs.core start
/sbin/init.d/nfs.server start
/sbin/init.d/nfs.client start
nfs stop /etc/init.d/nfs.server stop
/etc/init.d/nfs.client stop
/sbin/service nfs stop /sbin/init.d/nfs.client stop
/sbin/init.d/nfs.server stop
/sbin/init.d/nfs.core stop
nfs status ps -ef|grep < nfs daemons> /sbin/service nfs status ps -ef | grep <nfs daemons>
nfs reload shareall /sbin/service nfs reload exportfs -a
nfs performanace nfsstat nfsstat nfsstat
List nfs clients that have remote mount cat /etc/rmtab   cat /etc/rmtab

Disk

  Solaris Red Hat HP
Display the boot device eeprom

cat /etc/grub.conf
cat /etc/lilo.conf

grub = grand unified boot loader
lilo = linux loader

setboot
setting the boot device setenv boot-device <device> | <alias>
eeprom boot-device <device> | <alias>

/etc/grub.conf
/etc/lilo.conf

 

setboot -p <primary path>
setboot -a <alternate path>
Creating boot device (MBR) installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk <raw-device> grub-install <raw-device>
lilo -v
mkboot
format floppy drive fdformat -v -U
volcheck -v
newfs -v /vol/disk/aliases/floppy0
floppy --probe (use device obtained below )
floppy --createrc > /etc/fd0
floppy --format /dev/fd0
mkfs /dev/fd0
n/a
mount/unmount floppy volrmmount -l floppy0
eject floppy
mount /dev/fd0 /mnt/floppy
umount /mnt/floppy
n/a
mount/unmount CDROM mount -F hsfs -o ro <device path> /cdrom/cdrom0
umount /cdrom/cdrom0

/etc/init.d/volmgr start
eject cdrom

mount -rt iso9660 /dev/cdrom /mnt/cdrom
umount /mnt/cdrom
eject cdrom

mount -rF cdfs /dev/dsk/c1t6d0 /cdrom

start: /usr/sbin/pps_mountd
pps_mount

create boot disk or recovery tape n/a mkbootdisk `uname -r` (boot diskette) recovery tape (preview)
make_tape_recovery -v -l -x inc_entire=vg00
/opt/ignite/bin/make_recovery -ACv
boot cdrom/diskette (single user) ok> boot cdrom -s linux single (at the boot prompt) enter PDC
> search
>boot p1 (cdrom)
interact with IPL? Y
ISL> hpux -is
boot into maintenace mode ok> boot -as f10 or f12 >boot pri
interact with IPL? Y
ISL> hpux -lm

Kernel Modules

  Solaris Red Hat HP
display loaded modules modinfo

cat /proc/modules (more detailed)
lsmod

Location:
/lib/modules/`uname -r`/kernel/drivers

kmadmin -k
load modules modload -p drv/st
modprobe <module>
insmod
kmadmin -L <module name>
unload modules modunload -i drv/st modprobe -r <module>
rmmod

kmadmin -U <module name>
kmadmin -u <module id>

set kernel parameters edit
/etc/system
reboot

/etc/sysctl.conf (edit and update then reboot)
sysctl -p <filename>

sysctl -w param=value

No reboot (dynamically):
echo "250 32000 100 28" > /proc/sys/kernel/sem
echo "536870912" > /proc/sys/kernel/shmmax
echo "4096" > /proc/sys/kernel/shmmni
echo "2097152" > /proc/sys/kernel/shmall
etc.............................................

kcweb (11i)
kctune (11i only)
rebuild kernel (< 11i see below)
display kernel parameters cat /etc/system
sysdef -i
ipcs -a
sysctl -a
cat /etc/sysctl.conf

cat /proc/sys/kernel/sem
cat /proc/sys/kernel/shmmax
etc...................................

ipcs -a
kctune (11i only)
sysdef
kmtune
kmsystem
/usr/sam/lbin/getkinfo -f /stand/vmunix -o /tmp/kernel.data
build kernel

edit and update file then reboot:
/etc/system

cd /usr/src/linux-2.4
edit Makefile (change EXTRAVERSION)
make mrproper
backup .config
make xconfig
make dep
make bzImage
make modules
move new kernel
make modules_install
change lilo/grub config file
reboot

cd /stand/build
/usr/lbin/sysadm/system_prep -s system
edit system file
/usr/sbin/mk_kernel -s ./system
mv /stand/system /stand/system.old
mv /stand/vmunix /stand/vmunix.old
mv /stand/build/system /stand
mv /stand/build/vmunix_test /stand/vmunix
reboot

Networking

  Solaris Red Hat HP
Basic network information (hostname, ip address) /etc/hostname.hme0 /etc/sysconfig/network /etc/rc.config.d/netconf
default router /etc/defaultrouter

edit /etc/sysconfig/network

add: GATEWAY=<IP address>

/etc/rc.config.d/netconf
Starting and stopping a network interface ifconfig qfe0 up
ifconfig qfe0 down
/sbin/ifup eth0
/sbin/ifdown eth0
ifconfig lan0 up
ifconfig lan0 down
NIC speeds or Parameters

ndd -get <device> <parm>
ndd -get dev/ip \? (list all params)

kstat hme:0

mii-tool -v
ethtool eth1
ethtool -t eth0 online

sysctl -a | grep net*

lanadmin -x

ndd -get <device> <parm>
ndd -get /dev/ip \? (list all params)

Setting NIC speed ndd -set <device> <parm> <value> (dynamically)
/etc/system (edit and update then reboot - permanent)
mii-tool -F 100baseTx-FD eth0
ethtool -s eth1 speed 100 duplex full
ndd -set <device> <parm> <value>
lanadmin -X <option> lan0
Test IPMP, Bonding

if_mpadm -d           (detach)
if_mpadm -r           (reattach)

tail /var/adm/messages

ifenslave -d bond0 eth1   (detach)
ifenslave bond0 eth1       (reattach)

cat /proc/net/bonding/bond0

 
display routing table netstat -n netstat -rn netstat -rn
displaying network interfaces prtdiag -v
ifconfig -a
ifconfig
system-config-network (GUI)
ioscan -funC lan (list hardware)
lanscan -v (list configured)
ifconfig lan0 (individual)
display MAC address ifconfig -a (as user root) ifconfig
system-config-network (GUI)
lanscan
setup DNS /etc/resolv.conf /etc/resolv.conf /etc/resolv.conf
Name service switch file (DNS client)

/etc/nsswitch.conf
/etc/resolv.conf

/etc/nsswitch.conf
/etc/host.conf
/etc/resolv.conf
/etc/nsswitch.conf
/etc/resolv.conf
Displaying network packets snoop -d <interface>

tcpdump -i <interface>

ethereal (needs to be installed)

nettl -start
nettl -status all
nettl -tn pduin pduout -e ns_ls_driver -file /var/adm/LAN
nettl -stop

use netfmt to display the trace file

Domain Name /etc/defaultdomain /etc/sysconfig/network  (GATEWAY option)  
Obtain IP Address routing route -n get <hostname> ip route get <IP address>  

Patching / Software

  Solaris Red Hat HP
display installed patches showrev -p
patchadd -p
  swlist -l patch (HP 11)
swlist -l product PH* (HP 10.x)
adding patch patchadd
patchadd -M <dir> (multiple patches)
patch -p1 <patch>

zcat patch46.gz | patch -p1

Note: -p = # of path stripping


swcopy (install patch into depot)
swinstall (install patch from depot)

Note: the swagentd daemon must be running

removing patch patchrm patch -R -p1 <patch> swremove
display installed packages pkginfo (all packages)
pkginfo -l (single package)
pkgchk -l -p <file> (file belongs)
rpm -qa (all packages)
rpm -q (single package)
rpm -qf (file belongs)
rpm -qi <package> (very detailed)
swlist -l bundle <bundle>
swlist -l product <product>
adding package pkgadd rpm -Uhv (updates/installs if not already)
rpm -ihv (install)
swinstall
removing packages pkgrm rpm -e swremove
verify package

pkginfo -l
pkginfo -p

rpm -V package swverity <fileset> (see /var/adm/sw/swagent.log)
List files in package pkgchk -l <package> | grep -i pathname rpm -ql <package> swlist -l file <product>

Accounts

  Solaris Red Hat HP
display users cat /etc/passwd
logins -x
cat /etc/passwd
system-config-users (GUI)
cat /etc/passwd
logins -x
adding a user useradd useradd
system-config-users (GUI)
useradd
sam
removing a user userdel userdel
system-config-users (GUI)
userdel
sam
modifying a user usermod usermod
system-config-users (GUI)
usermod
sam
password files /etc/passwd
/etc/shadow
/etc/passwd /etc/passwd
/tcb/files/auth/r/root (trusted system)

NTP

  Solaris Red Hat HP
Time daemons

xntpd

ntpd

netdaemons
ntp setup

Edit:
# Solaris 8
/etc/ntp.conf
/etc/ntp.server
/etc/ntp.client

# Solaris 10
/etc/inet/ntp.server
/etc/inet/ntp.client

chkconfig --list ntpd
chkconfig --level 2345 ntpd on
/etc/ntp.conf (edit with ntp servers)
/sbin/service ntpd start

dateconfig (GUI)
/etc/rc.config.d/netdaemons (set XNTPD to 1)
/etc/ntp.conf
NTP Trace commands ntpq -p
ntptrace
ntpq -p
ntptrace
 

Log Files

  Solaris Red Hat HP
messages /var/adm/messages /var/log/messages n/a
syslog /var/log/syslog n/a /var/adm/syslog/syslog.log
mail   /var/log/mail /var/adm/syslog/mail.log
cron /var/cron/log /var/log/cron /var/adm/cron/log
boot /var/adm/messages /var/log/boot /var/adm/syslog/syslog.log

Security

  Solaris Red Hat HP
Checking the passwd file pwck pwck pwck
checking the group file grpck grpck grpck
console login (allow/deny) /etc/default/login (Edit file no reboot required) /etc/securetty (no reboot) /etc/securetty (no reboot)

Misc

  Solaris Red Hat HP
startup

eeprom

setenv boot-device

grub (GUI)
lilo (text based)
setboot -p
shutdown

shutdown -i5 -g0 -y (power down)
shutdown -i6 -g0 -y (reboot)
shutdown -i0 -g0 -y (OK prompt)

reboot -- -r (reboot/reconfigure)

shutdown -h (halt)
shutdown -r (reboot)
shutdown -f (fast reboot no fsck)
shutdown -F (force fsck)
shutdown -h -y (halt)
shutdown -r -y (reboot)
init status
0
1
2
3
4
5
6

0 - shutdown
1 - single user
2 - n/a
3 - Multi-user
4 - n/a
5 - power off
6 - reboot

0 - halt
1 - single user
2 - multiuser (no networking)
3 - multiuser (networking)
4 - unused
5 - GUI
6 - reboot


0 - halt
1 - single users
2 - multiuser (no networking)
3 - multiuser (networking and GUI)
4 - multiuser (netwrking and old GUI)
5 - n/a
6 - n/a

Startup options -s single user
-a interactive
-x no device drivers (used in clustering)
-r reconfigure devices
-m milestone

linux single  
linux emergency
linux rescue

single: runlevel1, local fs mounted, no network
emergency: root fs read-only, no init files run
rescue: use cd-rom/network, root mounted as /mnt/sysimage

 
startup scripts /etc/init.d

/etc/rc0.d - /etc/rc6.d
/etc/init.d

/etc/rc0.d - /etc/rc6.d
/etc/rc.config.d

/sbin/rc0.d - /sbin/rc6.d
determine the run level who -r runlevel who -r
obtain default run level cat /etc/inittab cat /etc/inittab /etc/inittab
start xwindows n/a startx (shorthand of below)
initx (lots of parms)
n/a
force a fsck n/a touch /forcefsck
shutdown -rF now
n/a
page size (memory) /usr/bin/pagesize /usr/bin/getconf -a| egrep -i 'pagesize|page_size' 4Kb
initialize system sys-unconfig netconf set_parms initi
Timezone /etc/TIMEZONE
/etc/default/init
/etc/sysconfig/clock /etc/TIMEZONE
update /dev directory drvconfig
devlinks
disks|tapes|ports

devfsadm ( solaris 8, 9, 10)
/dev/MAKEDEV <device>

insf -C tape (Class)

insf -H 0.1.0 -e (recreate deleted link)

remove device rem_drv   rmsf
list device drivers prtconf -D cat /proc/devices lsdev
change the hostname

change the follwing four files:

/etc/nodename
/etc/hostname.<interface>
/etc/inet/hosts
/etc/inet/ipnodes

   
Device paths floppy:

disk:
/dev/dsk/c0t0d0s0

tape:
/dev/rmt/0ucb

cdrom:
/dev/dsk/c0t6d0s0

floppy:
/dev/fd0

disk:
/dev/hda or /dev/sda
/dev/hdb or /dev/sdb

tape:

cdrom:
/dev/hda (depends on number of IDE disks)

floppy:
n/a

disk:
/dev/dsk/c0t6d0

tape:
/dev/dsk/rmt/0

cdrom:
/dev/dsk/c1t6d0

Crash Dump

dumpadm -d <device>

crash (used to analyse crash dumps)
adb (used to analyse crash dumps)

diskdump
netdump
kdump (part of kexec rpm)

crash (used to analyse crash dumps)

edit /stand/system

add either:
dump 2/0/1.5.0
dump lvol
dump none

Find Services on network

Boot (jumpstart) servers:
rpcinfo -b bootparam 1

NFS servers:
rpcinfo -b mountd 1

NIS servers/slaves:
rpcinfo -b ypserv 1

Boot (jumpstart) servers:
rpcinfo -b bootparam 1

NFS servers:
rpcinfo -b mountd 1

NIS servers/slaves:
rpcinfo -b ypserv 1

Boot (jumpstart) servers:
rpcinfo -b bootparam 1

NFS servers:
rpcinfo -b mountd 1

NIS servers/slaves:
rpcinfo -b ypserv 1