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

Common Unix Commands: Sysinfo

This document provides an overview of common commands used to view system information on various Unix/Linux systems such as Solaris, Red Hat, Ubuntu, HP-UX. It includes commands to view hardware details like the CPU, memory, disks, kernel information. Networking commands to view network configuration. Commands are also provided to view and manage services, software packages, user accounts and more. System utilities like top, vmstat can help monitor performance.

Uploaded by

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

Common Unix Commands: Sysinfo

This document provides an overview of common commands used to view system information on various Unix/Linux systems such as Solaris, Red Hat, Ubuntu, HP-UX. It includes commands to view hardware details like the CPU, memory, disks, kernel information. Networking commands to view network configuration. Commands are also provided to view and manage services, software packages, user accounts and more. System utilities like top, vmstat can help monitor performance.

Uploaded by

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

Unix Commands Page 1 of 11

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 properties
## 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 mode'
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 capability'

Display Firmware At the OK prompt type banner boot into the BIOS (normally F2 or F12) boot into the BIOS (normally F2 or F12)
workstations:
reboot
enter PDC

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 5/17/2018
Unix Commands Page 2 of 11

type: IN (information menu)


type: FV (Firmware Version)

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 AIX


/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 pagesizes)
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
swap -a /var/swapfile create partition with fdisk (type 82) 82) swapon <device> | -f <logical device> # change the attributes
file(create 50MB swap file): file(create 50MB swap file): swapon -p 3 <device> | -f <logical device> chps -a n paging00 (don't use after restart)
update /etc/vfstab dd if=/dev/zero of=/var/swapfile dd if=/dev/zero of=/var/swapfile
bs=1024 count=50000 bs=1024 count=50000 update /etc/fstab # change the logical volume attributes (name in this
chlv -n <new name> <old old> (chang page space nam
adding swap mkswap <device>|<file> mkswap <device>|<file> Note: -p = priority swap number . The nswapdev
swapon <device>|<file> swapon <device>|<file> tunable system parameter controls the maximum Note:
number of swap devices.
update /etc/fstab update /etc/fstab -a reconfigure paging space after restart
-s size of the page space (logical partitions)
-n activiates the paging space (use swapoff to deacti

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 deactiviated before rem

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/c0t4d0 (detailed but no
luxadm inq <disk> (A5x00 disk arrays) number)
hdparm -Tt /dev/hda (speed test) haparm -Tt /dev/hda (speed test) /opt/ignite/bin/print_manifest (no serial num

sdparm -i /dev/sdb sdparm -i /dev/sdb ## Insure that the online diagnostic support to
have been installed
cat /proc/ide/ide0/hda/model cat /proc/ide/ide0/hda/model swlist -l bundle | grep 'Support Tools'
Disk serial Number, type, cat /proc/scsi/scsi cat /proc/scsi/scsi
etc ## Command-Line Support Tools Manager (cstm
## The run cstm
cstm
cstm> map
cstm> sel dev 4       (select the disk of you cho
cstm> info
cstm> il                  (obtain the serial number)
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 stored in the boot ar
Logical Interchange Format (LIF), which is sim
a file system. For a device to be bootable, the
volume on that device must contain at least t
(the initial system loader) and HPUX (the HP-U
bootstrap utility) LIF files. ISL is like GRUB.

List Raw Partitions use format to partition the disk then just use mknod /dev/rawctl c 162 0 Just create a new LVOL without a filesystem -
the slice as a raw partition, remember to use ## Old way mknod /dev/raw/raw0 c 162 1 it.
the 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

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 5/17/2018
Unix Commands Page 3 of 11

## New way, Edit below file ## map raw devices to the disk
/etc/udev/rules.d/60-raw.rules raw /dev/raw/raw1 /dev/sdb1
udevinfo -d or udevadm info
## display raw devices
## Display raw partitions raw -qa
raw -qa

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


Bad Blocks
Note: no errors means disk is good
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 /dev/vg01/rlvol1
mkfs -t ext3 /dev/sdb1
# Display how the filesystem was created mke2fs -t ext4 /dev/sdb1 mkfs -F vxfs -o largefiles /dev/vg01/rlvol1
newfs -Nv <filesystem>
# all point to mke2fs Note: mkfs and newfs are a pointer
mkfs.ext2 to /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 to see if a filesystem
tune2fs -l /dev/sdb<?> |grep -i 'filesystem state' # edit /etc/default/rcS change below so # needs checking
# 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>
/etc/lilo.conf
Setting the boot device
# 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 disk as a LVM device
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 mount -rt iso9660 /dev/cdrom /mnt/cdrom
path> /cdrom/cdrom0 mount -rt iso9660 /dev/cdrom /mnt/cdrom umount /mnt/cdrom mount -rF cdfs /dev/dsk/c1t6d0 /cdrom
umount /cdrom/cdrom0 umount /mnt/cdrom eject cdrom
mount/unmount CDROM eject cdrom start: /usr/sbin/pps_mountd
/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 <filesystem>

remount a filesystem

n/a mkbootdisk `uname -r` (boot diskette) n/a recovery tape (preview)
create boot disk or
make_tape_recovery -v -l -x inc_entire=vg00
recovery tape
/opt/ignite/bin/make_recovery -ACv
boot cdrom/diskette (single ok> boot cdrom -s using the grub window append the word single to using the grub window append the word single to enter PDC
user) the kernel line the kernel line > search
> boot p1 (cdrom)
interact with IPL? Y
ISL> hpux -is

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 5/17/2018
Unix Commands Page 4 of 11

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


interact with IPL? Y
ISL> hpux -lm

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
/dev/scd0 (external usb cd) cdrom: cdrom: cdrom:
/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 deleted link)
devfsadm ( solaris 8, 9, 10)

rem_drv # remove all devices from a hardward path


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


Basic network information /etc/hostname.hme0 /etc/sysconfig/network /etc/network/interfaces /etc/rc.config.d/netconf
  (hostname, ip address) /etc/sysconfig/network-scripts/ifcfg-eth0
ifconfig ifconfig ioscan -funC lan (list hardware)
prtdiag -v system-config-network (GUI) lanscan -v (list configured)
ifconfig -a ifconfig lan0 (individual)

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

Starting and stopping a network ifconfig qfe0 up /sbin/ifup eth0 /sbin/ifup eth0
interface ifconfig qfe0 down /sbin/ifdown eth0 /sbin/ifdown eth0 ifconfig lan0 up
ifconfig lan0 down

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 5/17/2018
Unix Commands Page 5 of 11

note: there is no "ifconfig -a" in hpux u


then "ifconfig <interface>"

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

ethtool eth0
ndd -get <device> <parm> mii-tool -v lanadmin -> lan -> display
ethtool eth1 sysctl -a |grep net*
# List parameters ethtool -t eth0 online ## options supported
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 interface]


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 pduout -e ns_ls_driver
Displaying network packets -file /var/adm/LAN
nettl -stop

use netfmt to display the trace file

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


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 optional product called Au


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 hostname (requires reboot)


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

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 5/17/2018
Unix Commands Page 6 of 11

Domain Name /etc/defaultdomain /etc/sysconfig/network  (HOSTNAME option) /etc/host /etc/rc.config.d/netconf


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

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) servers:
rpcinfo -b bootparam 1 rpcinfo -b bootparam 1 rpcinfo -b bootparam 1 rpcinfo -b bootparam 1

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 1

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 <device> diskdump diskdump edit /stand/system sysdumpdev -l (list dump destination)
coreadm netdump netdump sysdumpdev -e (estimates dumpsize)
kdump (part of kexec rpm) kdump (part of kexec rpm) add either: sysdumpdev -L (info)
crash (used to analyse dump 2/0/1.5.0
crash dumps) /etc/kdump.conf (select where you /etc/kdump.conf (select where you dump lvol sysdumpstart -p (start dump primary)
adb (used to analyse want the dump to go) want the dump to go) dump none sysdumpstart -s (start dump secondary)
Crash Dump crash dumps) service kdump start service kdump start
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
snoop lsof lsof glance trace)
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


Process top
prstat
ps -ef
pargs <pid>
pcred <pid>
pfiles <pid>
pflags <pid>
pgrep <pattern>
pkill <pattern>
pmap <pid>
pldd <pid>
preap <pid>
prun <pid>
psig <pid>

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 5/17/2018
Unix Commands Page 7 of 11

pstack <pid>
pstop <pid>
ptime <pid>
ptree <pid>
pwait <pid>
pwdx<pid>

Kernel Modules and Parameters

Solaris Red Hat Ubuntu/Debian HP


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 modules /lib/modules/`uname -r`/kernel/drivers
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
set kernel parameters echo "536870912" > /proc/sys/kernel/shmmax echo "536870912" > /proc/sys/kernel/shmmax
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 /tmp/kernel.data
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 command
svcs -l <service> way /etc/init.d/<service> use the old fashioned
display services
svcs -vx way /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 dependencies svcs -d network n/a n/a
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
Add a new service n/a

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 5/17/2018
Unix Commands Page 8 of 11

# Create your
stop/start
# script in /etc/init.d

chkconfig --add <script>

Patching / Software

Solaris Red Hat Ubuntu/Debian HP


showrev -p swlist -l bundle
display installed patches patchadd -p swlist -l product
swlist -l patch
patchadd patch -p1 <patch>
patchadd -M <dir> (multiple patches)
zcat patch46.gz | patch -p1 swcopy (install patch into depot)
adding patch swinstall (install patch from depot)
Note: -p = # of path stripping
Note: the swagentd daemon must be running

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/sw/swagent.log)


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 # user defaults useradd
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>
change user passwd passwd passwd passwd
password

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 5/17/2018
Unix Commands Page 9 of 11

passwd
pwdadm
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
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.conf
/etc/ntp.conf dateconfig (GUI) /etc/ntp.conf
/etc/ntp.server startsrc -s xntpd
/etc/ntp.client chkconfig --list ntpd /etc/init.d/ntp [start|stop|restart] stopsrc -s xntpd
chkconfig --level 2345 ntpd on
/etc/rc2.d/xntpd [start|stop] /sbin/service ntpd start lslpp -L all|grep xntpd
ntp setup
# Solaris 10
/etc/inet/ntp.server
/etc/inet/ntp.client

svcadm enable ntpd

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 5/17/2018
Unix Commands Page 10 of 11

ntp daemon options /lib/svc/method/xntp /etc/sysconfig/ntpd /etc/default/ntp /etc/rc.config.d/netdaemons startsrc -s xntpd -a "-x"

/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
/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)
errpt -a (detailed errorlog report)
Error logging logger logger logger logger Error 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
console login (allow/deny) # Solaris 11 (no reboot)
/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 HP


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, and CDE GUI) (default
5 4 - n/a 4 - unused 5 - same as 2 4 - multiuser (netwrking, NFS, and VUE GUI)
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 vi /etc/event.d/rc-default # change default - change the initdefault
vi /etc/inittab vi /etc/inittab vi /etc/inittab

Startup options
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
-x no device drivers (used in emergency: root fs read-only, no init files run emergency: root fs read-only, no init files run

http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm 5/17/2018
Unix Commands Page 11 of 11

clustering) rescue: use cd-rom/network, root mounted rescue: use cd-rom/network, root mounted # Logical volume maintanence mode
-r reconfigure devices as /mnt/sysimage as /mnt/sysimage ISL> hpux -lm
-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
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-dependent code; executes and
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; loads the secondary
• 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 system loader and loa
• Kernel Initialization: ufsboot 5. GRUB (stage 1_5) - deals with specific 5. GRUB (stage 1_5) - deals with specific the kernel /stand/vmunix, then hands over to
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 the 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 processes are started by the
data structures, loads other displays the grub menu, it specifies the kernel and displays the grub menu, it specifies the kernel then starts the init
kernel modules based on and the initrd files kernel and the initrd files 5. INIT - reads /etc/inittab
the /etc/system file, 7. KERNEL - control given to the kernel 7. KERNEL - control given to the kernel
starts /sbin/init program 8. INIT - reads /etc/inittab and 8. INIT - runs the /etc/event.d/rc-default script
• init: starts other processes runs /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_address|timezone]
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 5/17/2018

You might also like