San Francisco

dave spink toolset




ls /var/lib/rpm ;database directory for installed rpms
ls /var/lib/dpkg ;databasae directory for installed for debian with apt-get
rpm --rebuilddb ;after upgrading RPM program you may need to rebuild rpm database
rpm -Uvh bind.x86_64 ;install or upgrade bind
yum repolist ;OEL and RHEL7 are based on Fedora which uses yum.
yum list ;list of all packages in all repos
yum list installed ;packages installed
yum update ;update all packages
yum info httpd.x86_64 ;package info
yum install httpd.x86_64 ;install apache web server
yum remove httpd.x86_64 ;remove package
apt-get update ;debian uses apt-get for automated installation of packages


service nfs restart ;systemd replaces sysvinit, and services now call systemctl commands
systemctl list-unit-files ;list all units - devices, mounts, paths, servies, sockets
systemctl list-units --type service ;list a specific unit
systemctl restart nfs.service ;restart nfs
systemctl status nfs ;service status
systemctl enable firewalld.service ;enable service
systemctl start firewalld.service ;start service
systemctl stop firewalld.service ;stop service
systemctl disable firewalld.service ;disable service


cat /etc/exports ;see NFS shares
nfsstat -c ;client stats, check retrans, badcalls
nfsstat -s ;server stats
nfsstat -m ;stats for each file system, check srtt round trip times
pgrep nfsd ;get process ID for stack trace
strace -p 243 ;trace process
rpcinfo -u servername mountd ;check NFS server is responding to RPC requests
netstat -rn ;checking routing table
showmount -a ;see what servers are accessing the NFS shares
showmount -e ;see list of NFS shares


free ;includes total RAM, buffers, cache, swap
ps u U spi0004 ;display extra process information for user
top ;use "r" to change process priority, "k" to kill
sar 1 5 ;five samples one second apart
nice -n 12 xterm ;set run priority from default 0 to 10, range -20 to 19
renice 0 14030 ;change run priority on a active process
killall -i xterm ;interactive kill all
netstat -ap ;show listening and nonlistening sockets with PID
uptime ;plus load average over 1, 5 and 15 minute interval
cat /proc/interrupts ;see interrupts in use
tcpdump -q ;used in linux like snoop, docs in /usr/local/doc/tcpdump
strace -p 28218 ;see what the process is actually doing


fdisk /dev/sdb ;partition tool
fdisk /dev/sdb -l ;list partition table
mkfs -V -t ext3 /dev/sdb1 ;a front end to create file systems, this calls mkfs.ext3
mkfs.ext3 -j -v /dev/sdb1 ;also known as mke2fs
fsck -t ext3 /dev/sdb1 ;on run on mounted read only or umounted file systems
fsck.ext3 -f /dev/sdb2 ;also known as e2fsck, -f force a check
mount -a ;mount all file systems in /etc/fstab
mount -t ext3 /dev/sdb1 /backup ;mount file system
mount -t cifs -o username=adcpscorp/dspink //tpawindowsdev/temp /test ;mount Windows share on Linux
mount -t cifs -o username=spi0004 //d1de0199/docs /test ;mount Linux samba share on Linux
cat /etc/mtab ;see mounted file systems


df -l ;ignore network filesystems
df -hT ;display file system type and usage in GB
ls -p ;appends indicator code to show type of file
cp -u fileA fileB ;only copy if fileA is newer than fileB
ln /usr/testprog mylink ;hard link - ln source link
find ./ -maxdepth 1 -name gtypist-2.7.tar.gz ;limit number of subdirectories to search
find / -uid 501 ;find all files with UID 501
find / -perm /2000 ;find all files with SUID bits set
locate yum ;like find, but searches a database updated by updatebd
updatedb ;updates located database, normally forms part of cron
whereis samba ;searches in standard certain locations
whatis samba ;searches whatis database for words
chgrp sapusers myfile ;change group ownership for this file
setfacl -m user:spi0004:r-- myfile.txt ;-m set an ACL, requires acl mount option in /etc/fstab
getfacl myfile.txt ;see ACLs on a file
logrotate ;rotate log files
su -c "rm -rf /tmp*" ;remove all files first prompting for root password
dd if=/dev/zero of=/shareX/testfile.out bs=1MB count=1000000 ;create file 1MB IOs
dd if=/shareX/testfile.out of=/dev/null bs=128K count=1000000 ;read file 128KB chunks


/usr/lib/systemd/systemd ;in RHEL7 /sbin/init is now a symbolic link to /usr/lib/systemd/system
cat /etc/systemd/system/ ;in RHEL7 the direction for booting depends on
cd /etc/systemd/system/ ;see symlinks to services started
cat /etc/nsswitch.conf ;search order
cd /etc/sysconfig/network-scripts ;see ifcfg-eth0
route add default gw ;add default route
route add -net netmask gw ;add route with gateway
route add -net netmask dev eth0 ;add route
route del -net netmask dev eth0 ;delete route
echo "1" > /proc/sys/net/ipv4/ip_forward ;configure linux as router
vi /etc/sysctl.conf ;see net.ipv4.ip_forward = 0


journalctl -k ;see kernel messages from current boot
cat /etc/crontab ;display system crontab
tail -f /var/log/cron ;cron log
cat /var/spool/cron/root ;see cron entries created by user root
at -f mycmds.txt noon ;run job with commands in file at noon
atq ;see queued jobs
Ctrl+A ;moves cursor to start of line
Ctrl+E ;moves cursor to end of line
info ;newer version of man pages
export PATH=$PATH:/usr/local/bin ;bash set environment variable
setenv PATH "${PATH}:/usr/local/bin" ;tcsh set environment variable
cat /etc/samba/smbpasswd ;see contents of samba file
smbpasswd -a drstemp ;add user to samba password file
smbpasswd -x drstemp ;delete user from samba password file
mount -t cifs -o username=adcpscorp/dspink //tpawindowsdev/temp /test ;mount Windows share on Linux
mount -t cifs -o username=spi0004 //d1de0199/docs /test ;mount Linux samba share on Linux
smbclient -L d1de0199 ;see list of available shares
smbclient //d1de0102/docs ;gives ftp like commands i.e. after logging in
nmblookup -U tpaexbe02n1 ;queries WINS database, like nslookup on DNS
IP Tables
iptables -L -t filter ;see filter table (other tables are nat and mangle)
iptables -t filter -F FORWARD ;flush all rules in FORWARD chain
iptables -t filter -F FORWARD DROP ;flush rules and set default policy to DROP
iptables -A INPUT -p udp --sport 53 -j ACCEPT ;let DNS traffic
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT ;let DNS traffic