Common Unix Commands: Sysinfo
Common Unix Commands: Sysinfo
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
cat /etc/release Server Release info Solaris 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 mo un ios ios Ubuntu/Debian cat /etc/lsb-release lsb_release -a /st
Hardware Info
/o ca
Operating System
un dm /u /o ca
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
/o sam ca
ios
/boot/initrd.?????.img /boot/vmlinuz
/boot/initrd.img-?????-server /boot/vmlinuz-????-server
/st
ge /o HP
Kernel 32 or 64
No ge /o At the OK prompt type banner boot into the BIOS (normally F2 or F12) boot into the BIOS (normally F2 or F12)
Display Firmware
n/a
sam
Memory
adding swap
device: device: create partition with fdisk (type create partition with fdisk (type 82) 82)
update /etc/vfstab
file(create 50MB swap file): dd if=/dev/zero of=/var/swapfile bs=1024 count=50000 mkswap <device>|<file> swapon <device>|<file> update /etc/fstab
file(create 50MB swap file): dd if=/dev/zero of=/var/swapfile bs=1024 count=50000 mkswap <device>|<file> swapon <device>|<file> update /etc/fstab
swapon -p 3 <device> | -f <logical device> update /etc/fstab Note: -p = priority swap number . The nswa tunable system parameter controls the max number of swap devices.
removing swap
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 leve cat /etc/fstab
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
Filesystem commands
df -k df -h newfs -v <raw device> # Display how the filesystem was created newfs -Nv <filesystem>
Filesystem (create|remove)
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 'file # edit /etc/default/rcS change belo # you dont have to hang around FSCKFIX=yes
backup filesystem
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
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
grub-install <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
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
n/a
mount/unmount floppy
n/a mount -rt iso9660 /dev/cdrom /mn umount /mnt/cdrom eject cdrom
mount/unmount CDROM
mount -o remount,rw /
mount -o remount,rw /
remount a filesystem
n/a
n/a
using the grub window append the word single to the kernel line
f10 or f12
f10 or f12
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 ID
Device paths
/dev/MAKEDEV <device>
/dev/MAKEDEV <device>
prtconf -D sysdef
cat /proc/devices
cat /proc/devices
Networking
Solaris Red Hat Ubuntu/De
/etc/network/interface ifconfig
ifconfig
ifconfig
ifconfig
ifconfig qfe0 up ifconfig qfe0 down Starting and stopping a network interface
ndd -set <device> <parm> <value> (dynamically) /etc/system (edit and update then reboot permanent)
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 \? Display NIC statistics display MAC address ifconfig -a (as user root) snoop -d <interface>
ifconfig
/etc/defaultrouter default router route add default <gteway> netstat -rn display routing table
if_mpadm -d (detach) if_mpadm -r (reattach) tail /var/adm/messages change the following files:
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 ifenslave bond0 eth1 cat /proc/net/bonding/ /etc/hostname /etc/hosts sysctl -a |grep hostname
/etc/nodename /etc/hostname.<interface> /etc/inet/hosts /etc/inet/ipnodes /etc/net - few files in here as well /etc/resolv.conf
setup DNS
/etc/resolv.conf
/etc/resolv.conf
/etc/nsswitch.conf /etc/resolv.conf
## 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
Domain Name route -n get <hostname> traceroute Boot (jumpstart) servers: rpcinfo -b bootparam 1 Find Services on the network NFS servers: rpcinfo -b mountd 1 NIS servers/slaves: rpcinfo -b ypserv 1
ip route get <IP address> tracroute Boot (jumpstart) servers: rpcinfo -b bootparam 1 NFS servers: rpcinfo -b mountd 1 NIS servers/slaves: rpcinfo -u <yp server> ypserv
ip route get <IP address traceroute Boot (jumpstart) servers rpcinfo -b bootparam 1 NFS servers: rpcinfo -b mountd 1 NIS servers/slaves: rpcinfo -u <yp server> y
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 HP edit /stand/system add either: dump 2/0/1.5.0 dump lvol dump none # crash config file /etc/rc.config.d/savecrash sysdumpdev -l (list sysdumpdev -e (est sysdumpdev -L (info sysdumpstart -p (st sysdumpstart -s (sta # set the dump dev sysdumpdev -p <du # analyse dump file echo "stat\n status\
Crash Dump
dumpadm -d <device> diskdump netdump crash (used to kdump (part of kexec rpm) analyse crash dumps) adb (used to analyse /etc/kdump.conf (select where you want the dump to go) crash dumps) service kdump start chkconfig kdump on ## to crash the system echo "c" > /proc/sysrq-trigger
crash (used to analyse crash dumps) crash (used to analyse crash dumps)
CPU
Memory
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
Network I/O
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=tr lsattr -HEl sys0 -a iostat 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
NFS
nfsstat
nfsstat
nfsstat
nfsstat
k k k k r
k s k k / o c / e / m m m m r
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
interprocess communication
ipcs -a
ipcs -a
Services
display services Solaris 10 svcs -a inetadm -l svcadm enable nfs svcadm disable nfs svcadm refresh nfs svcadm restart nfs svcs nfs svcs -d network Red Hat service --status-all Ubuntu/Debian HP
There is no services or chkconfig command use There is no services or chkconfig comm 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 status service dependencies
service nfs start service nfs stop service nfs reload service nfs restart service nfs staus n/a
n/a n/a
Patching / Software
display installed patches showrev -p patchadd -p patchadd patchadd -M <dir> (multiple patches) adding patch Solaris Red Hat Ubuntu/Debian
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)
rpm -Uhv (updates/installs if not already) dpkg -i <package> rpm -ihv (install)
pkgrm
rpm -e <package>
dpkg -r <package> (do not remove config dpkg -P <package> (remove config files)
removing packages
verify package
rpm -V <package>
n/a
/var/lib/rpm
/var/lib/dpkg/info
ldd <file>
ldd <file>
ldd <file>
Accounts
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 Solaris cat /etc/passwd Red Hat cat /etc/passwd system-config-users (GUI) Ubuntu/Debian cat /etc/passwd cat /etc/passwd logins -x HP cat /etc/pass lsuser -f ALL mkuser useradd rmuser userdel chuser -a usermod passwd -f passwd -s chfn <usernam chfn <usernam
modify a user
usermod
usermod
usermod sam
change user password create a group remove a group modify a goup password files
passwd groupadd groupdel groupmod /etc/passwd /tcb/files/auth/r/root (trusted system) id whoami who w uptime (displays # of users logged in) finger
passwd pwdadm pwdck -t ALL mkgroup <gro rmgroup <grou chgroup <attr /etc/security id whoami who w uptime (displa finger # License info lslicense chlicense # Maximum nu lsattr -D -l sys chdev -l sys0
groups
groups
groups setprivgrp
NFS
NFS Daemons Solaris server: mountd, nfsd client: statd, lockd Red Hat server: rpc.mountd,nfsd client: rpc.statd, lockd server: rpc.mountd client: rpc.statd, lo /etc/exports /var/lib/nfs/etab /var/lib/nfs/xtab /var/lib/nfs/rmtab showmount -e local
NFS files List nfs clients that have a remote mount display nfs shares
/etc/dfs/dfstab (edit and add share) share <path> create nfs share
redhat-config-nfs (GUI)
/etc/exports (edit a exportfs -rav (expor /etc/init.d/portma /etc/init.d/nfs-kern ## /etc/exports exa /export *(rw,fsid=0 /etc/exports (edit a exportfs -rav (expor
/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/init.d/nfs.server start /etc/init.d/nfs.client start svcadm enable nfs/server svcadm disable nfs/server /etc/init.d/nfs.server stop /etc/init.d/nfs.client stop
/etc/init.d/portma /etc/init.d/nfs-kern
stop nfs daemons nfs status nfs reload nfs performanace nfs Options
/etc/init.d/portma /etc/init.d/nfs-kern
## Make sure you use NFS version 3 mount -F nfs -o vers=3 <mount> <mountpoint>
n/a
n/a
NTP
Time daemons xntpd Solaris ntpd Red Hat ntpd Ubuntu/Debian 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/ntp.conf (edit with ntp servers) dateconfig (GUI) chkconfig --list ntpd chkconfig --level 2345 ntpd on /sbin/service ntpd start
/etc/rc.config.d/netda /etc/ntp.conf
/etc/sysconfig/ntpd
/etc/default/ntp
/etc/rc.config.d/netda
ntpq -p ntptrace
ntpq -p ntptrace
ntpq -p ntptrace
Log Files
messages syslog mail cron Solaris /var/adm/messages /var/log/syslog /var/cron/log /var/adm/messages dmesg 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) AIX
logger
logger
logger
errclear (clears errorlog) errclear -d <class><days> (clears class errors) errlogger "message upto 230 chars"
Security
Checking the passwd file checking the group file pwck grpck # No reboot required /etc/default/login Solaris 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 A usrck -t AL grpck # No reboo /etc/secu
Note: you may need to create this file chsec -f /e if it does not exist
Misc
eeprom startup setenv boot-device shutdown -h (halt) shutdown -r (reboot) shutdown -f (fast reboot no fsck) shutdown -F (force fsck) Solaris grub (GUI) lilo (text based) Red Hat grub (GUI) Ubuntu/Debian
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 -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
shutdown telinit
shutdown telinit
0 1 2 3 4 5 6
0 - halt 1 - single user 2 - multiuser (no networking) 3 - multiuser (networking) 4 - unused 5 - GUI 6 - reboot # 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 vi /etc/inittab -s single user -a interactive -x no device drivers (used in clustering) -r reconfigure devices -m milestone
single- use grub to edit kernel line emergency - use grub to edit kernel line linux rescue - use at the boot prompt single: runlevel1, local fs mounted, no network emergency: root fs read-only, no init files run rescue: use cd-rom/network, root mounted as /mnt/sysimage
Startup options
F10 or F12
F10 or F12
show-devs show-pci-devs-all probe-scsi-all probe-fcal-all probe-pci watch-net-all reset-all Boot sequence 1. BIOS 2. POST 3. Master Boot Record (MBR) - point to the bootloader GRUB or LILO 4. GRUB (stage 1) - point to GRUB stage 1_ 5. GRUB (stage 1_5) - deals with specific filesystem types look at /boot/grub/*1_ files 6. GRUB (stage 2) reads /boot/grub/men and displays the grub menu, it specifies kernel and the initrd files 7. KERNEL - control given to the kernel 8. INIT - runs the /etc/event.d/rc-default
Phases: Boot PROM: displays system information, run POST, load bootblk, locate ufsboot Boot Programs: bootblk loads and executes the ufsboot Kernel Initialization: ufsboot loads and executes the core kernel, initializes core kernel data structures, loads other kernel modules based on the /etc/system file, starts /sbin/init program init: starts other processes based on the /etc/inittab file who -r cat /etc/inittab locale -a n/a sys-unconfig initialize system Timezone /etc/TIMEZONE /etc/default/init
Boot sequence 1. BIOS 2. POST 3. Master Boot Record (MBR) - point to the bootloader GRUB or LILO 4. GRUB (stage 1) - point to GRUB stage 1_5 5. GRUB (stage 1_5) - deals with specific filesystem types look at /boot/grub/*1_5 files 6. GRUB (stage 2) reads /etc/grub.conf and displays the grub menu, it specifies the kernel and the initrd files 7. KERNEL - control given to the kernel 8. INIT - reads /etc/inittab and runs /etc/rc.d/rc.sysinit script
Boot process
determine the run level obtain default run level list locale start xwindows
runlevel who -r cat /etc/inittab locale -a startx (shorthand of below) initx (lots of parms)
/etc/sysconfig/clock /usr/share/zoneinfo/zone.tab
/etc/timezone /usr/share/zoneinfo/zone.tab