Monday, December 22, 2014

Unix Commands Cheat Sheet

Unix Commands Cheat Sheet



File related commands
  • cat , more , tail ,touch, mkdir , rm , ln , ls , chmod , cp , tar , jar , find , grep
  • ln –s <target> <symblink>
  • find <dir> –name <filename>
  • tar –cvf <tarfile> <dir>/*
  • tar –xvf <tarfile>
Redirecting stdout , stderr
  • 0 – filedescriptor for standard input
  • 1 – filedescriptor for standard output
  • 2 – filedescriptor for standard error
  • ./startWeblogic > start.out
  • ./startWeblogic > start.out 2>&1
Commands for taking Thread dump


  • nohup ./startWeblogic.sh > start.out 2>&1 &
  • ps –ef|grep startWeblogic.sh (Find processid)
  • ptree <pid> (Find the child java processid)
  • kill -3 <pid> (send SIGQUIT to java pid)
  • Look PROCESS console logfile for thread dump
Resource Utilization/Statistics
  • top
  • prstat
  • netstat
  • iostat
  • vmstat
  • df
  • du
  • swap




sysinfo

Solaris
Red Hat
Ubuntu/Debian
Server Release info
cat /etc/release
cat /etc/enterprise-release
cat /etc/redhat-release

lsb_release -a
cat /proc/version
cat /etc/lsb_release

lsb_release -a
Server type
/usr/platform/`uname -i`/sbin/prtdiag -v
dmidecode
dmidecode
Hardware Info
prtdiag -v
prtpicl -v [-c <class>]
prtconf -D
lspci
lsusb
lshal

Note: hal = hardware abstraction layer
lspci
lsusb
lshal
Operating System
uname -a
uname -a
uname -a
Memory
/usr/platform/`uname -i`/sbin/prtdiag -v
prtconf | grep -i mem
cat /proc/meminfo (detailed)
free -om

cat /proc/slabinfo
cat /proc/meminfo (detailed)
free -om

cat /proc/slabinfo
CPU (type, number, etc)
/usr/platform/`uname -i`/sbin/prtdiag -v
## display,offline,online
psrinfo
psradm -f 0 (offline)
psradm -n 0 (online)
cat /proc/cpuinfo (detailed)
cat /proc/cpuinfo (detailed)
Disk Drives
format
prtvtoc <device>

format -e (to convert EFI (zfs) to SMI)
fdisk -l
sfdisk -l (advanced server)
parted <device> print
partprobe -s <device>
fdisk -l
sfdisk -l (advanced server)
parted <device> print
partprobe <device>
Kernel File and associated directories
/kernel/genunix

/platform/sparc/kernel
/platform/i86pc/kernel
/kernel
/usr/kernel
/boot/initrd.?????.img
/boot/vmlinuz
/boot/initrd.img-?????-server
/boot/vmlinuz-????-server
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'
uname -a
uname -m
getconf -a |grep -i 'long_bit'
Display Firmware
At the OK prompt type banner
boot into the BIOS (normally F2 or F12)
boot into the BIOS (normally F2 or F12)
Display IRQ, IO ports and DMA
n/a
/proc/interrupts
/proc/ioports
/proc/dma
/proc/interrupts
/proc/ioports
/proc/dma
GUI admin tool
admintool
linuxconf
linuxconf
Memory and Swap

Solaris
Red Hat
Ubuntu/Debian
Memory
/usr/platform/`uname -i`/sbin/prtdiag -v
prtconf | grep -i mem
cat /proc/meminfo (detailed)
free -om
cat /proc/meminfo (detailed)
free -om
page size (memory)
/usr/bin/pagesize
/usr/bin/getconf -a| egrep -i 'pagesize|page_size'
/usr/bin/getconf -a| egrep -i 'pagesize|page_size'
display swap
swap -l
swap -s
cat /proc/swaps (detailed)
swapon -s
cat /proc/swaps (detailed)
swapon -s
adding swap
mkfile 5m /var/swapfile
swap -a /var/swapfile

update /etc/vfstab
device:
create partition with fdisk (type 82)
file(create 50MB swap file):
dd if=/dev/zero of=/var/swapfile bs=1024 count=50000

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

update /etc/fstab
device:
create partition with fdisk (type 82)
file(create 50MB swap file):
dd if=/dev/zero of=/var/swapfile bs=1024 count=50000

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

update /etc/fstab
removing swap
update /etc/vfstab
swap -d
swapoff <device>|<file>

Remove device or file as normal
swapoff <device>|<file>

Remove device or file as normal
Disks, Filesystems and Devices

Solaris
Red Hat
Ubuntu/Debian
Disk Drives
format
prtvtoc <device>

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

hdparm -Tt /dev/hda (speed test)

sdparm -i /dev/sdb

cat /proc/ide/ide0/hda/model
cat /proc/scsi/scsi
hdparm -i /dev/hda
hdparm -I /dev/hda (detailed)

haparm -Tt /dev/hda (speed test)

sdparm -i /dev/sdb

cat /proc/ide/ide0/hda/model
cat /proc/scsi/scsi
Disk disk partitions
prtvtoc <device>

cat /etc/vfstab
fdisk -l
sfdisk -l (advanced server)

cat /proc/partitions (very high level)
cat /etc/fstab


fdisk -l
sfdisk -l (advanced server)

cat /proc/partitions (very high level)
cat /etc/fstab
List Raw Partitions
n/a
## Old way
/etc/sysconfig/rawdevices
service rawdevices start
chkconfig rawdevices on

## New way, Edit below file
/etc/udev/rules.d/60-raw.rules
udevinfo -d

## Display raw partitions
raw -qa
mknod /dev/rawctl c 162 0
mknod /dev/raw/raw0 c 162 1
mknod /dev/raw/raw1 c 162 2
ln -s /dev/rawctl /dev/raw/rawctl

## map raw devices to the disk
raw /dev/raw/raw1 /dev/sdb1

## display raw devices
raw -qa
Filesystem commands
df -k
df -k
df -h
df -k
df -h
Filesystem (create|remove)
newfs -v <raw device>

# Display how the filesystem was created
newfs -Nv <raw device>
mkfs -t ext3 /dev/sdb1
mkfs -t ext3 /dev/sdb1
Tune Filesystems
tunefs
fstyp -v <device> |grep -i minfree
tune2fs
tune2fs -l /dev/sda1

# change reserved blocks percentage to 1%
tune2fs -m 1 /dev/sda1
tune2fs
tune2fs -l /dev/sda1

# change reserved blocks percentage to 1%
tune2fs -m 1 /dev/sda1
Force fsck

touch /forcefsck
shutdown -Fr now


tune2fs -l /dev/sdb<?> |grep -i 'filesystem state'
touch /forcefsck
shutdown -r now


tune2fs -l /dev/sdb<?> |grep -i 'filesystem state'

# edit /etc/default/rcS change below so
# you dont have to hang around
FSCKFIX=yes
backup filesystem
ufsdump|ufsrestore
tar
dd
cpio
dump/restore
tar
dd
cpio
dump/restore
tar
dd
cpio
Display the boot device
eeprom |grep boot-device
prtconf -pv |grep bootpath
cat /boot/grub/grub.conf
cat /etc/lilo.conf

grub = grand unified boot loader
lilo = linux loader
cat /boot/grub/menu.lst
Setting the boot device
setenv boot-device [<device>|<alias>]
eeprom boot-device [<device>|<alias>]
/boot/grub/grub.conf
/etc/lilo.conf


/boot/grub/menu.lst
Creating boot device (MBR)
installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk <raw-device>
grub-install <raw-device>
lilo -v
grub-install <raw-device>
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 -rt iso9660 /dev/cdrom /mnt/cdrom
umount /mnt/cdrom
eject cdrom
remount a filesystem

mount -o remount,rw /
mount -o remount,rw /
create boot disk or recovery tape
n/a
mkbootdisk `uname -r` (boot diskette)
n/a
boot cdrom/diskette (single user)
ok> boot cdrom -s
using the grub window append the word single to the kernel line
using the grub window append the word single to the kernel line
boot into maintenace mode
ok> boot -as
f10 or f12
f10 or f12
Device paths
floppy:
disk:
/dev/dsk/c0t0d0s0

tape:
/dev/rmt/0ucb

cdrom:
/dev/dsk/c0t6d0s0
/dev/scd0 (external usb cd)
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:
/dev/fd0
disk:
/dev/hda or /dev/sda
/dev/hdb or /dev/sdb
tape:
cdrom:
/dev/hda (depends on number of IDE disks)
update /dev directory
drvconfig
devlinks
disks|tapes|ports

devfsadm ( solaris 8, 9, 10)
/dev/MAKEDEV <device>
/dev/MAKEDEV <device>
remove or change a device
rem_drv


list device drivers
prtconf -D
sysdef
cat /proc/devices
cat /proc/devices
Networking

Solaris
Red Hat
Ubuntu/Debian
Basic network information
  (hostname, ip address)
/etc/hostname.hme0
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/network/interfaces
displaying network interfaces
prtdiag -v
ifconfig -a

kstat hme:0
ifconfig
system-config-network (GUI)
ifconfig
Configure network interface
ifconfig
ifconfig
ifconfig
Starting and stopping a network interface
ifconfig qfe0 up
ifconfig qfe0 down
/sbin/ifup eth0
/sbin/ifdown eth0
/sbin/ifup eth0
/sbin/ifdown eth0
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
ethtool -s eth1 speed 100 duplex full
Change NIC parameters
ndd -get <device> <parm>
ndd -get dev/ip \? (list all params)


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

sysctl -a | grep net*
ethtool eth0

sysctl -a |grep net*
Display NIC statistics



display MAC address
ifconfig -a (as user root)
ifconfig
system-config-network (GUI)
ifconfig
Displaying network packets
snoop -d <interface>
tcpdump -i <interface>
ethereal (needs to be installed)
tcpdump -i <interface>
ethereal (needs to be installed)
default router
/etc/defaultrouter

route add default <gteway>
edit /etc/sysconfig/network
add: GATEWAY=<IP address>
edit /etc/network/interfaces

add: gateway <IP address>
display routing table
netstat -n
netstat -rn
route -n
netstat -rn
route -n
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
ifenslave -d bond0 eth1   (detach)
ifenslave bond0 eth1       (reattach)

cat /proc/net/bonding/bond0
change the hostname
change the following four files:
/etc/nodename
/etc/hostname.<interface>
/etc/inet/hosts
/etc/inet/ipnodes
/etc/net - few files in here as well
/etc/sysconfig/network
/etc/hosts

sysctl -a |grep hostname
/etc/hostname
/etc/hosts

sysctl -a |grep hostname
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/host.conf
/etc/resolv.conf
Flush DNS cache

## if installed
service nscd restart

Domain Name
/etc/defaultdomain
/etc/sysconfig/network  (GATEWAY option)
edit /etc/network/interfaces
Obtain IP Address routing
route -n get <hostname>
traceroute
ip route get <IP address>
ip route get <IP address>
Find Services on the 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 -u <yp server> ypserv
Boot (jumpstart) servers:
rpcinfo -b bootparam 1

NFS servers:
rpcinfo -b mountd 1

NIS servers/slaves:
rpcinfo -u <yp server> ypserv
Crash Dump

Solaris
Red Hat
Ubuntu/Debian
Crash Dump
dumpadm -d <device>
crash (used to analyse crash dumps)
adb (used to analyse crash dumps)
diskdump
netdump
kdump (part of kexec rpm)

/etc/kdump.conf (select where you want the dump to go)
service kdump start
chkconfig kdump on

## to crash the system
echo "c" > /proc/sysrq-trigger

crash (used to analyse crash dumps)
diskdump
netdump
kdump (part of kexec rpm)

/etc/kdump.conf (select where you want the dump to go)
service kdump start
chkconfig kdump on

## to crash the system
echo "c" > /proc/sysrq-trigger

crash (used to analyse crash dumps)
Performance Monitoring and Diagnostics

Solaris
Red Hat
Ubuntu/Debian
CPU

top
sar
mpstat
w          (load average)
uptime   (load average)
ps
vmstat
procinfo
oprofile
cat /proc/cpuinfo
top
sar
mpstat
w          (load average)
uptime   (load average)
ps
vmstat
procinfo
cat /proc/cpuinfo
Memory

free
vmstat
top
procinfo
slabtop
sar
cat /proc/meminfo
free
vmstat
top
procinfo
slabtop
sar
cat /proc/meminfo
Network I/O

ethtool
mii-tool
netstat
lsof
tcpdump
ip
iptraf
ethtool
mii-tool
netstat
lsof
tcpdump
ip
iptraf
Disk I/O

sar -d
iostat
vmstat
lsof
sar -d
iostat
vmstat
lsof
Application
truss -p <pid>
strace -p <pid>
strace -p <pid>
NFS

nfsstat
nfsstat
Kernel Modules and Parameters

Solaris
Red Hat
Ubuntu/Debian
display loaded modules
modinfo
cat /proc/modules (more detailed)
lsmod
Location:
/lib/modules/`uname -r`/kernel/drivers

Config:
/etc/modprobe.conf
/etc/modprobe.d
cat /proc/modules (more detailed)
lsmod
Location:
/lib/modules/`uname -r`/kernel/drivers

Config:
/etc/modprobe.d/options
/etc/modprobe.d
load modules
modload -p drv/<module name>
modprobe <module>
insmod
modprobe <module>
insmod
unload modules
modunload -i <module number>
modprobe -r <module>
rmmod
modprobe -r <module>
rmmod
set kernel parameters (tuning)
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.............................................
/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.............................................
display kernel parameters
cat /etc/system
sysdef -i
sysctl -a
cat /etc/sysctl.conf

cat /proc/sys/kernel/sem
cat /proc/sys/kernel/shmmax
etc...................................
sysctl -a
cat /etc/sysctl.conf

cat /proc/sys/kernel/sem
cat /proc/sys/kernel/shmmax
etc...................................
build kernel
edit and update file then reboot:
/etc/system
cd /usr/src/linux-2.5
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

interprocess communication
ipcs -a
ipcs -a
ipcs -a
Services

Solaris 10
Red Hat
Ubuntu/Debian
display services
svcs -a
inetadm -l
service --status-all
There is no services or chkconfig command use the old fashioned way /etc/init.d/<service>
start services
svcadm enable nfs
service nfs start
stop services
svcadm disable nfs
service nfs stop
reload service
svcadm refresh nfs
service nfs reload
restart service
svcadm restart nfs
service nfs restart
service status
svcs nfs
service nfs staus
service dependencies
svcs -d network
n/a
service dependants
svcs -D network
n/a
service logging, etc
/var/svc/log
/var/svc/manifest
/lib/svc/method
n/a
change service startup
n/a
chkconfig --levels 2345 nfs on
Patching / Software

Solaris
Red Hat
Ubuntu/Debian
display installed patches
showrev -p
patchadd -p


adding patch
patchadd
patchadd -M <dir> (multiple patches)
patch -p1 <patch>

zcat patch46.gz | patch -p1

Note: -p = # of path stripping

removing patch
patchrm
patch -R -p1 <patch>

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)
dpkg -l
dpkg -S <search string> (search)
dpkg -S <filename> (file belongs)
dpkg -s <package> (status)
dpkg -p <package> (detailed)
adding package
pkgadd
rpm -Uhv (updates/installs if not already)
rpm -ihv (install)
dpkg -i <package>
removing packages
pkgrm
rpm -e <package>
dpkg -r <package> (do not remove config files)
dpkg -P <package> (remove config files)
verify package
pkginfo -l
pkginfo -p
rpm -V <package>
n/a
List files in package
pkgchk -l <package> | grep -i pathname
rpm -ql <package>
dpkg -L <package> (list files)
Package directory
/var/sadm
/var/lib/rpm
/var/lib/dpkg/info
List libraries required for binary program
ldd <file>
ldd <file>
ldd <file>
Accounts

Solaris
Red Hat
Ubuntu/Debian
display users
cat /etc/passwd

logins -x
cat /etc/passwd
system-config-users (GUI)
cat /etc/passwd
create a user
useradd
useradd
system-config-users (GUI)
useradd
remove a user
userdel
userdel
system-config-users (GUI)
userdel
modify a user
usermod
usermod
system-config-users (GUI)
usermod
change user password
passwd
passwd
passwd
create a group
groupadd
groupadd
groupadd
remove a group
groupdel
groupdel
groupdel
modify a goup
groupmod
groupmod
groupmod
password files
/etc/passwd
/etc/shadow
/etc/shadow
/etc/shadow
useful user commands
id -a
whoami
who
w
finger
id -a
whoami
who
w
finger
id -a
whoami
who
w
finger
useful group commands

groups
groups
NFS

Solaris
Red Hat
Ubuntu/Debian
NFS Daemons
server: mountd, nfsd
client: statd, lockd
server: rpc.mountd,nfsd
client: rpc.statd, lockd
server: rpc.mountd,nfsd
client: rpc.statd, lockd
NFS files
/etc/dfs/dfstab
/etc/dfs/sharetab
/etc/rmtab
/etc/exports
/var/lib/nfs/etab
/var/lib/nfs/xtab
/etc/exports
/var/lib/nfs/etab
/var/lib/nfs/xtab
List nfs clients that have a remote mount
/etc/rmtab
/var/lib/nfs/rmtab
/var/lib/nfs/rmtab
display nfs shares
dfshares
showmount -e localhost
showmount -e localhost
showmount -e localhost
create nfs share
/etc/dfs/dfstab (edit and add share)
share <path>

## dfstab example
share -F nfs -d "jumpstart" /export/jumpstart
redhat-config-nfs (GUI)

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

## /etc/exports example
/export *(rw,fsid=0,insecure,no_root_squash,sync)
/etc/exports (edit and add share, see below example)
exportfs -rav (export the shares)

/etc/init.d/portmap restart
/etc/init.d/nfs-kernel-server restart

## /etc/exports example
/export *(rw,fsid=0,insecure,no_root_squash,sync)
uncreate nfs share
unshare <path>
/etc/dfs/dfstab (edit and remove share)
/etc/exports (edit and remove share)
/sbin/service nfs reload
/etc/exports (edit and remove share)
exportfs -rav (export the shares)
start/change nfs daemons
/etc/init.d/nfs.server start
/etc/init.d/nfs.client start

svcadm enable nfs/server
svcadm disable nfs/server
/sbin/service nfs start
/etc/init.d/portmap start
/etc/init.d/nfs-kernel-server start
stop nfs daemons
/etc/init.d/nfs.server stop
/etc/init.d/nfs.client stop
/sbin/service nfs stop
/etc/init.d/portmap stop
/etc/init.d/nfs-kernel-server stop
nfs status
ps -ef|grep < nfs daemons>
/sbin/service nfs status
/etc/init.d/nfs-kernel-server status
nfs reload
shareall
/sbin/service nfs reload
exportfs -rav (export the shares)
nfs performanace
nfsstat
nfsstat
nfsstat
nfs Options

cat /var/lib/nfs/etab
cat /var/lib/nfs/etab
solaris/redhat mount problems (nfs v3 to v4)
## Make sure you use NFS version 3
mount -F nfs -o vers=3 <mount> <mountpoint>
n/a
n/a
NTP

Solaris
Red Hat
Ubuntu/Debian
Time daemons
xntpd ntpd
ntpd
ntp setup
# Solaris 8
/etc/ntp.conf
/etc/ntp.server
/etc/ntp.client

/etc/rc2.d/xntpd [start|stop]
# Solaris 10
/etc/inet/ntp.server
/etc/inet/ntp.client

svcadm enable ntpd
/etc/ntp.conf (edit with ntp servers)
dateconfig (GUI)

chkconfig --list ntpd
chkconfig --level 2345 ntpd on
/sbin/service ntpd start
/etc/default/ntp
/etc/ntp.conf

/etc/init.d/ntp [start|stop|restart]
ntp daemon options

/etc/sysconfig/ntpd
/etc/default/ntp
NTP Trace commands
ntpq -p
ntptrace
ntpq -p
ntptrace
ntpq -p
ntptrace
Log Files

Solaris
Red Hat
Ubuntu/Debian
messages
/var/adm/messages
/var/log/messages
/var/log/messages
syslog
/var/log/syslog
/var/log/syslog
/var/log/syslog
mail

/var/log/mail
/var/log/mail.*
cron
/var/cron/log
/var/log/cron
/var/log/cron.log
boot
/var/adm/messages
dmesg
/var/log/boot
dmesg
/var/log/boot
dmesg
Error logging
logger
logger
logger
Security

Solaris
Red Hat
Ubuntu/Debian
Checking the passwd file
pwck
pwck
pwck
checking the group file
grpck
grpck
grpck
console login (allow/deny)
# No reboot required
/etc/default/login
# No reboot required
/etc/securetty
# No reboot required
/etc/securetty
Misc

Solaris
Red Hat
Ubuntu/Debian
startup
eeprom
setenv boot-device
grub (GUI)
lilo (text based)
grub (GUI)
shutdown
shutdown -i5 -g0 -y (power down)
shutdown -i6 -g0 -y (reboot)
shutdown -i0 -g0 -y (OK prompt)

reboot -- -r (reboot/reconfigure)

touch /reconfigure
shutdown -h (halt)
shutdown -r (reboot)
shutdown -f (fast reboot no fsck)
shutdown -F (force fsck)
shutdown -h (halt)
shutdown -r (reboot)
shutdown -P (power off)

touch /forcefsck
# edit /etc/default/rcS change below so
# you dont have to hang around
FSCKFIX=yes
Change run level
halt
init
poweroff
reboot
shutdown
telinit
uadmin
halt
init
poweroff
reboot
shutdown
telinit
halt
init
poweroff
reboot
shutdown
telinit
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


# change default
vi /etc/inittab

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


# change default
vi /etc/inittab

0 - halt
1 - single user
2 - multiuser (default)
3 - same as 2
4 - same as 2
5 - same as 2
6 - reboot



# change default - change all the telinit
vi /etc/event.d/rc-default
Startup options
-s single user
-a interactive
-x no device drivers (used in clustering)
-r reconfigure devices
-m milestone
single  - use grub to edit kernel line
emergency - use grub to edit kernel line
linux rescue - use at the boot prompt

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
single  - use grub to edit kernel line
emergency - use grub to edit kernel line
linux rescue - use at the boot prompt

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/init.d

/etc/rc0.d - /etc/rc6.d
boot prompt commands
boot
printenv
setenv
banner
devalias
show-devs
show-pci-devs-all
probe-scsi-all
probe-fcal-all
probe-pci
watch-net-all
reset-all
F10 or F12
F10 or F12
Boot process
Phases:
  • Boot PROM: displays system information, run POST, load bootblk, locate ufsboot
  • Boot Programs: bootblk loads and executes the ufsboot
  • Kernel Initialization: ufsboot loads and executes the core kernel, initializes core kernel data structures, loads other kernel modules based on the /etc/system file, starts /sbin/init program
  • init: starts other processes based on the /etc/inittab file
Boot sequence
1.     BIOS
2.     POST
3.     Master Boot Record (MBR) - point to the bootloader GRUB or LILO
4.     GRUB (stage 1) - point to GRUB stage 1_5
5.     GRUB (stage 1_5) - deals with specific filesystem types look at /boot/grub/*1_5 files
6.     GRUB (stage 2) – reads /etc/grub.conf and displays the grub menu, it specifies the kernel and the initrd files
7.     KERNEL - control given to the kernel
8.     INIT - reads /etc/inittab and runs /etc/rc.d/rc.sysinit script
Boot sequence
1.     BIOS
2.     POST
3.     Master Boot Record (MBR) - point to the bootloader GRUB or LILO
4.     GRUB (stage 1) - point to GRUB stage 1_5
5.     GRUB (stage 1_5) - deals with specific filesystem types look at /boot/grub/*1_5 files
6.     GRUB (stage 2) – reads /boot/grub/menu.lst and displays the grub menu, it specifies the kernel and the initrd files
7.     KERNEL - control given to the kernel
8.     INIT - runs the /etc/event.d/rc-default script
determine the run level
who -r
runlevel
who -r
runlevel
who -r
obtain default run level
cat /etc/inittab
cat /etc/inittab
/etc/event.d/rc-default
list locale
locale -a
locale -a
locale -a
start xwindows
n/a
startx (shorthand of below)
initx (lots of parms)

initialize system
sys-unconfig


Timezone
/etc/TIMEZONE
/etc/default/init
/etc/sysconfig/clock
/usr/share/zoneinfo/zone.tab
/etc/timezone
/usr/share/zoneinfo/zone.tab