0% found this document useful (0 votes)
68 views

Common Unix Commands: Sysinfo

This document provides commands to view system information on various Unix/Linux systems. Some key commands include: - sysinfo, dmidecode - Display system hardware information like CPU, memory, disks - cat /proc/cpuinfo, lscpu - Show CPU details - free, cat /proc/meminfo - View physical memory details - fdisk, parted, lsblk - List disk drives and partitions - uname -a - Show kernel/OS information - cat /proc/version - View kernel version

Uploaded by

rahulbisht1694
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

Common Unix Commands: Sysinfo

This document provides commands to view system information on various Unix/Linux systems. Some key commands include: - sysinfo, dmidecode - Display system hardware information like CPU, memory, disks - cat /proc/cpuinfo, lscpu - Show CPU details - free, cat /proc/meminfo - View physical memory details - fdisk, parted, lsblk - List disk drives and partitions - uname -a - Show kernel/OS information - cat /proc/version - View kernel version

Uploaded by

rahulbisht1694
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

29/07/2016 Unix Commands

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

sysinfo

  Solaris Red Hat Ubuntu/Debian HP­UX


cat /etc/release cat /etc/enterprise­release cat /etc/lsb­release /stand/kernrel
cat /etc/redhat­release
lsb_release ­a
Server Release info lsb_release ­a

cat /proc/version

/usr/platform/`uname ­i`/sbin/prtdiag ­v dmidecode dmidecode


model
Server type
uname ­a

lspci
prtdiag ­v lspci lsusb ioscan
prtconf ­D  lsusb lshal ioscan ­fun [disk|tape|lan]
prtpicl ­v [­c <class>] lshal
/opt/ignite/bin/print_manifest
picl = platform information and control Note: hal = hardware abstraction layer cat /var/opt/ignite/local/manifest/manifest.info
library
Hardware Info

Operating System uname ­a uname ­a uname ­a uname ­a


/usr/platform/`uname ­i`/sbin/prtdiag ­v
prtconf | grep ­i mem cat /proc/meminfo (detailed) cat /proc/meminfo (detailed) dmesg | grep ­i physical
free ­om free ­om /usr/sam/lbin/getmem
Memory /opt/ignite/bin/print_manifest
cat /proc/slabinfo cat /proc/slabinfo
cat /var/opt/ignite/local/manifest/manifest.info

cat /proc/cpuinfo (detailed) cat /proc/cpuinfo (detailed)
/usr/platform/`uname ­i`/sbin/prtdiag ­v /opt/ignite/bin/print_manifest
sam ­> performance monitors ­> system pro
## display,offline,online
CPU (type, number, etc)
psrinfo cat /var/opt/ignite/local/manifest/manifest.info
psradm ­f 0 (offline) 
psradm ­n 0 (online) 

fdisk ­l fdisk ­l ioscan ­funC disk


format sfdisk ­l (advanced server) sfdisk ­l (advanced server)
prtvtoc <device> parted <device> print parted <device> print
partprobe ­s <device>  partprobe <device>
format ­e (to convert EFI (zfs) to SMI)
Disk Drives
smartctl ­a <device>
Note:
EFI ­ Extensible Firmware Interface
SMI ­ Sun Microsystems Inc

/boot/initrd.?????.img /boot/initrd.img­?????­server /stand/vmunix


/kernel/genunix /boot/vmlinuz /boot/vmlinuz­????­server

Kernel File and associated /platform/`uname ­m`/kernel
directories /platform/i86pc/kernel
/kernel
/usr/kernel

isainfo ­kv (solaris 9+) uname ­a uname ­a


isalist (sparc v9 will be listed first) uname ­m uname ­m getconf KERNEL_BITS ( version 11)
isainfo ­b getconf ­a |grep ­i 'long_bit' getconf ­a |grep ­i 'long_bit' /opt/ignite/bin/print_manifest |grep ­i 'os mod
cat /proc/version
HPUX < version 11 all 32 bit
Kernel 32 or 64
Note: determine if system supports 64 bit
getconf HW_CPU_SUPP_BITS
/opt/ignite/bin/print_manifest |grep ­i 'hw cap

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


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

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 1/11
29/07/2016 Unix Commands

n/a /proc/interrupts /proc/interrupts n/a


Display IRQ, IO ports and DMA /proc/ioports /proc/ioports
/proc/dma /proc/dma
admintool linuxconf linuxconf sam
GUI admin tool

Memory and Swap

  Solaris Red Hat Ubuntu/Debian HP


/usr/platform/`uname ­ cat /proc/meminfo (detailed) cat /proc/meminfo (detailed) prtconf ­m 
i`/sbin/prtdiag ­v free ­om free ­om dmesg | grep ­i physical prtconf |grep ­i memory
prtconf | grep ­i mem /usr/sam/lbin/getmem lsattr ­El sys0 ­a realmem
Memory /opt/ignite/bin/print_manifest bootinfo ­r
cat /var/opt/ignite/local/manifest/manifest.info

page size /usr/bin/pagesize /usr/bin/getconf ­a| egrep ­i /usr/bin/getconf ­a| egrep ­i dmesg |grep ­i physical pagesize


(memory) 'pagesize|page_size' 'pagesize|page_size' pagesize ­a (display all supported
swap ­l cat /proc/swaps (detailed) cat /proc/swaps (detailed) swapinfo (displayed in KB) lsps ­a (detailed) 
display swap swap ­s swapon ­s swapon ­s swapinfo ­m (display in Mb) lsps ­s
swapinfo ­tm (total / Mb)
device: Create logical volume or filesystem mkps ­a ­s 4 ­n <volume group>
mkfile 5m /var/swapfile  device: create partition with fdisk (type 82)
swap ­a /var/swapfile  create partition with fdisk (type 82) file(create 50MB swap file): swapon <device> | ­f <logical device> # change the attributes 
file(create 50MB swap file): dd if=/dev/zero of=/var/swapfile swapon ­p 3 <device> | ­f <logical device> chps ­a n paging00 (don't use aft
update /etc/vfstab dd if=/dev/zero of=/var/swapfile bs=1024 count=50000
bs=1024 count=50000 update /etc/fstab # change the logical volume attrib
mkswap <device>|<file> chlv ­n <new name> <old old> (c
adding swap mkswap <device>|<file> swapon <device>|<file> Note: ­p = priority swap number . The nswapdev
swapon <device>|<file> tunable system parameter controls the maximum Note:
update /etc/fstab number of swap devices.
update /etc/fstab ­a reconfigure paging space after
­s size of the page space (logical
­n activiates the paging space (us

also see /etc/swapspaces file
update /etc/vfstab swapoff <device>|<file> swapoff <device>|<file> remove entry from /etc/fstab swapoff /dev/paging00
removing swap ­d reboot rmps paging00 
swap Remove device or file as normal Remove device or file as normal
Note: paging space must be deac

Disks, Filesystems and Devices

  Solaris Red Hat Ubuntu/Debian


fdisk ­l ioscan ­funC disk
format fdisk ­l sfdisk ­l (advanced server)
prtvtoc <device> sfdisk ­l (advanced server) parted <device> print
cfgadm ­al parted <device> print partprobe <device>
fcinfo hba­port partprobe <device>
luxadm probe
mpathadm list initiator­port  udevadm info ­q all ­n /dev/sda1
mpathadm show <initiator­port name> blkid
Disk Drives iscsiadm list initiator­node dmsetup [ls|info]
iscsiadm list discovery

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

Note:
EFI ­ Extensible Firmware Interface
SMI ­ Sun Microsystems Inc

format hdparm ­i /dev/hda hdparm ­i /dev/hda


iostat ­En hdparm ­I /dev/hda (detailed) hdparm ­I /dev/hda (detailed) diskinfo ­v /dev/rdsk/c0t4d
luxadm inq <disk> (A5x00 disk arrays) number)
hdparm ­Tt /dev/hda (speed test) haparm ­Tt /dev/hda (speed test) /opt/ignite/bin/print_manife

sdparm ­i /dev/sdb  sdparm ­i /dev/sdb  ## Insure that the online d


been installed
cat /proc/ide/ide0/hda/model cat /proc/ide/ide0/hda/model swlist ­l bundle | grep 'Sup
Disk serial Number, type, cat /proc/scsi/scsi cat /proc/scsi/scsi
etc ## Command­Line Suppor
## The run cstm 
cstm
cstm> map
cstm> sel dev 4       (selec
cstm> info
cstm> il                  (obtain 
cstm> quit 

prtvtoc <device>
fdisk ­l fdisk ­l lvlnboot ­v /dev/vg00 
cat /etc/vfstab sfdisk ­l (advanced server) sfdisk ­l (advanced server) lifls ­Clv <device>

cat /proc/partitions (very high level) cat /proc/partitions (very high level) # Display the LIF contents


cat /etc/fstab cat /etc/fstab lifcp /dev/dsk/c0t6d0:AUTO

  cat /etc/fstab
Disk disk partitions
Note: Boot programs are s
Logical Interchange Forma
file system. For a device to
volume on that device mus
(the initial system loader) a
bootstrap utility) LIF files. I

use format to partition the disk then just use the mknod /dev/rawctl c 162 0 Just create a new LVOL w


slice as a raw partition, remember to use the ## Old way  mknod /dev/raw/raw0 c 162 1
character device /etc/sysconfig/rawdevices mknod /dev/raw/raw1 c 162 2
service rawdevices start ln ­s /dev/rawctl /dev/raw/rawctl
chkconfig rawdevices on
## map raw devices to the disk
List Raw Partitions ## New way, Edit below file  raw /dev/raw/raw1 /dev/sdb1
/etc/udev/rules.d/60­raw.rules
udevinfo ­d or udevadm info ## display raw devices

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 2/11
29/07/2016 Unix Commands
## Display raw partitions  raw ­qa
raw ­qa

format (use analyse ) badblocks badblocks dd if=/dev/rdsk/cXtYd0 of=


Bad Blocks
Note: no errors means dis
df ­k df ­k  df ­k bdf
Filesystem commands df ­h  df ­h df ­h df [­egiklnvfb]

newfs ­v <raw device> mkfs ­t ext3 /dev/sdb1 newfs ­F vxfs ­o largefiles 


mkfs ­t ext3 /dev/sdb1 
# Display how the filesystem was created  mke2fs ­t ext4 /dev/sdb1 mkfs ­F vxfs ­o largefiles /d
newfs ­Nv <filesystem>
# all point to mke2fs  Note: mkfs and newfs are 
mkfs.ext2 /sbin/fs_wrapper 
mkfs.ext3
mkfs.ext4 
Filesystem (create|remove)
cat /etc/mke2fs.conf

tunefs tunefs ­v <filesystem>
fstyp ­v <device> |grep ­i minfree tune2fs tune2fs vxtunefs ­v <filesystem> 
tune2fs ­l /dev/sda1 tune2fs ­l /dev/sda1 fstyp ­v <filesystem>
Tune Filesystems # change reserved blocks percentage to 1% # change reserved blocks percentage to 1% # Disk fragmentation
tune2fs ­m 1 /dev/sda1 tune2fs ­m 1 /dev/sda1 fsadm ­F vxfs ­E / (report)
fsadm ­F vxfs ­e / (defrag)

touch /forcefsck
touch /forcefsck shutdown ­r now  
shutdown ­Fr now
fsck.mode=force (kernel parameter)   
Force fsck # Check to see filesystem needs checking tune2fs ­l /dev/sdb<?> |grep ­i 'filesystem state' 
fstyp ­v <filesystem> | grep fsclean # Look at the second line t
tune2fs ­l /dev/sdb<?> |grep ­i 'filesystem state' # needs checking 
# edit /etc/default/rcS change below so 
# you dont have to hang around  tunefs ­v <filesystem>
FSCKFIX=yes
ufsdump|ufsrestore dump/restore dump/restore fbackup/frecover
tar tar tar dump/restore
dd dd dd ftio 
backup filesystem
cpio cpio cpio tar
dd
cpio
eeprom |grep boot­device  cat /boot/grub/menu.lst setboot
prtconf ­pv |grep bootpath  cat /boot/grub/grub.conf
prtpicl ­v|grep ':bootpath' cat /etc/lilo.conf
Display the boot device
grub = grand unified boot loader
lilo = linux loader

setenv boot­device [<device>|<alias>] /boot/grub/menu.lst setboot ­p <primary path>


eeprom boot­device [<device>|<alias>] /boot/grub/grub.conf setboot ­a <alternate path>
Setting the boot device /etc/lilo.conf
# autoboot sequnce 
  setboot ­b [on|off]

installboot /usr/platform/`uname ­ grub­install <raw­device>  grub­install <raw­device> mkboot ­l <device>


Creating boot device (MBR) i`/lib/fs/ufs/bootblk <raw­device> lilo ­v
Note: we are treating the d
fdformat ­v ­U floppy ­­probe (use device obtained below )  n/a n/a
volcheck ­v floppy ­­createrc > /etc/fd0
Format floppy drive
newfs ­v /vol/disk/aliases/floppy0 floppy ­­format /dev/fd0
mkfs /dev/fd0
volrmmount ­l floppy0 mount /dev/fd0 /mnt/floppy n/a n/a
mount/unmount floppy
eject floppy umount /mnt/floppy
mount ­F hsfs ­o ro <device path> mount ­rt iso9660 /dev/cdrom /mnt/cdrom
/cdrom/cdrom0 mount ­rt iso9660 /dev/cdrom /mnt/cdrom umount /mnt/cdrom mount ­rF cdfs /dev/dsk/c1
umount /cdrom/cdrom0 umount /mnt/cdrom eject cdrom
mount/unmount CDROM eject cdrom start: /usr/sbin/pps_mount
/etc/init.d/volmgr start pps_mount
eject cdrom
     
lofiadm ­a <iso image> /dev/lofi/1
mount ­F hsfs ­o ro /dev/lofi/1 /mnt
mount/umount ISO image
# to list
lofiadm

n/a mount ­o remount,rw / mount ­o remount,rw / mount_vxfs ­o remount,ro 

remount a filesystem

n/a mkbootdisk `uname ­r` (boot diskette) n/a recovery tape (preview)


create boot disk or
make_tape_recovery ­v ­l 
recovery tape
/opt/ignite/bin/make_recov
ok> boot cdrom ­s using the grub window append the word single to using the grub window append the word single to enter PDC
the kernel line the kernel line > search 
>boot p1 (cdrom) 
interact with IPL? Y
boot cdrom/diskette (single ISL> hpux ­is
user)

ok> boot ­as f10 or f12 f10 or f12 >boot pri 


interact with IPL? Y
ISL> hpux ­lm

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 3/11
29/07/2016 Unix Commands
boot into maintenace mode

floppy:
floppy: floppy: floppy:
disk: /dev/fd0 /dev/fd0 n/a
/dev/dsk/c0t0d0s0
disk: disk: disk:
tape: /dev/hda or /dev/sda  /dev/hda or /dev/sda  /dev/dsk/c0t6d0
/dev/rmt/0ucb /dev/hdb or /dev/sdb /dev/hdb or /dev/sdb
Device paths tape:
cdrom: tape: tape: /dev/dsk/rmt/0
/dev/dsk/c0t6d0s0
cdrom: cdrom: cdrom:
/dev/scd0 (external usb cd)
/dev/hda (depends on number of IDE disks) /dev/hda (depends on number of IDE disks) /dev/dsk/c1t6d0

drvconfig /dev/MAKEDEV <device> /dev/MAKEDEV <device>


devlinks insf ­C tape (Class)
update /dev directory disks|tapes|ports
insf ­H 0.1.0 ­e (recreate d
devfsadm ( solaris 8, 9, 10)

rem_drv     # remove all devices from 
rmsf ­k ­H 52.6.0
remove or change a device

prtconf ­D  cat /proc/devices cat /proc/devices lsdev


sysdef

list device drivers

Networking

  Solaris Red Hat Ubuntu/Debian


/etc/hostname.hme0 /etc/sysconfig/network /etc/network/interfaces /etc/rc.config.d/net
Basic network information 
/etc/sysconfig/network­scripts/ifcfg­eth0
  (hostname, ip address)

ifconfig ifconfig ioscan ­funC lan (l


prtdiag ­v  system­config­network (GUI) lanscan ­v (list con
ifconfig ­a  ifconfig lan0 (indiv

kstat hme:0:parameters:<param name> 
kstat e1000g:0:parameters:<param name>

module:instance:name:statistics

# Solaris 11 
netadm list
displaying network interfaces
dladm show­phys
dladm show­link
dladm show­linkprop
dladm show­vnic
dladm show­etherstub 

ipadm show­if
ipadm show­ifprop 
ipadm show­addr
ipadm show­addrprop

ifconfig ifconfig ifconfig <interface>


ifconfig

# Solaris 11 ­ Automatic (using profiles) 
netadm enable ­p ncp Automatic
netcfg       (use by Automatic) 

# Solaris 11 ­ Manual
netadm enable ­p ncp DefaultFixed
netcfg 
Configure network interface
dladm create­vnic
dladm delete­vnic 
dladm rename­link

dladm create­etherstub

ipadm create­ip net1 
ipadm create­addr ­T static ­a 192.168.0.110/24 net1/pfv 
ipadm delete­ip
ipadm delete­addr

ifconfig qfe0 up /sbin/ifup eth0 /sbin/ifup eth0


ifconfig qfe0 down /sbin/ifdown eth0 /sbin/ifdown eth0 ifconfig lan0 up
ifconfig lan0 down
Starting and stopping a network
interface
note: there is no "i
"ifconfig <interface

ndd ­set <device> <parm> <value> (dynamically)  mii­tool ­F 100baseTx­FD eth0 ethtool ­s eth1 speed 100 duplex full ndd ­set <device> 


/etc/system (edit and update then reboot ­ permanent) ethtool ­s eth1 speed 100 duplex full lanadmin ­X <optio
Setting NIC speed

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 4/11
29/07/2016 Unix Commands

ethtool eth0 
ndd ­get <device> <parm> mii­tool ­v  lanadmin ­> lan ­>
ethtool eth1 sysctl ­a |grep net*
# List parameters  ethtool ­t eth0 online  ## options support
Change NIC parameters ndd ­get /dev/hme \? ndd ­get /dev/ip ?
ndd ­get /dev/e1000g0 \? sysctl ­a | grep net* ndd ­get /dev/tcp ?
ndd ­get /dev/ip \? ndd ­get /dev/arp ?
ndd ­get /dev/tcp \? ndd ­get /dev/udp 

      netstat ­i [­I interfa
Display NIC statistics netstat ­s

ifconfig ­a (as user root) ifconfig ifconfig lanscan


display MAC address
system­config­network (GUI)
snoop ­d <interface>
tcpdump ­i <interface> tcpdump ­i <interface> nettl ­start
nettl ­status all
ethereal (needs to be installed) ethereal (needs to be installed) nettl ­tn pduin pdu
Displaying network packets /var/adm/LAN
nettl ­stop

use netfmt to displ

/etc/defaultrouter edit /etc/network/interfaces /etc/rc.config.d/net


edit /etc/sysconfig/network
default router route add default <gateway>  add: gateway <IP address>
route ­p add default <gateway> (persist changes) add: GATEWAY=<IP address>

netstat ­rn netstat ­rn netstat ­rn netstat ­rn


display routing table route ­n route ­n

You buy an optiona
if_mpadm ­d           (detach) ifenslave ­d bond0 eth1   (detach)  ifenslave ­d bond0 eth1   (detach)  Aggragation.
if_mpadm ­r           (reattach) ifenslave bond0 eth1       (reattach) ifenslave bond0 eth1       (reattach)

tail /var/adm/messages cat /proc/net/bonding/bond0 cat /proc/net/bonding/bond0

# create bonding
/etc/sysconfig/network­scripts/ifcfg­bond0
Test IPMP, Bonding # modprobe
/etc/modprobe.d/bonding.conf

# for bonding options ­ use BONDING_OPTS 
/etc/sysconfig/network­scripts/ifcfg­bond0

# see bonding mode
cat /sys/class/net/bond0/bonding/mode

/etc/sysconfig/network /etc/hostname set_parms hostnam


change the following files: /etc/hosts /etc/hosts

/etc/nodename sysctl ­a |grep hostname sysctl ­a |grep hostname


/etc/hostname.<interface>
/etc/inet/hosts
/etc/inet/ipnodes
/etc/net ­ few files in here as well 
change the hostname
# Solaris 11
svccfg ­s system/identity:node listprop config/nodename

svcfg ­s system/identity:node setprop config/nodename =
astring: hostname
svcadm refresh system/identity:node
svcadm restart indentity:node

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


/etc/resolv.conf

# Solaris 11 ­ You need to use the svccfg command
svccfg ­s dns/client listprop config/nameserver
svccfg ­s dns/client listprop config/search
svccfg ­s name­service/switch listprop config/host
svccfg ­s name­service/switch listprop config/password

svcprop <pattern>
setup DNS
Note: just use listprop on its own to view all options 

svccfg ­s "dns/client" setprop "config/nameserver =
net_address: (192.168.0.1)"
svccfg ­s "dns/client" setprop 'config/domain = astring:
("datadisk.co.uk")' 
svccfg ­s "name­service/switch" setprop 'config/host =
astring: "file dns"'
svcadm refresh name­service/switch
svcadm refresh dns/client

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


/etc/nsswitch.conf /etc/host.conf /etc/host.conf /etc/resolv.conf
/etc/resolv.conf /etc/resolv.conf /etc/resolv.conf
Name service switch file (DNS
client) # Solaris 11 ­ you need to use the svccfg command 
see above

svcadm restart system/name­service­cache:default ## if installed    n/a


Flush DNS cache
service nscd restart
/etc/defaultdomain /etc/sysconfig/network  (HOSTNAME option) /etc/host /etc/rc.config.d/net
/etc/resolv.conf  /etc/resolv.conf
Domain Name
Note: for NIS use the NISDOMAIN option
route ­n get <hostname> ip route get <IP address>  ip route get <IP address> n/a
Obtain IP Address routing
traceroute traceroute traceroute

Boot (jumpstart) servers: Boot (jumpstart) servers: Boot (jumpstart) servers: Boot (jumpstart) se

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 5/11
29/07/2016 Unix Commands
rpcinfo ­b bootparam 1 rpcinfo ­b bootparam 1 rpcinfo ­b bootparam 1 rpcinfo ­b bootpara

NFS servers: NFS servers: NFS servers: NFS servers:


Find Services on the network rpcinfo ­b mountd 1 rpcinfo ­b mountd 1 rpcinfo ­b mountd 1 rpcinfo ­b mountd 

NIS servers/slaves: NIS servers/slaves: NIS servers/slaves: NIS servers/slaves


rpcinfo ­b ypserv 1 rpcinfo ­u <yp server> ypserv rpcinfo ­u <yp server> ypserv rpcinfo ­b ypserv 1

Crash Dump

  Solaris Red Hat Ubuntu/Debian HP AIX

dumpadm ­d diskdump diskdump edit /stand/system sysdumpdev ­l (list dump destination)


<device> netdump netdump sysdumpdev ­e (estimates dumpsize)
coreadm kdump (part of kexec rpm) kdump (part of kexec rpm) add either: sysdumpdev ­L (info)
dump 2/0/1.5.0
crash (used to /etc/kdump.conf (select where you /etc/kdump.conf (select where you dump lvol sysdumpstart ­p (start dump primary)
analyse crash dumps) want the dump to go)  want the dump to go)  dump none sysdumpstart ­s (start dump secondary)
Crash Dump adb (used to analyse service kdump start service kdump start
crash dumps) chkconfig kdump on chkconfig kdump on # crash config file # set the dump device permanently 
/etc/rc.config.d/savecrash sysdumpdev ­p <dump device> ­P 
## to crash the system ## to crash the system
echo "c" > /proc/sysrq­trigger echo "c" > /proc/sysrq­trigger   # analyse dump file
echo "stat\n status\n t ­m" | crash /var/adm/ras/vmcore.0
crash (used to analyse crash dumps) crash (used to analyse crash dumps)

Performance Monitoring and Diagnostics

  Solaris Red Hat Ubuntu/Debian HP AIX  


top (sunfreeware) top top top
prstat  sar sar sar topas ­P
sar mpstat mpstat w          (load average) topas ­L  (logical partitions) 
mpstat w          (load average) w          (load average) uptime   (load average)  mpstat
w          (load average) uptime   (load average)  uptime   (load average)  ps sar ­c 
uptime   (load average)  ps ps vmstat w          (load average)
CPU ps vmstat vmstat glance uptime   (load average)  CPU
vmstat procinfo procinfo sam lparstat
oprofile cat /proc/cpuinfo ps
cat /proc/cpuinfo iostat ­tT 1
tprof
curt 

prstat free free top topas


vmstat vmstat vmstat vmstat vmstat
top top top sar sar ­b
sar procinfo procinfo sam svmon
Memory Memory
slabtop slabtop glance ps
sar sar ipcs ­a
cat /proc/meminfo  cat /proc/meminfo lockstat (version 4) 
rmss 
ndd ethtool ethtool netstat [ent|tok|fddi|atm]stat
netstat mii­tool mii­tool lanadmin netstat
lsof netstat netstat sam netpmon (trcstop to stop trace)
snoop lsof lsof glance 
Network Network I/O
route tcpdump  tcpdump 
ip ip
iptraf iptraf
nmap
sar ­d sar ­d sar ­d iostat topas ­D   (disk)
iostat iostat iostat sar topas ­F   (filesystem) 
vmstat vmstat vmstat sam  iostat
lsof lsof lsof glance sar ­D 
fcstat (fibre)
lvmstat
Disk Disk I/O
filemon (trcstop to stop) 
fileplace

# disk stat history 
chdev ­l sys0 ­a iostat=true
lsattr ­HEl sys0 ­a iostat
truss ­p <pid>  strace ­p <pid> strace ­p <pid> download and install tusc
ppriv ­D ­e <command> topas
tusc ­p <pid> truss
sar 
Application Application
probevue
tprof
svmon ­P <pid>

NFS nfsstat nfsstat nfsstat nfsstat nfsstat NFS


top        
prstat
ps ­ef 
pargs <pid> 
pcred <pid> 
pfiles <pid> 
pflags <pid> 
pgrep <pattern> 
pkill <pattern> 
pmap <pid> 
Process  
pldd <pid> 
preap <pid> 
prun <pid> 
psig <pid> 
pstack <pid> 
pstop <pid> 
ptime <pid> 
ptree <pid> 
pwait <pid> 
pwdx<pid>

Kernel Modules and Parameters

  Solaris Red Hat Ubuntu/Debian HP

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 6/11
29/07/2016 Unix Commands
modinfo cat /proc/modules (more detailed)  cat /proc/modules (more detailed)  kmadmin ­k 
lsmod lsmod
modinfo <module> 
Location: 
Location:  /lib/modules/`uname ­r`/kernel/drivers
display loaded
/lib/modules/`uname ­r`/kernel/drivers
modules
Config:
Config: /etc/modprobe.d/options
/etc/modprobe.conf /etc/modprobe.d
/etc/modprobe.d

modload ­p drv/<module name>  modprobe <module> modprobe <module> kmadmin ­L <module name>


load modules
insmod insmod
modunload ­i <module number> modprobe ­r <module> modprobe ­r <module>
rmmod rmmod kmadmin ­U <module name> 
unload modules
kmadmin ­u <module id>

/etc/system (edit and reboot) /etc/sysctl.conf (edit and update then reboot) /etc/sysctl.conf (edit and update then reboot) kcweb (11i) 


sysctl ­p <filename> sysctl ­p <filename> kctune (11i only)
rebuild kernel (< 11i see below)
sysctl ­w param=value  sysctl ­w param=value 

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

cat /etc/system sysctl ­a sysctl ­a kctune (11i only)


sysdef ­i cat /etc/sysctl.conf cat /etc/sysctl.conf sysdef
display kernel kmtune
parameters cat /proc/sys/kernel/sem cat /proc/sys/kernel/sem kmsystem
cat /proc/sys/kernel/shmmax cat /proc/sys/kernel/shmmax /usr/sam/lbin/getkinfo ­f /stand/vmunix ­o /t
etc................................... etc...................................
cd /usr/src/linux­2.5  
edit and update file then reboot: edit Makefile (change EXTRAVERSION) cd /stand/build
/etc/system make mrproper /usr/lbin/sysadm/system_prep ­v ­s system
backup .config edit system file
make xconfig /usr/sbin/mk_kernel ­s ./system
make dep mv /stand/system /stand/system.old
build kernel mv /stand/vmunix /stand/vmunix.old
make bzImage
make modules mv /stand/build/system /stand
move new kernel mv /stand/build/vmunix_test /stand/vmunix
make modules_install reboot
change lilo/grub config file
reboot
interprocess ipcs ­a ipcs ­a ipcs ­a ipcs ­a
communication

Services

  Solaris Red Hat Ubuntu/Debian HP AIX


service ­­status­all There is no services or chkconfig There is no services or chkconfig lssrc ­a
svcs ­a command use the old fashioned way command 
svcs ­l <service> /etc/init.d/<service> use the old fashioned way
display services
svcs ­vx  /sbin/init.d/<service>
inetadm ­l

svcadm enable nfs service nfs start startsrc ­s <subsystem>


start services
startsrc ­g <group>
svcadm disable nfs service nfs stop stopsrc ­s <subsystem>
stop services
stopsrc ­g <group>
svcadm refresh nfs service nfs reload refresh ­s <subsystem>
reload service
svcadm clear nfs (changes state)
svcadm restart nfs service nfs restart stopsrc ­s <subsystem> 
restart service
startsrc ­s <subsystem>
service status svcs nfs service nfs staus lssrc ­a
service svcs ­d network n/a n/a
dependencies
service dependants svcs ­D network n/a n/a
   
# change or add
svccfg
Service notifications
# verify or confirm 
svcprop

/var/svc/log n/a /var/adm/ras


/var/svc/manifest /etc/syslog.conf 
service logging, etc /lib/svc/method /etc/rc.tcpip
/etc/svc/repository.db
/system/volatile/svc_nonpersist.db
change service n/a chkconfig ­­levels 2345 n/a
startup nfs on
n/a  
# Create your stop/start
# script in /etc/init.d
Add a new service
chkconfig ­­add <script>

Patching / Software

  Solaris Red Hat Ubuntu/Debian


showrev ­p     swlist ­l bundle 
display installed patches patchadd ­p swlist ­l product
swlist ­l patch

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 7/11
29/07/2016 Unix Commands
patchadd patch ­p1 <patch>  
patchadd ­M <dir> (multiple patches)
zcat patch46.gz | patch ­p1 swcopy (install patch into depo
adding patch swinstall (install patch from dep
Note: ­p = # of path stripping
Note: the swagentd daemon m

removing patch patchrm patch ­R ­p1 <patch>   swremove


pkginfo (all packages) rpm ­qa (all packages) dpkg ­l swlist ­l bundle <bundle> 
pkginfo ­l (single package) rpm ­q (single package) dpkg ­S <search string> (search) swlist ­l product <product> 
pkgchk ­l ­p <file> (file belongs)  rpm ­qf (file belongs) dpkg ­S <filename> (file belongs) 
rpm ­qi <package> (very detailed) dpkg ­s <package> (status) ## check a package
# NEW IPS dpkg ­p <package> (detailed)  swlist ­s <full_path/software>
pkg list (all packages)
pkg info (single package)
display installed packages pkg search (find packages and files)

pkgadd rpm ­Uhv (updates/installs if not already) dpkg ­i <package> swinstall


rpm ­ihv (install) swinstall ­s <full_path/software
# NEW IPS
adding package pkg install
pkg update 

rpm ­e <package> dpkg ­r <package> (do not remove config files) swremove


pkgrm dpkg ­P <package> (remove config files)
# NEW IPS
removing packages pkg uninstall <package>

rpm ­V <package> n/a swverity <fileset> (see /var/adm


pkginfo ­l
pkginfo ­p
verify package
# NEW IPS
pkg publisher 
pkg verify <package>

pkgchk ­l <package> | grep ­i pathname  rpm ­ql <package> dpkg ­L <package> (list files) swlist ­l file <product>

List files in package # NEW IPS
pkg contents <package>

# NEW IPS      
pkg history
pkg purge­history
pkg freeze
Other package commands
pkg unfreeze 
pkg fix
pkg refresh
pkg publisher 
/var/sadm /var/lib/rpm /var/lib/dpkg/info /var/adm/sw

Package directory

List libraries required for binary ldd <file> ldd <file> ldd <file> chatr <file>


program

Accounts

  Solaris Red Hat Ubuntu/Debian HP AIX


cat /etc/passwd cat /etc/passwd cat /etc/passwd cat /etc/passwd cat /etc/passwd
display users system­config­users (GUI) logins ­x
logins ­x [­p] lsuser ­f ALL   (detailed)

useradd
useradd useradd mkuser
create a user useradd
# user defaults  system­config­users (GUI) sam useradd
/usr/sadm/defadduser

userdel userdel rmuser


remove a user userdel userdel
system­config­users (GUI) sam userdel
chuser ­a
usermod 
usermod usermod passwd ­f
modify a user usermod usermod
system­config­users (GUI) sam passwd ­s
chfn <username>
chfn <username><shell>
passwd
change user
passwd passwd passwd passwd pwdadm
password
pwdck ­t ALL
create a group groupadd groupadd groupadd groupadd mkgroup <group name>
remove a group groupdel groupdel groupdel groupdel rmgroup <group name>
modify a goup groupmod groupmod groupmod groupmod chgroup <attribute><group name>
/etc/passwd /etc/passwd /etc/passwd /etc/passwd
password files /etc/security/passwd
/etc/shadow /etc/shadow /etc/shadow /tcb/files/auth/r/root (trusted system)
id ­a id ­a id ­a id id
whoami whoami whoami whoami whoami
who who who who who
w w w w w
finger finger finger uptime (displays # of users logged in) uptime (displays # of users logged in)
logins ­p finger finger 
useful user
commands # License information 

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 8/11
29/07/2016 Unix Commands
lslicense
chlicense

# Maximum number of processes for a user 
lsattr ­D ­l sys0 ­a maxuproc
chdev ­l sys0 ­a maxuproc=<number>
groups groups groups groups groups
useful group
setpgrp setprivgrp setgroups
commands
newgrp lsgroup ALL
/etc/security/policy.conf /etc/login.defs    
Password Policy  
/etc/default/passwd
passwd chage ­l <user>    
Password Aging  
chage <options> <user>

NFS

  Solaris Red Hat Ubuntu/Debian


server: mountd, nfsd server: rpc.mountd,nfsd
client: statd, lockd client: rpc.statd, lockd server: rpc.mountd,nfsd
NFS Daemons
client: rpc.statd, lockd

/etc/dfs/dfstab /etc/exports /etc/exports


NFS files /etc/dfs/sharetab /var/lib/nfs/etab /var/lib/nfs/etab
/etc/rmtab /var/lib/nfs/xtab /var/lib/nfs/xtab
/etc/rmtab /var/lib/nfs/rmtab /var/lib/nfs/rmtab
List nfs clients that have a remote mount

dfshares showmount ­e localhost showmount ­e localhost


display nfs shares
showmount ­e localhost
/etc/dfs/dfstab (edit and add share) redhat­config­nfs (GUI) /etc/exports (edit and add share, see below example)
share <path>  exportfs ­rav (export the shares) 
/etc/exports (edit and add share)
## dfstab example  /sbin/service nfs reload /etc/init.d/portmap restart
create nfs share
share ­F nfs ­d "jumpstart" /export/jumpstart /etc/init.d/nfs­kernel­server restart
## /etc/exports example
/export *(rw,fsid=0,insecure,no_root_squash,sync) ## /etc/exports example
/export *(rw,fsid=0,insecure,no_root_squash,sync) 
unshare <path> /etc/exports (edit and remove share) /etc/exports (edit and remove share)
/etc/dfs/dfstab (edit and remove share)  /sbin/service nfs reload exportfs ­rav (export the shares) 
uncreate nfs share

/sbin/service nfs start /etc/init.d/portmap start
/etc/init.d/nfs.server start  /etc/init.d/nfs­kernel­server start
/etc/init.d/nfs.client start
start/change nfs daemons
svcadm enable nfs/server
svcadm disable nfs/server

/etc/init.d/nfs.server stop /sbin/service nfs stop /etc/init.d/portmap stop


/etc/init.d/nfs.client stop /etc/init.d/nfs­kernel­server stop
stop nfs daemons

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
n/a cat /var/lib/nfs/etab cat /var/lib/nfs/etab
nfs Options

## Make sure you use NFS version 3  n/a n/a


solaris/redhat mount problems (nfs v3 to
mount ­F nfs ­o vers=3 <mount>
v4)
<mountpoint>

NTP

  Solaris Red Hat Ubuntu/Debian HP


ntpd xntpd xntpd
Time daemons xntpd ntpd

/etc/rc.config.d/netdaemons (set XNTPD to 1) 
# Solaris 8  /etc/ntp.conf (edit with ntp servers) /etc/default/ntp /etc/ntp.conf /etc/ntp.con
/etc/ntp.conf dateconfig (GUI) /etc/ntp.conf
/etc/ntp.server startsrc ­s x
/etc/ntp.client chkconfig ­­list ntpd /etc/init.d/ntp [start|stop|restart] stopsrc ­s xn
chkconfig ­­level 2345 ntpd on 
/etc/rc2.d/xntpd [start|stop] /sbin/service ntpd start  lslpp ­L all|g
ntp setup
# Solaris 10
/etc/inet/ntp.server
/etc/inet/ntp.client

svcadm enable ntpd

/lib/svc/method/xntp /etc/sysconfig/ntpd /etc/default/ntp /etc/rc.config.d/netdaemons


startsrc ­s x
ntp daemon options
/etc/rc.tcpip

ntpq ­p ntpq ­p ntpq ­p ntpq ­p ntpq ­p


NTP Trace commands ntptrace ntptrace ntptrace ntpdate (set the date) ntptrace
ntpdate

Log Files

  Solaris Red Hat Ubuntu/Debian HP AIX  


messages /var/adm/messages /var/log/messages /var/log/messages /var/adm/syslog/syslog.log /var/adm/ras messages
syslog /var/log/syslog /var/log/syslog /var/log/syslog /var/adm/syslog/syslog.log /var/adm/ras syslog
mail   /var/log/mail /var/log/mail.* /var/adm/syslog/mail.log /usr/spool/mqueue/syslog mail
cron /var/cron/log /var/log/cron /var/log/cron.log /var/adm/cron/log /var/adm/cron/log cron

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 9/11
29/07/2016 Unix Commands
/var/adm/ras
/var/adm/messages /var/log/boot /var/log/boot /var/adm/syslog/syslog.log
boot alog ­o ­t boot boot
dmesg dmesg dmesg dmesg
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)
Error errpt ­a (detailed errorlog report)
logger logger logger logger Error logging
logging errpt ­j <identifier> (single errorlog report)

errclear (clears errorlog)
errclear ­d <class><days> (clears class errors)

errlogger "message upto 230 chars" 

Security

  Solaris Red Hat Ubuntu/Debian HP AIX


pwdck ­t ALL 
Checking the passwd file pwck pwck pwck pwck
usrck ­t ALL
checking the group file grpck grpck grpck grpck grpck
# No reboot required  # No reboot required  # No reboot required
# Solaris 10 (no reboot)  /etc/securetty /etc/securetty /etc/security/user
/etc/default/login
# No reboot required 
/etc/securetty chsec ­f /etc/security/user ­s root
# Solaris 11 (no reboot)
console login (allow/deny)
/etc/default/login
Note: you may need to create this file
/etc/user_attr (see below)
if it does not exist
rolemod ­K type=normal root

Misc

  Solaris Red Hat Ubuntu/Debian


grub (GUI) grub (GUI) setboot ­p <primary path>
eeprom lilo (text based) setboot ­a <alternate path>
startup
setenv boot­device # autoboot sequnce 
setboot ­b [on|off]
shutdown ­h (halt) shutdown ­h now (halt)
shutdown ­i5 ­g0 ­y (power down) shutdown ­r (reboot) shutdown ­h (halt) shutdown ­r now(reboot)
shutdown ­i6 ­g0 ­y (reboot) shutdown ­f (fast reboot no fsck) shutdown ­r (reboot)
shutdown ­i0 ­g0 ­y (OK prompt) shutdown ­F (force fsck) shutdown ­P (power off)

shutdown reboot ­­ ­r (reboot/reconfigure) touch /forcefsck

touch /reconfigure # edit /etc/default/rcS change below so 
# you dont have to hang around 
FSCKFIX=yes

halt halt halt init


init init init reboot
poweroff poweroff poweroff shutdown
Change run level reboot reboot reboot
shutdown shutdown shutdown
telinit telinit telinit
uadmin
init status
0 0 ­ halt
1 0 ­ shutdown 0 ­ halt 1 ­ single user 0 ­ halt
2 1 ­ single user 1 ­ single user 2 ­ multiuser (default) 1 ­ single users
3 2 ­ n/a 2 ­ multiuser (no networking) 3 ­ same as 2  2 ­ multiuser (networking)
4 3 ­ Multi­user 3 ­ multiuser (networking) 4 ­ same as 2  3 ­ multiuser (networking, NFS, an
5 4 ­ n/a 4 ­ unused 5 ­ same as 2  4 ­ multiuser (netwrking, NFS, and
6 5 ­ power off 5 ­ GUI 6 ­ reboot  5 ­ n/a
6 ­ reboot 6 ­ reboot 6 ­ n/a

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

boot <option> single  ­ use grub to edit kernel line  single  ­ use grub to edit kernel line  interact with IPL? Y


emergency ­ use grub to edit kernel line  emergency ­ use grub to edit kernel line 
# Options linux rescue ­ use at the boot prompt linux rescue ­ use at the boot prompt # single user 
­s single user ISL> hpux ­is
­a interactive single: runlevel1, local fs mounted, no network single: runlevel1, local fs mounted, no network
Startup options ­x no device drivers (used in emergency: root fs read­only, no init files run  emergency: root fs read­only, no init files run  # Logical volume maintanence mo
clustering)  rescue: use cd­rom/network, root mounted as rescue: use cd­rom/network, root mounted as ISL> hpux ­lm
­r reconfigure devices /mnt/sysimage /mnt/sysimage
­m milestone # No quroum check
ISL> hpux ­lq

/etc/init.d /etc/init.d /etc/init.d /sbin/init.d


/etc/rc.config.d (startup config files
/etc/rc0.d ­ /etc/rc6.d /etc/rc0.d ­ /etc/rc6.d /etc/rc0.d ­ /etc/rc6.d
/sbin/rc0.d ­ /sbin/rc6.d
startup scripts

F10 or F12 F10 or F12 interact with IPL? Y


boot
printenv
setenv

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 10/11
29/07/2016 Unix Commands
banner
devalias
boot prompt show­devs
commands show­pci­devs­all 
probe­scsi­all
probe­fcal­all
probe­pci 
watch­net­all
reset­all

Phases: Boot sequence Boot sequence Phases:

Boot PROM: displays system 1. BIOS 1. BIOS 1. PDC ­ processor­dependen


information, run POST, load 2. POST 2. POST performs self­tests
bootblk, locate ufsboot 3. Master Boot Record (MBR) ­ point to the 3. Master Boot Record (MBR) ­ point to the 2. ISL ­ initial system loader; 
Boot Programs: bootblk loads bootloader GRUB or LILO bootloader GRUB or LILO system loader hpux
and executes the ufsboot 4. GRUB (stage 1) ­ point to GRUB stage 1_5 4. GRUB (stage 1) ­ point to GRUB stage 1_5 3. HPUX ­ is the secondary s
Kernel Initialization: ufsboot 5. GRUB (stage 1_5) ­ deals with specific 5. GRUB (stage 1_5) ­ deals with specific the kernel /stand/vmunix, t
Boot process
loads and executes the core filesystem types look at /boot/grub/*1_5 files filesystem types look at /boot/grub/*1_5 files kernel
kernel, initializes core kernel 6. GRUB (stage 2) – reads /etc/grub.conf and 6. GRUB (stage 2) – reads /boot/grub/menu.lst 4. KERNEL ­ swapper proces
data structures, loads other displays the grub menu, it specifies the kernel and displays the grub menu, it specifies the kernel then starts the 
kernel modules based on the and the initrd files kernel and the initrd files 5. INIT ­ reads /etc/inittab
/etc/system file, starts /sbin/init 7. KERNEL ­ control given to the kernel 7. KERNEL ­ control given to the kernel
program 8. INIT ­ reads /etc/inittab and runs 8. INIT ­ runs the /etc/event.d/rc­default script
init: starts other processes /etc/rc.d/rc.sysinit script
based on the /etc/inittab file

bootadm list­archive      
bootadm update­archive
bootadm list­menu 
bootadm set­menu <option>
Boot Environments
(BE) beadm create
beadm rename
beadm activate
beadm list
beadm destroy
determine the run who ­r runlevel runlevel who ­r
level who ­r who ­r
obtain default run cat /etc/inittab cat /etc/inittab /etc/event.d/rc­default /etc/inittab
level
list locale locale ­a locale ­a locale ­a locale ­a
n/a startx (shorthand of below)   n/a
start xwindows
initx (lots of parms)
sys­unconfig     set_parms [initial|hostname|ip_add
initialize system
Note: set_parms is in /sbin
/etc/TIMEZONE /etc/sysconfig/clock /etc/timezone /etc/TIMEZONE
Timezone
/etc/default/init /usr/share/zoneinfo/zone.tab /usr/share/zoneinfo/zone.tab

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

You might also like