Show Menu
Cheatography

New Hire Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Commands and Tasks

Kernel Inform­ation
uname -sr
CPU Info
cat /proc/­cpuinfo
Memory Info
free -h
Reboots Info
last reboot
List Block Devices
lsblk
Get BIOS settings
racadm get BIOS.S­ysP­rof­ile­Set­tings
Look for Attack Scripts
strings root/dos64 | grep -i attack
Look for Spam - Subjects
tcpdump -nn -i SRVID##### -A "dst port 25" | grep -i subject
Dead Processes
ps aux | awk '$8 ~ /D/'
Limit IOPS
virsh blkdev­iotune SRVID##### sda --tota­l_i­ops­_se­c=100
Look for port in use
netstat -lp | grep <PORT TO FIND>
Add IPTables rules
iptables -I INPUT -s <YO­UR_­IP> -j ACCEPT
Remove IPTables rules
iptables -D INPUT -s <YO­UR_­IP> -j ACCEPT
Gracefully shut down all guests
virsh list | awk '{print $2}' | grep SRVID | xargs -n1 virsh shutdown
Earliest sign of disk failure
cat /var/l­og/­mes­sages | grep exception
Get Serials
smartctl --info /dev/sda | fgrep -i Serial
Get Serials and Firmware
hdparm -I /dev/s­d[a-d] | grep 'Numbe­r\|­Rev­ision'
 

Ceph

Ceph Health
ceph health detail
List Ceph Disks
ceph-disk list
Setting 'noout'
ceph osd set noout
Removing 'noout'
ceph osd unset noout
Fix Incons­istant PGs
ceph pg repair {id}
Start Ceph OSD (Centos 6)
service ceph (start­|st­op|­res­tart) osd.{id}
Start Ceph OSD (Centos 7)
systemctl (start­|st­op|­res­tart) ceph-o­sd@{id}
List down OSDs
ceph osd tree | grep down
Locate host of an OSD
ceph osd find {id}

SmartMon Tools

Check Health
smartctl -H /dev/<­DIS­K>
Short Test
smartctl -t short /dev/<­DIS­K>
Check Results of Test
smartctl -a /dev/<­DIS­K>

TCPDUMP

Capture all traffic
tcpdump -nn -i SRVID#####
Capture Outbound SMTP
tcpdump -nn -i SRVID##### -A "dst port 25"
Capture new TCP connec­tions
tcpdump -nn -i SRVID##### "­tcp­[tc­pflags] & (tcp-syn) != 0"
 

DNS

Lookup records of domain
dig +answer <DO­MAI­N>
Look for A records of domain
dig +noall +answer <DO­MAI­N>
Reverse DNS of an IP
dig -X +noall +answer <IP­_AD­DRE­SS>
Lookup domain inform­ation
whois <DO­MAI­N>
Lookup MX records
dig +noall +answer <DO­MAI­N> MX
Lookup TXT records
dig +noall +answer <DO­MAI­N> TXT
Lookup namese­rvers
dig +noall +answer <DO­MAI­N> NS

VIRSH

List all VMs
virsh list --all
Start a VM
virsh start <VM­_NA­ME>
Stop a VM
virsh destroy <VM­_NA­ME>
Undefine a VM
virsh undefine <VM­_NA­ME>
Define a VM
virsh define <PA­TH_­TO_­XML>
Dump the config­uration
virsh dumpxml <VM­_NA­ME>

.

 
 

LVM

Display physical volumes
pvs
Display volume groups
vgs
Display logical volumes
lvs
List VGs and their UUIDs
vgs -o +pv_na­me,uuid
Rename an LV
vgrename <UU­ID> <Ne­w_N­ame>
Activate an VG
lvchange -a y <vo­lum­e_g­rou­p>
Activate and ensure working VG
lvs | awk 'BEGIN {OFS = "­;"} {print $2,$1}' | sed 's/;/\//g' | grep <lo­gic­al_­vol­ume> | xargs -n1 lvchange -ay
Deactive a VG
vgchange -a n <vo­lum­e_g­rou­p>.bak
Create an LV
lvcreate <vo­lum­e_g­rou­p> --name <ne­w_l­v_n­ame> --size ##G
Remove an LV forcefully
lvremove -f /dev/<­vol­ume­_gr­oup­>/<­log­ica­l_v­olu­me>