Quick Reference Commands

That extra umph when your almost there

FreeBSD

Restart Networking: /etc/rc.d/netif restart && /etc/rc.d/routing restart
gmirror:
  1. sysctl kern.geom.debugflags=16
  2. gmirror label -vb round-robin gm0 /dev/ad4
  3. FSTAB: /dev/mirror/gm0*(remove ad4 and leave s1a,b, etc...)
  4. echo geom_mirror_load=YES >> /boot/loader.conf
  5. REBOOT
  6. gmirror insert gm0 /dev/ad6
  7. gmirror status
Rebuild Failed gmirror:
# gmirror forget gm0
# gmirror insert gm0 /dev/"NEW HDD"

Debian

Networking scripts:
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.90
gateway 192.168.1.1
netmask 255.255.255.0

Debian Aliases:
auto eth0:1
iface eth0:1 inet static
address 192.168.2.22
netmask 255.255.255.0

Centos

Networking scripts:
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.50
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet

Check RPM of your HDD

  1. yum install sg3_utils
  2. sginfo -g /dev/"drive"

To get rid of networkmanager...
  1. rpm -e networkmanager
  2. enable regular network scripts -- cd /etc/rc3.d; ln -s
  3. /etc/init.d/network S10network
Linux Range Files:
vi ifcfg-eth0-range0
IPADDR_START=192.168.0.2
IPADDR_END=192.168.0.5
CLONENUM_START=0

GUI config: system-config-* (e.g. date, network, users)

Windows

Clear TCP stack: netsh int ip reset resetlog.txt
Netstat: netstat -nab

Slow RDP in win7:
netsh interface tcp set global autotuninglevel=disabled
netsh interface tcp set global rss=disabled

Allow Ping in Server2008: netsh firewall set icmpsetting 8

DiskPart during windows install: Shift-F10->diskpart->list disk->sel disk->clean all

Restart Networking: net stop netman, net start netman

All Linux Platforms

Traceroute DNS:dig @ns1 +trace ns [foo.bar]
Show connections on a server: netstat -an | grep :80 | sort | wc -l
Show details process: lsof -ni4 | grep rhnmd

Copy a drive using dd: dd if=/dev/sda of=/dev/sdb bs=1024
Watch status of dd: watch -n 10 kill -USR1 [PID]

Generating ssh Keys:
On the local computer:
1. ssh-keygen -t dsa
2. scp ~/.ssh/id_dsa.pub root@remote_computer:/root/.ssh/authorized_keys

Show connected IPs: netstat -atun | awk '{print $5}' | cut -d: -f1 | sed -e '/^$/d' |sort | uniq -c | sort -n
Show connection state: netstat -nat | awk '{print $6}' | sort | uniq -c | sort -n
Show established with IP: netstat -ntu | grep ESTAB | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr
More connection states: netstat -n -p | grep SYN_REC | sort -u
Allow Ping from Host: iptables -I INPUT -s xx.xx.xx.xx/*CIDR* -j ACCEPT -p icmp --icmp-type echo-request
Find and replace words in a file: sed -i s/*words to replace*/*words to replace with* filename.foo (Use a # after the S if what you are replacing is a /)
Sync Time: ntpdate -u pool.ntp.org

Helpful Troubleshooting Websites

Just Ping
Way Back Machine
RHCE WIKI
SQL Help

MySQL

Adding User: grant ALL on DATABASENAME.* to USER@localhost;
Set user password: set password for USER@localhost = password('PASSWORD');
MySQL Dump(backup): mysqldump -u (username) -p -l (databasename) > (databasename).sql
MySQL Restore: mysql -u (user) -p < filename.sql
Extract DB from a dump File: mysql -u root -p --one-database db_to_restore < fulldump.sql
Show Users: select * from mysql.user;

Linux Compromised Help:

who
last -20
ls -lart /
lsof | grep IPv
lsof | grep LIST
lsof | grep ESTAB
history
rpm -VA
find / -mtime 2 #modify date
find / -ctime -2 -print #inode time
tcpdump -vvxXs 1500 -i eth0 'port X'