What I Learned Today
Emulate network latency using tc

Use this code:

PATH=$PATH:/sbin
lat=$1  ## desired bandwidth in megabits per sec
destip=$2  ## destination host to limit traffic to

if [[ -z $lat ]]
then
        lat=100
fi

if [[ -z $destip ]]
then
        echo "using default IP: 192.168.245.21"
        destip=192.168.245.21
fi

echo "note this may not work for VMs since it uses eth instead of peth0"

tc qdisc del dev eth0 root

tc qdisc add dev eth0 root handle 1: prio
tc qdisc add dev eth0 parent 1:3 handle 30: netem \
     delay ${lat}ms 
## add to end of previous line for distribution: 10ms distribution normal

## I think the line below is for bandwidth
#tc qdisc add dev eth0 parent 30:1 tbf rate 20kbit buffer 1600 limit 3000

tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 \
     match ip dst $destip/32 flowid 1:3

(Source: linuxfoundation.org)

Making a /proc entry with a kernel module

This is actually really simple. 

Just follow this example.

Resize an LVM disk and FS

Resize the partition using LVM:

sudo lvextend -L30G  /dev/mapper/VolGroup00-LogVol05

Unmount the partition (hopefully it isn’t the root!):

sudo umount /dev/mapper/VolGroup00-LogVol05

Check the FS for errors

sudo e2fsck -f /dev/mapper/VolGroup00-LogVol05

Adjust the FS to the new size

sudo resize2fs /dev/mapper/VolGroup00-LogVol05

Remount the disk

sudo mount /dev/mapper/VolGroup00-LogVol05 /home

List all modules on linux system

Run: cat /proc/modules or lsmod

Adjust number of file descriptors

cat >> /etc/security/limits.conf
*               hard    nofile          32768
*               soft    nofile          32768
Test with: ulimit -n

Crontab start at bootup

To run a script or command at every restart, add this to crontab by running crontab -e

  @reboot /path/to/my/program

Setup an NFS Server

On host machine, edit: /etc/exports add lines like:

/home/twood *(rw)

to let anybody mount /home/twood in read-write mode. Then you will probably need to restart the NFS server:

/etc/init.d/nfs restart

On the destination machine, run:

mount hostip:/home/twood /mnt/twood

Adding to PATH in bash

to add common directories to your path, edit .bashrc and add:

PATH=$PATH:/usr/sbin:/sbin

Then run: source .bashrc to load the changes