7.21.2015

Bash Cheat Sheet

1. Run a script with no output and in the background
$ ./my_script.sh > /dev/null 2>&1 &

2.  Run a script with no output and in the background and see the pid
$ ./my_script.sh > /dev/null 2>&1 & echo $!

3. Template script that loops thru and writes to a file
#!/bin/bash

# $1 - number of minutes
# $2 - task id
COUNTER=$(($1*60/5))
TOTAL=$COUNTER
echo Perfload will run for $1 minutes
echo "Perfload will run for $1 minutes" > /tmp/$2.log
until [  $COUNTER -eq 0 ]; do
    echo The counter is $COUNTER
    PROGRESS=$(echo "scale=2;($TOTAL - $COUNTER)*100/$TOTAL" | bc -l)
    echo "Perfload RUNNING $PROGRESS %" >> /tmp/$2.log
    let COUNTER-=1
    sleep 5
done
echo "Perfload SUCCESS" >> /tmp/$2.log


7.14.2015

Cisco Switch Cheat Sheet


sho lldp neighbors
sho cdp ne

switch-name# show mac address-table | i 0060.165c.f83e
* 2016     0060.165c.f83e    dynamic     ~~~      F    F  Eth1/22

switch-name# sho int description | grep 'yogi34 eth4b'
Eth8/19       eth    10G     yogi34 eth4b 90E2BA068BB1

switch-name# show interface ethernet 2/27 description
-------------------------------------------------------------------------------
Port          Type   Speed   Description
-------------------------------------------------------------------------------
Eth2/27       eth    10G     artemis59-eth3b 0060.1645.505a

switch-name(config)# config
switch-name(config)# int e8/19
switch-name(config-if)# inherit port-profile Apposite
switch-name(config-if)# exit
switch-name(config)# exit
switch-name# copy run startup-config

switch-name# show interface ethernet 1/28 switchport

# If missing VLANs, can set using...
switch-name(config-if)# switchport trunk allow vlan 2016,2030-2049