You are on page 1of 6

Unix Commands

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm

Common Unix Commands


Sysinfo Memory and Swap Disks, Filesystems and Devices Networking Crash Dump Performance Monitoring and Diagnostics Kernel Modules and Parameters Services Patching / Packages Accounts NFS NTP Log Files Security Misc Display system information i.e cpu, memory, etc Information regarding the physical memory and swap area Displaying disk information, filesystems Display and configuring network parameters Configure, display and use the crash dump utiltities List, Monitor and trace processes Displaying, modifying and tuning kernel parameters Display, start and stop services Installing and removing patches and software packages Setting up and removing user accounts Information on NFS i.e starting, stopping, etc Network Time Protocol Location to common log files Security information Other stuff i.e shutdown, timezone, run level, etc

sysinfo
Solaris cat /etc/release Server Release info Red Hat cat /etc/enterprise-release cat /etc/redhat-release lsb_release -a cat /proc/version /usr/platform/`uname -i`/sbin/prtdiag -v Server type prtdiag -v prtpicl -v [-c <class>] prtconf -D lspci lsusb lshal dmidecode dmidecode model uname -a ioscan ioscan -fun [disk|tape|lan] /opt/ignite/bin/print_manifest cat /var/opt/ignite/local/manifest/manifest.info prtconf | grep -i 'System Model' Server type Ubuntu/Debian cat /etc/lsb-release lsb_release -a /stand/kernrel oslevel -r Server Release info HP AIX

lspci lsusb lshal Note: hal = hardware abstraction layer

lscfg -v lscfg -l ent0 lscfg -vl fcs0 (find the WWN of HBA adapter) lsdev lsdev -Cc disk lsdev -Cc disk -p scsi0 lsslot -c [pci|phb|port] lsslot -c pci -l ent0 lspath -l hdisk0 diag

Hardware Info

Hardware Info

Operating System

uname -a /usr/platform/`uname -i`/sbin/prtdiag -v prtconf | grep -i mem

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

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

uname -a dmesg | grep -i physical /usr/sam/lbin/getmem /opt/ignite/bin/print_manifest cat /var/opt/ignite/local/manifest/manifest.info

oslevel [-r|-s] prtconf -m prtconf |grep -i memory lsattr -El sys0 -a realmem bootinfo -r

Operating System

Memory

Memory

/usr/platform/`uname -i`/sbin/prtdiag -v CPU (type, number, etc) ## display,offline,online psrinfo psradm -f 0 (offline) psradm -n 0 (online) format prtvtoc <device> Disk Drives format -e (to convert EFI (zfs) to SMI) Note: EFI - Extensible Firmware Interface SMI - Sun Microsystems Inc /kernel/genunix Kernel File and associated directories /platform/sparc/kernel /platform/i86pc/kernel /kernel /usr/kernel isainfo -kv (solaris 9+) isalist (sparc v9 will be listed first)

cat /proc/cpuinfo (detailed)

cat /proc/cpuinfo (detailed)

/opt/ignite/bin/print_manifest sam -> performance monitors -> system properties cat /var/opt/ignite/local/manifest/manifest.info

prtconf |grep -i processor

CPU (type, number, etc)

fdisk -l sfdisk -l (advanced server) parted <device> print partprobe -s <device>

fdisk -l sfdisk -l (advanced server) parted <device> print partprobe <device>

ioscan -funC disk

lsdev -Cc disk lsdev -Cc disk -p scsi0 (specific controller) lsdev -Cc disk -S [a|d|s] (available, defined, stopped) lscfg -v -l hdisk0 Disk Drives

/boot/initrd.?????.img /boot/vmlinuz

/boot/initrd.img-?????-server /boot/vmlinuz-????-server

/stand/vmunix

/unix /usr/lib/boot /usr/lib/drivers Note: /unix - symbolic link to kernel file i.e /usr/lib /boot/unix_64

Kernel File

uname -a uname -m getconf -a |grep -i 'long_bit'

uname -a uname -m getconf -a |grep -i 'long_bit'

getconf KERNEL_BITS ( version 11) /opt/ignite/bin/print_manifest |grep -i 'os mode' HPUX < version 11 all 32 bit

prtconf -k bootinfo -K

Kernel 32 or 64

Note: determine if system supports 64 bit getconf HW_CPU_SUPP_BITS /opt/ignite/bin/print_manifest |grep -i 'hw capability'

Kernel 32 or 64

At the OK prompt type banner Display Firmware

boot into the BIOS (normally F2 or F12)

boot into the BIOS (normally F2 or F12)

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

prtconf |grep -i firmware lscfg -pv invscout

Display Firmware

n/a Display IRQ, IO ports and DMA GUI admin tool admintool

/proc/interrupts /proc/ioports /proc/dma linuxconf

/proc/interrupts /proc/ioports /proc/dma linuxconf

prtconf

Display IRQ, IO ports and DMA GUI admin tool

sam

smit smitty

Memory and Swap


Solaris Red Hat Ubuntu/Debian cat /proc/meminfo (detailed) free -om HP dmesg | grep -i physical /usr/sam/lbin/getmem /opt/ignite/bin/print_manifest cat /var/opt/ignite/local/manifest/manifest.info page size (memory) display swap /usr/bin/pagesize swap -l swap -s /usr/bin/getconf -a| egrep -i 'pagesize|page_size' cat /proc/swaps (detailed) swapon -s /usr/bin/getconf -a| egrep -i 'pagesize|page_size' cat /proc/swaps (detailed) swapon -s dmesg |grep -i physical swapinfo (displayed in KB) swapinfo -m (display in Mb) swapinfo -tm (total / Mb) 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 . The nswapdev tunable system parameter controls the maximum number of swap devices. pagesize pagesize -a (display all supported pagesizes) lsps -a (detailed) lsps -s mkps -a -s 4 -n <volume group> # change the attributes chps -a n paging00 (don't use after restart) # change the logical volume attributes (name in this case) chlv -n <new name> <old old> (chang page space name) adding swap Note: -a reconfigure paging space after restart -s size of the page space (logical partitions) -n activiates the paging space (use swapoff to deactivate) also see /etc/swapspaces file 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 Note: paging space must be deactiviated before removing remove entry from /etc/fstab reboot swapoff /dev/paging00 rmps paging00 removing swap page size (memory) display swap prtconf -m prtconf |grep -i memory lsattr -El sys0 -a realmem bootinfo -r AIX

Memory

/usr/platform/`uname -i`/sbin cat /proc/meminfo (detailed) /prtdiag -v free -om prtconf | grep -i mem

Memory

mkfile 5m /var/swapfile swap -a /var/swapfile update /etc/vfstab

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

adding swap

Disks, Filesystems and Devices

1 of 6

2/7/2012 9:53 PM

Unix Commands

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm

Solaris format prtvtoc <device> Disk Drives format -e (to convert EFI (zfs) to SMI) Note: EFI - Extensible Firmware Interface SMI - Sun Microsystems Inc format iostat -En luxadm inq <disk> (A5x00 disk arrays)

Red Hat fdisk -l sfdisk -l (advanced server) parted <device> print partprobe <device>

Ubuntu/Debian fdisk -l sfdisk -l (advanced server) parted <device> print partprobe <device> ioscan -funC disk

HP

AIX lsdev -Cc disk lsdev -Cc disk -p scsi0 (specific controller) lsdev -Cc disk -S [a|d|s] (available, defined,stopped) lscfg -v -l hdisk0 Disk Drives

hdparm -i /dev/hda hdparm -I /dev/hda (detailed) hdparm -Tt /dev/hda (speed test) sdparm -i /dev/sdb

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

diskinfo -v /dev/rdsk/c0t4d0 (detailed but no serial number) /opt/ignite/bin/print_manifest (no serial number) ## Insure that the online diagnostic support tools have been installed swlist -l bundle | grep 'Support Tools' ## Command-Line Support Tools Manager (cstm) ## The run cstm cstm cstm> map cstm> sel dev 4 (select the disk of you choice) cstm> info cstm> il (obtain the serial number) cstm> quit lvlnboot -v /dev/vg00 lifls -Clv <device> # Display the LIF contents lifcp /dev/dsk/c0t6d0:AUTO cat /etc/fstab Note: Boot programs are stored in the boot area in Logical Interchange Format (LIF), which is similar to a file system. For a device to be bootable, the LIF volume on that device must contain at least the ISL (the initial system loader) and HPUX (the HP-UX bootstrap utility) LIF files. ISL is like GRUB.

lscfg -vl hdisk0 lscfg -vl hdisk*

Disk serial Number, type, etc

cat /proc/ide/ide0/hda/model cat /proc/scsi/scsi

Disk serial Num

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

lsvg -l rootvg lchangelv cat /etc/filesystems

Disk disk partitions

Disk disk partit

use format to partition the disk then just use the slice as a raw partition, remember to use the character device

## 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

Just create a new LVOL without a filesystem - that's it.

Just create a new LVOL without a filesystem # create a raw volume mklv -y rawVolume vg01 10 List Raw Partiti

List Raw Partitions

Filesystem commands

df -k df -h newfs -v <raw device> # Display how the filesystem was created newfs -Nv <filesystem>

df -k df -h mkfs -t ext3 /dev/sdb1

df -k df -h mkfs -t ext3 /dev/sdb1

bdf df [-egiklnvfb] newfs -F vxfs -o largefiles /dev/vg01/rlvol1 mkfs -F vxfs -o largefiles /dev/vg01/rlvol1 Note: mkfs and newfs are a pointer to /sbin/fs_wrapper

df -k lsfs [<filesystem>] lsfs -q <filesystem> (detailed) crfs -v jfs2 -d data02lv -m /data02 -A yes -v filesystem type -d device or logical volume -m mountpoint -A mount after restart [yes|no] rmfs -ri /data02 -r remove the mountpoint -i display warning before removing chfs -a size=+1G /var (grow by additional 1GB) chfs -a size=1G /var (grow to 1GB in size)

Filesystem com

Filesystem (create|remove)

Filesystem (cre

tunefs fstyp -v <device> |grep -i minfree Tune Filesystems

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

tunefs -v <filesystem> vxtunefs -v <filesystem> fstyp -v <filesystem> # Disk fragmentation fsadm -F vxfs -E / (report) fsadm -F vxfs -e / (defrag)

chfs Note: you can perform the following resize freeze change mountpoint permissions lots more.............................. n/a

Tune Filesystem

touch /forcefsck shutdown -Fr now Force fsck # Check to see filesystem needs checking fstyp -v <filesystem> | grep fsclean 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

# Look at the second line to see if a filesystem # needs checking tunefs -v <filesystem> fbackup/frecover dump/restore ftio tar dd cpio setboot backup|restore tar dd cpio

Force fsck

backup filesystem

ufsdump|ufsrestore tar dd cpio

dump/restore tar dd cpio

dump/restore tar dd cpio

backup filesyst

Display the boot device

eeprom |grep boot-device prtconf -pv |grep bootpath prtpicl -v|grep ':bootpath'

cat /boot/grub/grub.conf cat /etc/lilo.conf grub = grand unified boot loader lilo = linux loader

cat /boot/grub/menu.lst

bootinfo -b (display last boot device) bootlist -m [normal|service] -o (display bootable devices) Display the boo

setenv boot-device [<device>|<alias>] eeprom boot-device [<device>|<alias>] Setting the boot device

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

/boot/grub/menu.lst

setboot -p <primary path> setboot -a <alternate path> # autoboot sequnce setboot -b [on|off]

bootlist -m normal hdisk0 hdisk1 Setting the boo

Creating boot device (MBR)

installboot /usr/platform/`uname -i`/lib /fs/ufs/bootblk <raw-device> fdformat -v -U volcheck -v newfs -v /vol/disk/aliases/floppy0 volrmmount -l floppy0 eject floppy mount -F hsfs -o ro <device path> /cdrom /cdrom0 umount /cdrom/cdrom0 /etc/init.d/volmgr start eject cdrom n/a

grub-install <raw-device> lilo -v floppy --probe (use device obtained below ) floppy --createrc > /etc/fd0 floppy --format /dev/fd0 mkfs /dev/fd0 mount /dev/fd0 /mnt/floppy umount /mnt/floppy mount -rt iso9660 /dev/cdrom /mnt/cdrom umount /mnt/cdrom eject cdrom

grub-install <raw-device>

mkboot -l <device> Note: we are treating the disk as a LVM device

bosboot -a (uses default device) bosboot -ad hdisk1 format -d /dev/rfd0 format -d /dev/fd0.18 (high format)

Creating boot d

n/a

n/a

Format floppy drive

Format floppy d

mount/unmount floppy

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

n/a

mount /dev/rfd0 /floppy mount -v cdrfs -r /dev/cd0 /cdrom umount /cdrom

mount/unmoun

mount -rF cdfs /dev/dsk/c1t6d0 /cdrom start: /usr/sbin/pps_mountd pps_mount mount_vxfs -o remount,ro <filesystem>

mount/unmount CDROM

mount/unmoun

mount -o remount,rw /

mount -o remount,rw /

mount -o remount,rw <filesystem> Note:I did find a note that it should be possible to remount remount a files a jfs2 filesystem, but it did not work on my system

remount a filesystem

create boot disk or recovery tape

n/a

mkbootdisk `uname -r` (boot diskette)

n/a

recovery tape (preview) make_tape_recovery -v -l -x inc_entire=vg00 /opt/ignite/bin/make_recovery -ACv

mksysb create boot dis based on a 9114-275 workstation 1. Restart the machine. 2. Wait the the AIX splash screen to come up. Devices begin to initialize here. boot cdrom/dis 3. When you see the [keyboard] word on screen hit the F5 button or the 5 key depending on your console. 4. Choose default boot list when the maintenance screen comes up. based on a 9114-275 workstation 1. Restart the machine. 2. Wait the the AIX splash screen to come up. Devices begin to initialize here. 3. When you see the [keyboard] word on screen hit the boot into maint F5 button or the 5 key depending on your console. 4. Choose select boot options when the maintenance screen comes up, then option 1, then option 1 for scsi, then option 3 service mode boot

ok> boot cdrom -s

using the grub window append the word single to the kernel line

boot cdrom/diskette (single user)

using the grub window append the word single to enter PDC the kernel line > search >boot p1 (cdrom) interact with IPL? Y ISL> hpux -is

ok> boot -as

f10 or f12

f10 or f12

>boot pri interact with IPL? Y ISL> hpux -lm

boot into maintenace mode

2 of 6

2/7/2012 9:53 PM

Unix Commands

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm

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)

floppy: n/a disk: /dev/dsk/c0t6d0 tape: /dev/dsk/rmt/0 cdrom: /dev/dsk/c1t6d0

floppy: /dev/fd0 /dev/rfd0 disk: /dev/hdisk0 tape: cdrom: /dev/cd0

Device paths

Device paths

update /dev directory

drvconfig devlinks disks|tapes|ports devfsadm ( solaris 8, 9, 10) rem_drv

/dev/MAKEDEV <device>

/dev/MAKEDEV <device>

insf -C tape (Class) insf -H 0.1.0 -e (recreate deleted link)

cfgmgr cfgmgr -l scsi0 mkdev

update /dev dir

# remove all devices from a hardward path rmsf -k -H 52.6.0

rmdev rmdev -l cd0 remove or chan chdev chdev -l rmt0 -a ret=no

remove or change a device

prtconf -D sysdef

cat /proc/devices

cat /proc/devices

lsdev

lsdev lsdev -Cc disk lsdev -Cc disk -p scsi0 lsslot -c pci -l ent0

list device drivers

lscfg lscfg -l ent0 lscfg -vl fcs0 (find the WWN of HBA adapter) lspath -l hdisk0 getconf DISK_SIZE hdisk1 (detailed)

list device drive

Networking
Solaris Basic network information (hostname, ip address) /etc/hostname.hme0 prtdiag -v ifconfig -a kstat hme:0 kstat e1000g:0 Red Hat /etc/sysconfig/network /etc/sysconfig/network-scripts/ifcfg-eth0 ifconfig system-config-network (GUI) Ubuntu/Debian /etc/network/interfaces ifconfig /etc/rc.config.d/netconf ioscan -funC lan (list hardware) lanscan -v (list configured) ifconfig lan0 (individual) HP AIX stores information in the ODM (Object Database Manager) ifconfig -a entstat -d <interface> lsdev -Cc if lsdev -Cc tcpip odmget -q "name=en0" CuAt lsattr -EHl en0 ifconfig ifconfig ifconfig ifconfig <interface> mktcpip (completely setup a network interface) rmtcpip (remove all network interfaces) # configure an interface mktcpip -h aix1 -a 192.168.1.200 -m 255.255.255.0 -i en1 -g 192.168.0.10 -h - hostname assigned to interface -a - ip address -m - netmask -i - interface name -g - gateway ip address # remove an interface ifconfig en1 detach ifconfig (configures IP address) chdev (add aliases to network interface) ifconfig qfe0 up ifconfig qfe0 down Starting and stopping a network interface /sbin/ifup eth0 /sbin/ifdown eth0 /sbin/ifup eth0 /sbin/ifdown eth0 ifconfig lan0 up ifconfig lan0 down note: there is no "ifconfig -a" in hpux use lanscan then "ifconfig <interface>" 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 ndd -set <device> <parm> <value> lanadmin -X <option> lan0 ifconfig en0 up ifconfig en0 down ifconfig en0 detach (remove) displayin interface Basic ne (hostna

displaying network interfaces

Configure network interface

Configur interface

Starting network

chdev -l ent0 -a media_speed=1000_Full_Duplex -P chdev -l ent0 -a media_speed=Auto_Negotiation -P Note: entX - physical device enX - frame type run on entX Setting N

Setting NIC speed

ndd -get <device> <parm> Change NIC parameters # List parameters ndd -get /dev/hme \? ndd -get /dev/e1000g0 \? ndd -get /dev/ip \? ndd -get /dev/tcp \?

mii-tool -v ethtool eth1 ethtool -t eth0 online sysctl -a | grep net*

ethtool eth0 sysctl -a |grep net*

lanadmin -> lan -> display ## options supported ndd -get /dev/ip ? ndd -get /dev/tcp ? ndd -get /dev/arp ? ndd -get /dev/udp ? netstat -i [-I interface] netstat -s

netstat -v entstat -d <interface> no -a no -o "ipforwarding=1" NIC spee

Display NIC statistics display MAC address ifconfig -a (as user root) snoop -d <interface> ifconfig system-config-network (GUI) tcpdump -i <interface> ethereal (needs to be installed) ifconfig

netstat -i [-f inet] netstat -s entstat -d <interface> netstat -ia

Display n display M

lanscan

tcpdump -i <interface> ethereal (needs to be installed)

Displaying network packets

nettl nettl nettl nettl

-start tcpdump -i <interface> -status all iptrace -i <interface> <output file> -tn pduin pduout -e ns_ls_driver -file /var/adm/LAN ipreport (used with iptrace to view reports) -stop Note: you must stop the iptrace by using "kill -15" route add 0 <gateway IP address> Note: there is no file that holds the default router

Displayin packets

use netfmt to display the trace file /etc/defaultrouter default router route add default <gteway> netstat -rn display routing table edit /etc/sysconfig/network add: GATEWAY=<IP address> netstat -rn route -n edit /etc/network/interfaces add: gateway <IP address> netstat -rn route -n netstat -rn /etc/rc.config.d/netconf

default r

netstat -rn netstat -r -f inet lsattr -EHl inet0 -a route

display r

Test IPMP, Bonding

if_mpadm -d if_mpadm -r

(detach) (reattach)

ifenslave -d bond0 eth1 (detach) ifenslave bond0 eth1 (reattach) cat /proc/net/bonding/bond0 /etc/sysconfig/network /etc/hosts sysctl -a |grep hostname

ifenslave -d bond0 eth1 (detach) ifenslave bond0 eth1 (reattach) cat /proc/net/bonding/bond0 /etc/hostname /etc/hosts sysctl -a |grep hostname

You buy an optional product called Auto-Port Aggragation. smitty etherchannel (creates, deletes and tests) entstat -d ent0 Test IPM

tail /var/adm/messages change the following files: change the hostname /etc/nodename /etc/hostname.<interface> /etc/inet/hosts /etc/inet/ipnodes /etc/net - few files in here as well /etc/resolv.conf /etc/nsswitch.conf /etc/resolv.conf

set_parms hostname (requires reboot)

hostname <new hostname> chdev -l inet0 -a hostname=<hostname> change t

setup DNS

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

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

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

/etc/resolv.conf /etc/netsvc.conf /etc/resolv.conf /etc/irs.conf (may not be there) chnamsv (change name service) rmnamsv (remove a name service) lsnamsv -C (list name services)

setup DN

Name service switch file (DNS client)

Name se (DNS clie

Flush DNS cache

svcadm restart system/name-service-cache:default /etc/defaultdomain

## if installed service nscd restart /etc/sysconfig/network (HOSTNAME option) /etc/resolv.conf Note: for NIS use the NISDOMAIN option /etc/host /etc/resolv.conf

n/a /etc/rc.config.d/netconf

netcdctrl -t dns -e hosts -f domainname <domainname>

Flush DN

Domain Name route -n get <hostname> traceroute Boot (jumpstart) servers: rpcinfo -b bootparam 1

Domain n/a route -n get <hostname>

Obtain IP Address routing

ip route get <IP address> tracroute Boot (jumpstart) servers: rpcinfo -b bootparam 1

ip route get <IP address> traceroute Boot (jumpstart) servers: rpcinfo -b bootparam 1

Obtain IP Find Ser network

Find Services on the network

Boot (jumpstart) servers: rpcinfo -b bootparam 1

Boot (jumpstart) servers: rpcinfo -b bootparam 1

3 of 6

2/7/2012 9:53 PM

Unix Commands

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm

NFS servers: rpcinfo -b mountd 1 NIS servers/slaves: rpcinfo -b ypserv 1

NFS servers: rpcinfo -b mountd 1 NIS servers/slaves: rpcinfo -u <yp server> ypserv

NFS servers: rpcinfo -b mountd 1 NIS servers/slaves: rpcinfo -u <yp server> ypserv

NFS servers: rpcinfo -b mountd 1 NIS servers/slaves: rpcinfo -b ypserv 1

NFS servers: rpcinfo -b mountd 1 NIS servers/slaves: rpcinfo -b ypserv 1

Crash Dump
Solaris Red Hat Ubuntu/Debian 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) HP edit /stand/system add either: dump 2/0/1.5.0 dump lvol dump none # crash config file /etc/rc.config.d/savecrash AIX sysdumpdev -l (list dump destination) sysdumpdev -e (estimates dumpsize) sysdumpdev -L (info) sysdumpstart -p (start dump primary) sysdumpstart -s (start dump secondary) Crash Dump # set the dump device permanently sysdumpdev -p <dump device> -P # analyse dump file echo "stat\n status\n t -m" | crash /var/adm/ras/vmcore.0

Crash Dump

dumpadm -d <device> diskdump netdump crash (used to analyse kdump (part of kexec rpm) crash dumps) adb (used to analyse /etc/kdump.conf (select where you crash dumps) 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 top (sunfreeware) prstat sar mpstat w (load average) uptime (load average) ps vmstat Red Hat top sar mpstat w (load average) uptime (load average) ps vmstat procinfo oprofile cat /proc/cpuinfo Ubuntu/Debian top sar mpstat w (load average) uptime (load average) ps vmstat procinfo cat /proc/cpuinfo HP top sar w (load average) uptime (load average) ps vmstat glance sam AIX topas -P topas -L (logical partitions) mpstat sar -c w (load average) uptime (load average) lparstat ps iostat -tT 1 tprof curt topas vmstat sar -b svmon ps ipcs -a lockstat (version 4) rmss [ent|tok|fddi|atm]stat netstat netpmon (trcstop to stop trace)

CPU

CPU

Memory

prstat vmstat top sar

free vmstat top procinfo slabtop sar cat /proc/meminfo ethtool mii-tool netstat lsof tcpdump ip iptraf sar -d iostat vmstat lsof

free vmstat top procinfo slabtop sar cat /proc/meminfo ethtool mii-tool netstat lsof tcpdump ip iptraf sar -d iostat vmstat lsof

top vmstat sar sam glance

Memory

Network I/O

ndd netstat lsof snoop route

netstat lanadmin sam glance

Network I/O

sar -d iostat vmstat lsof Disk I/O

iostat sar sam glance

topas -D (disk) topas -F (filesystem) iostat sar -D fcstat (fibre) lvmstat filemon (trcstop to stop) fileplace # disk stat history chdev -l sys0 -a iostat=true lsattr -HEl sys0 -a iostat

Disk I/O

truss -p <pid>

strace -p <pid>

strace -p <pid>

download and install tusc tusc -p <pid>

Application

topas truss sar probevue tprof svmon -P <pid> nfsstat

Application

NFS

nfsstat

nfsstat

nfsstat

nfsstat

NFS

Kernel Modules and Parameters


Solaris modinfo Red Hat cat /proc/modules (more detailed) lsmod Location: /lib/modules/`uname -r`/kernel/drivers Config: /etc/modprobe.conf /etc/modprobe.d load modules modload -p drv/<module name> modunload -i <module number> unload modules /etc/system (edit and reboot) modprobe <module> insmod modprobe -r <module> rmmod /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............................................. Ubuntu/Debian cat /proc/modules (more detailed) lsmod Location: /lib/modules/`uname -r`/kernel/drivers Config: /etc/modprobe.d/options /etc/modprobe.d modprobe <module> insmod modprobe -r <module> rmmod /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............................................. kmadmin -L <module name> n/a n/a unload mod load module kmadmin -k HP genkex AIX

display loaded modules

display load

kmadmin -U <module name> kmadmin -u <module id> kcweb (11i) kctune (11i only) rebuild kernel (< 11i see below)

set kernel parameters (tuning)

chdev -l sys0 -a <parameter>=<value> no -a (network) vmo -a (virtual memory) nfso -a (NFS) ioo -a (Input/Ouput) raso -a (reliability, availability, serviceability) schedo -a (processor scheduler) vi /etc/security/limits cd /etc/tunables tunchange, tundefault, tunsave, tunrestore, tuncheck Note: most parameters are dynamically changed in AIX , for example memory segments are dynamically adjusted

set kernel p

cat /etc/system sysdef -i display kernel parameters

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...................................

kctune (11i only) lsattr -EHl sys0 sysdef kmtune Note: only a few kernel parameters can be changed kmsystem /usr/sam/lbin/getkinfo -f /stand/vmunix -o /tmp/kernel.data chdev -l sys0 -a <parameter>=<value> Note: most parameters are dynamically changed in AIX , for example memory segments are dynamically adjusted

display kern

edit and update file then reboot: /etc/system

build kernel

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 ipcs -a ipcs -a

cd /stand/build /usr/lbin/sysadm/system_prep -v -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

build kerne

interprocess communication

ipcs -a

ipcs -a

ipcs -a

interproces communica

Services
Solaris 10 display services svcs -a inetadm -l svcadm enable nfs svcadm disable nfs svcadm refresh nfs svcadm restart nfs Red Hat service --status-all Ubuntu/Debian HP lssrc -a display services startsrc -s <subsystem> startsrc -g <group> stopsrc -s <subsystem> stopsrc -g <group> refresh -s <subsystem> stopsrc -s <subsystem> startsrc -s <subsystem> AIX

There is no services or chkconfig command use There is no services or chkconfig command the old fashioned way /etc/init.d/<service> use the old fashioned way /sbin/init.d /<service>

start services stop services reload service restart service

service nfs start service nfs stop service nfs reload service nfs restart

start services stop services reload service restart service

4 of 6

2/7/2012 9:53 PM

Unix Commands

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm

service status service dependencies service dependants service logging, etc change service startup

svcs nfs svcs -d network svcs -D network /var/svc/log /var/svc/manifest /lib/svc/method n/a

service nfs staus n/a n/a n/a

lssrc -a n/a n/a /var/adm/ras /etc/syslog.conf /etc/rc.tcpip n/a

service status service dependencies service dependants service logging, etc change service startup

chkconfig --levels 2345 nfs on

Patching / Software
Solaris display installed patches showrev -p patchadd -p patchadd patchadd -M <dir> (multiple patches) adding patch patch -p1 <patch> zcat patch46.gz | patch -p1 Note: -p = # of path stripping removing patch patchrm pkginfo (all packages) pkginfo -l (single package) pkgchk -l -p <file> (file belongs) patch -R -p1 <patch> rpm rpm rpm rpm -qa (all packages) -q (single package) -qf (file belongs) -qi <package> (very detailed) dpkg dpkg dpkg dpkg dpkg -l -S <search string> (search) -S <filename> (file belongs) -s <package> (status) -p <package> (detailed) swcopy (install patch into depot) swinstall (install patch from depot) Note: the swagentd daemon must be running swremove swlist -l bundle <bundle> swlist -l product <product> ## check a package swlist -s <full_path/software> installp -r lslpp lslpp lslpp lslpp rpm rpm rpm rpm -L all (all filesets) -L <package> (single fileset) -w <file> (file belongs) -ha (history of filesets) removing patch Red Hat Ubuntu/Debian swlist -l bundle swlist -l product swlist -l patch HP instfix -ia display installed patches instfix -k adding patch AIX

display installed packages

-qa (all packages) -q (single package) -qf (file belongs) -qi <package> (very detailed)

display installed packages

oslevel -g (install packkages above os level) whereis <filename> which_fileset <filename> pkgadd rpm -Uhv (updates/installs if not already) dpkg -i <package> rpm -ihv (install) swinstall swinstall -s <full_path/software> installp -a installp -c (cleanup after failed install) rpm -i geninstall (generic installer: installp, RPM, etc) pkgrm rpm -e <package> dpkg -r <package> (do not remove config files) dpkg -P <package> (remove config files) swremove installp -u (commited packages) installp -r (applied packages) rpm -e <package> geninstall -u <package> pkginfo -l pkginfo -p pkgchk -l <package> | grep -i pathname List files in package rpm -V <package> n/a swverity <fileset> (see /var/adm/sw/swagent.log) lppchk -v rpm -V <package> rpm -ql <package> dpkg -L <package> (list files) swlist -l file <product> lslpp -f <fileset> rpm -ql <package> /var/sadm Package directory /var/lib/rpm /var/lib/dpkg/info /var/adm/sw /usr/lpp /var/lib/rpm ldd <file> ldd <file> ldd <file> chatr <file> ldd <file> verify package removing packages adding package

adding package

removing packages

verify package

List files in package

Package directory

List libraries required for binary program

List libraries required for program

Accounts
Solaris cat /etc/passwd display users logins -x create a user remove a user useradd userdel useradd system-config-users (GUI) userdel system-config-users (GUI) useradd userdel useradd sam userdel sam Red Hat cat /etc/passwd system-config-users (GUI) Ubuntu/Debian cat /etc/passwd cat /etc/passwd logins -x HP cat /etc/passwd display users lsuser -f ALL (detailed) mkuser useradd rmuser userdel chuser -a usermod passwd -f passwd -s chfn <username> chfn <username><shell> passwd pwdadm pwdck -t ALL mkgroup <group name> rmgroup <group name> chgroup <attribute><group name> /etc/security/passwd id whoami who w uptime (displays # of users logged in) finger # License information lslicense chlicense # Maximum number of processes for a user lsattr -D -l sys0 -a maxuproc chdev -l sys0 -a maxuproc=<number> useful group commands groups setpgrp newgrp groups groups groups setprivgrp groups setgroups lsgroup ALL useful group commands useful user commands create a user remove a user AIX

modify a user

usermod

usermod system-config-users (GUI)

usermod

usermod sam

modify a user

change user password create a group remove a group modify a goup password files

passwd groupadd groupdel groupmod /etc/passwd /etc/shadow id -a whoami who w finger

passwd groupadd groupdel groupmod /etc/passwd /etc/shadow id -a whoami who w finger

passwd groupadd groupdel groupmod /etc/passwd /etc/shadow id -a whoami who w finger

passwd groupadd groupdel groupmod /etc/passwd /tcb/files/auth/r/root (trusted system) id whoami who w uptime (displays # of users logged in) finger

change user password create a group remove a group modify a goup password files

useful user commands

NFS
Solaris NFS Daemons server: mountd, nfsd client: statd, lockd /etc/dfs/dfstab /etc/dfs/sharetab /etc/rmtab /etc/rmtab dfshares showmount -e localhost /etc/dfs/dfstab (edit and add share) share <path> create nfs share Red Hat server: rpc.mountd,nfsd client: rpc.statd, lockd /etc/exports /var/lib/nfs/etab /var/lib/nfs/xtab /var/lib/nfs/rmtab showmount -e localhost redhat-config-nfs (GUI) Ubuntu/Debian server: rpc.mountd,nfsd client: rpc.statd, lockd /etc/exports /var/lib/nfs/etab /var/lib/nfs/xtab /var/lib/nfs/rmtab showmount -e localhost /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) /etc/exports (edit and remove share) exportfs -rav (export the shares) /etc/rc.config.d/nfsconf (edit) exportfs -au (unshare all) exportfs -u /home/vallep /etc/exports (edit and remove share) /sbin/init.d/nfs.core start /sbin/init.d/nfs.server start /sbin/init.d/nfs.client start rmnfsexp -d <directory> (unshares and removes from file) exportfs -u <filesystem> unshareall mknfs chnfs startsrc -s nfsd startsrc -s rpc.mountd st u HP server: rpc.mountd, nfsd client: rpc.statd, lockd /etc/exports /etc/xtab /etc/rmtab showmount -e localhost server: rpc.mountd, nfsd client: rpc.statd, rpc.lockd /etc/exports /etc/xtab /etc/xtab exportfs showmount -e localhost mknfsexp -d <directory> mknfsmnt shareall cr AIX N

NFS files List nfs clients that have a remote mount display nfs shares

N Li re di

/etc/exports (edit and add share) ## dfstab example /sbin/service nfs reload share -F nfs -d "jumpstart" /export/jumpstart ## /etc/exports example /export *(rw,fsid=0,insecure,no_root_squash,sync) 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) /etc/exports (edit and add share) exportfs -a

uncreate nfs share

start/change nfs daemons

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

/sbin/service nfs start

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

5 of 6

2/7/2012 9:53 PM

Unix Commands

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm

svcadm disable nfs/server /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 /sbin/init.d/nfs.client stop /sbin/init.d/nfs.server stop /sbin/init.d/nfs.core stop ps -ef | grep <nfs daemons> exportfs -a nfsstat n/a rmnfs stopsrc -s nfsd stopsrc -s rpc.mountd lssrc -a |grep -i nfs exportfs -av nfsstat nfso -a nfso -o <option>=<value> exportfs (display options) 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 n/a n/a so p st nf nf nf nf

stop nfs daemons nfs status nfs reload nfs performanace nfs Options

ps -ef|grep < nfs daemons> shareall nfsstat n/a

/sbin/service nfs status /sbin/service nfs reload nfsstat cat /var/lib/nfs/etab

/etc/init.d/nfs-kernel-server status exportfs -rav (export the shares) nfsstat cat /var/lib/nfs/etab

NTP
Solaris Time daemons xntpd # Solaris 8 /etc/ntp.conf /etc/ntp.server /etc/ntp.client ntp setup /etc/rc2.d/xntpd [start|stop] # Solaris 10 /etc/inet/ntp.server /etc/inet/ntp.client svcadm enable ntpd /lib/svc/method/xntp ntp daemon options /etc/sysconfig/ntpd /etc/default/ntp /etc/rc.config.d/netdaemons startsrc -s xntpd -a "-x" /etc/rc.tcpip ntpq -p ntptrace ntpq -p ntptrace ntpq -p ntptrace ntpq -p ntpdate (set the date) ntpq -p ntptrace ntpdate ntpd /etc/ntp.conf (edit with ntp servers) dateconfig (GUI) chkconfig --list ntpd chkconfig --level 2345 ntpd on /sbin/service ntpd start Red Hat ntpd Ubuntu/Debian xntpd /etc/rc.config.d/netdaemons (set XNTPD to 1) /etc/ntp.conf HP xntpd AIX Time daemons

/etc/default/ntp /etc/ntp.conf /etc/init.d/ntp [start|stop|restart]

/etc/ntp.conf startsrc -s xntpd stopsrc -s xntpd lslpp -L all|grep xntpd ntp setup

ntp daemon options

NTP Trace commands

NTP Trace commands

Log Files
Solaris messages syslog mail cron /var/cron/log /var/adm/messages dmesg /var/adm/messages /var/log/syslog Red Hat /var/log/messages /var/log/syslog /var/log/mail /var/log/cron /var/log/boot dmesg Ubuntu/Debian /var/log/messages /var/log/syslog /var/log/mail.* /var/log/cron.log /var/log/boot dmesg HP /var/adm/syslog/syslog.log /var/adm/syslog/syslog.log /var/adm/syslog/mail.log /var/adm/cron/log /var/adm/syslog/syslog.log dmesg /var/adm/ras /var/adm/ras /usr/spool/mqueue/syslog /var/adm/cron/log /var/adm/ras boot alog -o -t boot alog -o -t console alog -L (list all the logs available) /usr/lib/errdemon -l (display attributes) /usr/lib/errdemon (start error logging) /usr/lib/errstop (stop error logging) # use with above errorlog file errpt (summary errorlog report) errpt -a (detailed errorlog report) errpt -j <identifier> (single errorlog report) errclear (clears errorlog) errclear -d <class><days> (clears class errors) errlogger "message upto 230 chars" boot AIX messages syslog mail cron

Error logging logger

logger

logger

logger

Error logging

Security
Solaris Checking the passwd file checking the group file pwck grpck # No reboot required /etc/default/login console login (allow/deny) Note: you may need to create this file chsec -f /etc/security/user -s root if it does not exist pwck grpck # No reboot required /etc/securetty Red Hat Ubuntu/Debian pwck grpck # No reboot required /etc/securetty pwck grpck # No reboot required /etc/securetty HP pwdck -t ALL usrck -t ALL grpck # No reboot required /etc/security/user console login (allow/deny) AIX Checking the passwd file checking the group file

Misc
Solaris eeprom startup setenv boot-device shutdown shutdown shutdown shutdown -h (halt) -r (reboot) -f (fast reboot no fsck) -F (force fsck) grub (GUI) lilo (text based) Red Hat grub (GUI) Ubuntu/Debian HP setboot -p <primary path> setboot -a <alternate path> # autoboot sequnce setboot -b [on|off] 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 halt init poweroff reboot shutdown telinit halt init poweroff reboot shutdown telinit init reboot shutdown init shutdown reboot telinit halt shutdown -h now (halt) shutdown -r now(reboot) shutdown -F (fast shutdown) shutdown -Fr (fast shutdown and reboot) AIX bootlist -m normal hdisk0 hdisk1 startup

shutdown -i5 -g0 -y (power down) shutdown -i6 -g0 -y (reboot) shutdown -i0 -g0 -y (OK prompt) shutdown reboot -- -r (reboot/reconfigure) touch /reconfigure

shutdown

Change run level

halt init poweroff reboot shutdown telinit uadmin

Change run level

init status 0 1 2 3 4 5 6

0 1 2 3 4 5 6

shutdown single user n/a Multi-user n/a power off reboot

0123456-

halt single user multiuser (no networking) multiuser (networking) unused GUI reboot

0123456-

halt single user multiuser (default) same as 2 same as 2 same as 2 reboot

0123456-

halt single users multiuser (networking) multiuser (networking, NFS, and CDE GUI) (default) multiuser (netwrking, NFS, and VUE GUI) n/a n/a

0 - reserved 1 - reserved 2 - multiuser mode with NFS 3 - user defined 4 - user defined 5 - user defined 6 - user defined 7-9 - user defined # change default - change the initdefault line vi /etc/inittab

init status 0 1 2 3 4 5 6

# change default vi /etc/inittab -s single user -a interactive -x no device drivers (used in clustering) -r reconfigure devices -m milestone

# change default vi /etc/inittab 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

# change default - change all the telinit vi /etc/event.d/rc-default

# change default - change the initdefault line vi /etc/inittab interact with IPL? Y # single user ISL> hpux -is # Logical volume maintanence mode ISL> hpux -lm # No quroum check ISL> hpux -lq

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

Based on 9114-275 workstation 1. switch off the machine 2. power on and enter the SMS menu Note: to enter the SMS menu press numeric 1 after the word keyboard but before the word speaker Startup options

Startup options

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

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

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

/sbin/init.d /etc/rc.config.d (startup config files) /sbin/rc0.d - /sbin/rc6.d

/etc/rc.d /etc/rc.d/init.d /etc/rc.d/rc2.d - rc9.d /etc/rc.* (config files for auto-starting) also uses the System Resource Controller startup scripts

6 of 6

2/7/2012 9:53 PM

You might also like