Common Unix Commands
| Swap | Information regarding the swap area |
| Sysinfo | Display system information i.e cpu, memory, etc |
| Services | Display, start and stop services |
| NFS | Information on NFS i.e starting, stopping, etc |
| Disk | Displaying disk information i.e type, serial number, etc |
| Kernel Modules | Displaying and modifing kernel parameters |
| Networking | Display and configuring network parameters |
| Patching / Packages | Installing and removing patches and software packages |
| Accounts | Setting up and removing user accounts |
| NTP | Network Time Protocol |
| Log Files | Location to common log files |
| Security | Security information |
| Misc | Other stuff i.e shutdown, timezone, run level, etc |
| Solaris | Red Hat | HP | |
| display swap | swap -l swap -s |
cat /proc/swaps (detailed) swapon -s |
swapinfo (displayed in KB) swapinfo -m (display in Mb) swapinfo -tm (total / Mb) |
| adding swap | mkfile 5m /var/swapfile |
device: |
Create logical volume or filesystem swapon <device> | -f <logical device> swapon -p 3 <device> | -f <logical device> update /etc/fstab Note: -p = priority swap number |
| removing swap | update /etc/vfstab swap -d |
swapoff <device>|<file> Remove device or file as normal |
remove entry from /etc/fstab reboot |
| Solaris | Red Hat | HP | |
| Server type | /usr/platform/`uname -i`/sbin/prtdiag -v | model |
|
| Hardware Info | prtdiag -v prtpicl -v [-c <class>] prtconf -D |
lspci lsusb |
|
| Memory | /usr/platform/`uname -i`/sbin/prtdiag -v prtconf | grep -i mem |
cat /proc/meminfo (detailed) free -om |
dmesg | grep -i physical /usr/sam/lbin/getmem /opt/ignite/bin/print_manifest |
| CPU (type, number, etc) | /usr/platform/`uname -i`/sbin/prtdiag -v | cat /proc/cpuinfo (detailed) | /opt/ignite/bin/print_manifest sam -> performance monitors -> system properties |
| Disk Drives | format format -e (to convert EFI (zfs) to SMI) |
fdisk -l sfdisk -l (advanced server) parted <device> print partprobe <device> |
ioscan -funC disk |
| Disk serial Number, type, etc | format iostat -En luxadm inq <disk> (A5x00 disk arrays) |
hdparm -i /dev/hda hdparm -I /dev/hda (detailed) cat /proc/ide/ide0/hda/model |
diskinfo -v /dev/rdsk/c0t4d0 (detailed but no serial number) /opt/ignite/bin/print_manifest (no serial number) |
| Disk disk partitions | prtvtoc <device> | fdisk -l cat /proc/partitions (very high level)
|
lifls -Clv <device> |
| List Raw Partitions | n/a | raw -qa | n/a |
| Tune Filesystems | tunefs fstyp -v <device> |
tune2fs tune2fs -l /dev/sda1 |
tunefs |
| Kernel 32 or 64 | isainfo -kv (solaris 9+) isalist (sparc v9 will be listed first) |
uname -a uname -m getconf -a |grep -i 'long_bit' |
getconf KERNEL_BITS ( version 11) |
| Display Firmware | At the OK prompt type banner | boot into the BIOS (normally F2 or F12) | workstations: servers: |
| Trace system calls | truss -p <pid> | strace -p <pid> | download and install tusc tusc -p <pid> |
| Display IRQ, IO ports and DMA | n/a | /proc/interrupts /proc/ioports /proc/dma |
n/a |
| Solaris 10 | Red Hat | HP | |
| display services | svcs -a |
service --status-all | n/a |
| start services | svcadm enable nfs | service nfs start | n/a |
| stop services | svcadm disable nfs | service nfs stop | n/a |
| reload service | svcadm refresh nfs | service nfs reload | n/a |
| restart service | svcadm restart nfs | service nfs restart | n/a |
| service status | svcs nfs | service nfs staus | n/a |
| service dependencies | svcs -d network | n/a | n/a |
| service dependants | svcs -D network | n/a | n/a |
| service logging, etc | /var/svc/log /var/svc/manifest /lib/svc/method |
n/a | n/a |
| Solaris | Red Hat | HP | |
| NFS Daemons | server: mountd, nfsd client: statd, lockd /etc/dfs/dfstab /etc/dfs/sharetab |
server: rpc.mountd,nfsd client: rpc.statd, lockd |
server: rpc.mountd, nfsd client: rpc.statd, lockd /etc/exports |
| display nfs shares | dfshares showmount -e localhost |
showmount -e localhost | showmount -e localhost cat /etc/xtab (currently exported) |
| create nfs share | /etc/dfs/dfstab (edit and add share) share <path> |
redhat-config-nfs (GUI) /etc/exports (edit and add share) /sbin/service nfs reload |
/etc/rc.config.d/nfsconf (edit) |
| uncreate nfs share | unshare <path> /etc/dfs/dfstab (edit and remove share) |
/etc/exports (edit and remove share) /sbin/service nfs reload |
/etc/rc.config.d/nfsconf (edit) exportfs -au (unshare all) exportfs -u /home/vallep /etc/exports (edit and remove share) |
| nfs start | /etc/init.d/nfs.server start svcadm enable nfs/server |
/sbin/service nfs start | /sbin/init.d/nfs.core start /sbin/init.d/nfs.server start /sbin/init.d/nfs.client start |
| nfs stop | /etc/init.d/nfs.server stop /etc/init.d/nfs.client stop |
/sbin/service nfs stop | /sbin/init.d/nfs.client stop /sbin/init.d/nfs.server stop /sbin/init.d/nfs.core stop |
| nfs status | ps -ef|grep < nfs daemons> | /sbin/service nfs status | ps -ef | grep <nfs daemons> |
| nfs reload | shareall | /sbin/service nfs reload | exportfs -a |
| nfs performanace | nfsstat | nfsstat | nfsstat |
| List nfs clients that have remote mount | cat /etc/rmtab | cat /etc/rmtab |
| Solaris | Red Hat | HP | |
| Display the boot device | eeprom | cat /etc/grub.conf grub = grand unified boot loader |
setboot |
| setting the boot device | setenv boot-device <device> | <alias> eeprom boot-device <device> | <alias> |
/etc/grub.conf
|
setboot -p <primary path> setboot -a <alternate path> |
| Creating boot device (MBR) | installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk <raw-device> | grub-install <raw-device> lilo -v |
mkboot |
| format floppy drive | fdformat -v -U volcheck -v newfs -v /vol/disk/aliases/floppy0 |
floppy --probe (use device obtained below ) floppy --createrc > /etc/fd0 floppy --format /dev/fd0 mkfs /dev/fd0 |
n/a |
| mount/unmount floppy | volrmmount -l floppy0 eject floppy |
mount /dev/fd0 /mnt/floppy umount /mnt/floppy |
n/a |
| mount/unmount CDROM | mount -F hsfs -o ro <device path> /cdrom/cdrom0 umount /cdrom/cdrom0 /etc/init.d/volmgr start eject cdrom |
mount -rt iso9660 /dev/cdrom /mnt/cdrom |
mount -rF cdfs /dev/dsk/c1t6d0 /cdrom start: /usr/sbin/pps_mountd |
| create boot disk or recovery tape | n/a | mkbootdisk `uname -r` (boot diskette) | recovery tape (preview) make_tape_recovery -v -l -x inc_entire=vg00 /opt/ignite/bin/make_recovery -ACv |
| boot cdrom/diskette (single user) | ok> boot cdrom -s | linux single (at the boot prompt) | enter PDC > search >boot p1 (cdrom) interact with IPL? Y ISL> hpux -is |
| boot into maintenace mode | ok> boot -as | f10 or f12 | >boot pri interact with IPL? Y ISL> hpux -lm |
| Solaris | Red Hat | HP | |
| display loaded modules | modinfo | cat /proc/modules (more detailed) Location: |
kmadmin -k |
| load modules | modload -p drv/st |
modprobe <module> insmod |
kmadmin -L <module name> |
| unload modules | modunload -i drv/st | modprobe -r <module> rmmod |
kmadmin -U <module name> |
| set kernel parameters | edit /etc/system reboot |
/etc/sysctl.conf (edit and update then reboot) sysctl -w param=value |
kcweb (11i) kctune (11i only) rebuild kernel (< 11i see below) |
| display kernel parameters | cat /etc/system sysdef -i ipcs -a |
sysctl -a cat /etc/sysctl.conf cat /proc/sys/kernel/sem cat /proc/sys/kernel/shmmax etc................................... ipcs -a |
kctune (11i only) sysdef kmtune kmsystem /usr/sam/lbin/getkinfo -f /stand/vmunix -o /tmp/kernel.data |
| build kernel | edit and update file then reboot: |
cd /usr/src/linux-2.4 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 |
cd /stand/build |
| Solaris | Red Hat | HP | |
| Basic network information (hostname, ip address) | /etc/hostname.hme0 | /etc/sysconfig/network | /etc/rc.config.d/netconf |
| default router | /etc/defaultrouter | edit /etc/sysconfig/network add: GATEWAY=<IP address> |
/etc/rc.config.d/netconf |
| Starting and stopping a network interface | ifconfig qfe0 up ifconfig qfe0 down |
/sbin/ifup eth0 /sbin/ifdown eth0 |
ifconfig lan0 up ifconfig lan0 down |
| NIC speeds or Parameters | ndd -get <device> <parm> kstat hme:0 |
mii-tool -v |
lanadmin -x ndd -get <device> <parm> |
| Setting NIC speed | ndd -set <device> <parm> <value> (dynamically) /etc/system (edit and update then reboot - permanent) |
mii-tool -F 100baseTx-FD eth0 ethtool -s eth1 speed 100 duplex full |
ndd -set <device> <parm> <value> lanadmin -X <option> lan0 |
| Test IPMP, Bonding | if_mpadm -d (detach) tail /var/adm/messages |
ifenslave -d bond0 eth1 (detach) cat /proc/net/bonding/bond0 |
|
| display routing table | netstat -n | netstat -rn | netstat -rn |
| displaying network interfaces | prtdiag -v ifconfig -a |
ifconfig system-config-network (GUI) |
ioscan -funC lan (list hardware) lanscan -v (list configured) ifconfig lan0 (individual) |
| display MAC address | ifconfig -a (as user root) | ifconfig system-config-network (GUI) |
lanscan |
| setup DNS | /etc/resolv.conf | /etc/resolv.conf | /etc/resolv.conf |
| Name service switch file (DNS client) | /etc/nsswitch.conf |
/etc/nsswitch.conf /etc/host.conf /etc/resolv.conf |
/etc/nsswitch.conf /etc/resolv.conf |
| Displaying network packets | snoop -d <interface> | tcpdump -i <interface> ethereal (needs to be installed) |
nettl -start use netfmt to display the trace file |
| Domain Name | /etc/defaultdomain | /etc/sysconfig/network (GATEWAY option) | |
| Obtain IP Address routing | route -n get <hostname> | ip route get <IP address> |
| Solaris | Red Hat | HP | |
| display installed patches | showrev -p patchadd -p |
swlist -l patch (HP 11) swlist -l product PH* (HP 10.x) |
|
| adding patch | patchadd patchadd -M <dir> (multiple patches) |
patch -p1 <patch> zcat patch46.gz | patch -p1 Note: -p = # of path stripping |
Note: the swagentd daemon must be running |
| removing patch | patchrm | patch -R -p1 <patch> | swremove |
| display installed packages | pkginfo (all packages) pkginfo -l (single package) pkgchk -l -p <file> (file belongs) |
rpm -qa (all packages) rpm -q (single package) rpm -qf (file belongs) rpm -qi <package> (very detailed) |
swlist -l bundle <bundle> swlist -l product <product> |
| adding package | pkgadd | rpm -Uhv (updates/installs if not already) rpm -ihv (install) |
swinstall |
| removing packages | pkgrm | rpm -e | swremove |
| verify package | pkginfo -l |
rpm -V package | swverity <fileset> (see /var/adm/sw/swagent.log) |
| List files in package | pkgchk -l <package> | grep -i pathname | rpm -ql <package> | swlist -l file <product> |
| Solaris | Red Hat | HP | |
| display users | cat /etc/passwd logins -x |
cat /etc/passwd system-config-users (GUI) |
cat /etc/passwd logins -x |
| adding a user | useradd | useradd system-config-users (GUI) |
useradd sam |
| removing a user | userdel | userdel system-config-users (GUI) |
userdel sam |
| modifying a user | usermod | usermod system-config-users (GUI) |
usermod sam |
| password files | /etc/passwd /etc/shadow |
/etc/passwd | /etc/passwd /tcb/files/auth/r/root (trusted system) |
| Solaris | Red Hat | HP | |
| Time daemons | xntpd |
ntpd |
netdaemons |
| ntp setup | Edit: # Solaris 10 |
chkconfig --list ntpd chkconfig --level 2345 ntpd on /etc/ntp.conf (edit with ntp servers) /sbin/service ntpd start dateconfig (GUI) |
/etc/rc.config.d/netdaemons (set XNTPD to 1) /etc/ntp.conf |
| NTP Trace commands | ntpq -p ntptrace |
ntpq -p ntptrace |
| Solaris | Red Hat | HP | |
| messages | /var/adm/messages | /var/log/messages | n/a |
| syslog | /var/log/syslog | n/a | /var/adm/syslog/syslog.log |
| /var/log/mail | /var/adm/syslog/mail.log | ||
| cron | /var/cron/log | /var/log/cron | /var/adm/cron/log |
| boot | /var/adm/messages | /var/log/boot | /var/adm/syslog/syslog.log |
| Solaris | Red Hat | HP | |
| Checking the passwd file | pwck | pwck | pwck |
| checking the group file | grpck | grpck | grpck |
| console login (allow/deny) | /etc/default/login (Edit file no reboot required) | /etc/securetty (no reboot) | /etc/securetty (no reboot) |
| Solaris | Red Hat | HP | |
| startup | eeprom setenv boot-device |
grub (GUI) lilo (text based) |
setboot -p |
| shutdown | shutdown -i5 -g0 -y (power down) reboot -- -r (reboot/reconfigure) |
shutdown -h (halt) shutdown -r (reboot) shutdown -f (fast reboot no fsck) shutdown -F (force fsck) |
shutdown -h -y (halt) shutdown -r -y (reboot) |
| init status 0 1 2 3 4 5 6 |
0 - shutdown 1 - single user 2 - n/a 3 - Multi-user 4 - n/a 5 - power off 6 - reboot |
0 - halt 1 - single user 2 - multiuser (no networking) 3 - multiuser (networking) 4 - unused 5 - GUI 6 - reboot |
|
| Startup options | -s single user -a interactive -x no device drivers (used in clustering) -r reconfigure devices -m milestone |
linux single single: runlevel1, local fs mounted, no network |
|
| startup scripts | /etc/init.d /etc/rc0.d - /etc/rc6.d |
/etc/init.d /etc/rc0.d - /etc/rc6.d |
/etc/rc.config.d /sbin/rc0.d - /sbin/rc6.d |
| determine the run level | who -r | runlevel | who -r |
| obtain default run level | cat /etc/inittab | cat /etc/inittab | /etc/inittab |
| start xwindows | n/a | startx (shorthand of below) initx (lots of parms) |
n/a |
| force a fsck | n/a | touch /forcefsck shutdown -rF now |
n/a |
| page size (memory) | /usr/bin/pagesize | /usr/bin/getconf -a| egrep -i 'pagesize|page_size' | 4Kb |
| initialize system | sys-unconfig | netconf | set_parms initi |
| Timezone | /etc/TIMEZONE /etc/default/init |
/etc/sysconfig/clock | /etc/TIMEZONE |
| update /dev directory | drvconfig devlinks disks|tapes|ports devfsadm ( solaris 8, 9, 10) |
/dev/MAKEDEV <device> | insf -C tape (Class) insf -H 0.1.0 -e (recreate deleted link) |
| remove device | rem_drv | rmsf | |
| list device drivers | prtconf -D | cat /proc/devices | lsdev |
| change the hostname | change the follwing four files: /etc/nodename |
||
| Device paths | floppy:
disk: |
floppy: disk: tape: cdrom: |
floppy: disk: tape: cdrom: |
| Crash Dump | dumpadm -d <device> crash (used to analyse crash dumps) |
diskdump crash (used to analyse crash dumps) |
edit /stand/system add either: |
| Find Services on network | Boot (jumpstart) servers: NFS servers: NIS servers/slaves: |
Boot (jumpstart) servers: NFS servers: NIS servers/slaves: |
Boot (jumpstart) servers: NFS servers: NIS servers/slaves: |