Rebuild GRUB from a Live CD!

Posted in Uncategorized on January 31st, 2012 by Brad Turnbough – Be the first to comment

To rebuild the grub bootloader, follow these commands:

mkdir /harddrive

mount /dev/sda1 /harddrive

mount -o bind /dev /harddrive/dev

mount -o bind /proc /harddrive/proc

chroot /harddrive bash

sudo update-grub

reboot

Virtual Box / Switching between TTY’s

Posted in Uncategorized on January 31st, 2012 by Brad Turnbough – Be the first to comment

Use the following key sequence to switch between TTY’s in a virtualbox VM.

If your HOST KEY is the right ctrl, you want to press:

right ctrl + F1

Stop LightDM from Loading in Ubuntu 11.10!

Posted in Uncategorized on January 31st, 2012 by Brad Turnbough – Be the first to comment

Although this isn’t exactly what I was looking for, this will suffice for the time being.  This will stop lightdm from loading upon bootup and instead kick you to tty1.

Drop to a terminal and blast in the following:

echo “manual” >> /etc/init/lightdm.override

sed -i ’s/quiet splash/text/’ /etc/default/grub

update-grub

reboot

SSH-Agent Info

Posted in Uncategorized on January 19th, 2012 by Brad Turnbough – Be the first to comment

Ssh-agent bash

Ssh-add /user/username/id_dsa

Enter in password

Then you can log in to the machine (additional options are to surpress Host Key verification, and warnings / errors)

ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@hostname

DHCP Hostname for Centos 6

Posted in Uncategorized on January 15th, 2012 by Brad Turnbough – Be the first to comment

To get a client to send its hostname during a DHCP request, add the following to the /etc/sysconfig/network-scripts/ifcfg-eth0 file:

DHCP_CLIENT_ID={thehostname}
DHCP_HOSTNAME={thehostname}

Ubuntu History

Posted in Uncategorized on January 15th, 2012 by Brad Turnbough – Be the first to comment

Just for my notes:

8.04        Hardy Heron (LTS)

8.10        Intrepid Ibex

9.04        Jaunty Jackalope

9.10        Karmic Koala

–Implemented Ubuntu One….was buggy and a piece of garbage

10.04     Lucid Lynx (LTS)

10.10     Maverick Meerkat

11.04     Natty Narwahl

–Implemented Unity, slow and buggy, but GDM is still optional

11.10     Oneric Ocelot

–Requires Unity 2D/3D, but can install GDM if you have the knowhow

12.04     Precise Pandolin (LTS)

Script to Crawl the Network

Posted in Uncategorized on January 15th, 2012 by Brad Turnbough – Be the first to comment

dig -t axfr domain.com | grep ^ws | grep -v — -rac | awk {’ print $1 ‘} > /users/username/servers_list

echo “Operating System | Hostname | Operating System Label | Operating System Version | Operating System Patch Level | Notes” | tee /users/username/output.txt

for myFile in /users/username/servers_list
do
while read myLine
do
if nc -z -w5 $myLine 22 2>/dev/null
then
#                       echo “$myLine — port is open”
OS=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $1}’)”

if [ "$OS" = "Linux" ];
then
thehostname=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $2}’)”
if [ -n "ssh -n -o LogLevel=ERROR-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine ls /etc/SuSE-release 2>/dev/null" ];
then
#                                     echo “file exists”
oslabel=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine cat /etc/SuSE-release | grep SUSE)”
osversion=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine cat /etc/SuSE-release | grep VERSION)”
ospatchlevel=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine cat /etc/SuSE-release | grep PATCHLEVEL)”
echo $OS “|” $thehostname “|” $oslabel “|” $osversion “|” $ospatchlevel | tee -a /users/username/output.txt
else
#                                   echo “file doesn’t exist”
echo $OS “|” $thehostname | tee /users/username/output.txt
fi
fi

if [ "$OS" = "SunOS" ];
then
thehostname=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $2}’)”
oslabel=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $1}’)”
osversion=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $3}’)”
ospatchlevel=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $4}’)”
echo $OS “|” $thehostname “|” $oslabel “|” $osversion “|” $ospatchlevel | tee -a /users/username/output.txt
fi

if [ "$OS" = "HP-UX" ];
then
thehostname=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $2}’)”
oslabel=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $1}’)”
osversion=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $3}’)”
ospatchlevel=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $6}’)”
echo $OS “|” $thehostname “|” $oslabel “|” $osversion “|” $ospatchlevel | tee -a /users/username/output.txt
fi

if [ "$OS" = "AIX" ];
then
thehostname=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $2}’)”
oslabel=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $1}’)”
osversion=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $4}’)”
ospatchlevel=”$(ssh -n -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$myLine uname -a | awk ‘{print $333}’)”
echo $OS “|” $thehostname “|” $oslabel “|” $osversion “|” $ospatchlevel | tee -a /users/username/output.txt
fi
else
echo “XXXXX | $myLine | XXXXX | XXXXX | XXXXX | Port 22 is closed” | tee -a /users/username/output.txt
fi
done < $myFile
done

Ubuntu and APC UPS Units

Posted in Uncategorized on January 14th, 2012 by Brad Turnbough – Be the first to comment

Ubuntu is able to communicate with APC UPS units.  To begin with, install apcupsd.

apt-get install apcupsd

Modify the “UPSCABLE” line in /etc/apcupsd/apcupsd.conf:

UPSCABLE usb

Modify the “UPSTYPE” line in /etc/apcupsd/apcupsd.conf:

UPSTYPE usb

Modify the “DEVICE” line (so it is blank) in /etc/apcupsd/apcupsd.conf:

DEVICE

Modify the “ISCONFIGURED” line in /etc/default/apcupsd:

ISCONFIGURED=yes

Restart APCUPSD:

service apcupsd restart

Verify connectivity:

apcaccess

Setting A Static IP Address

Posted in Uncategorized on October 12th, 2011 by Brad Turnbough – Be the first to comment

How to set up an in address statically in CentOS 6:

edit /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=”eth0″
BOOTPROTO=”static”
HWADDR=”d0:54:56:9A:00:22″
NM_CONTROLLED=”yes”
IPADDR=”172.24.21.145″
NETMASK=”255.255.255.0″
NETWORK=”172.24.21.0″
ONBOOT=”yes”

edit /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=PCNAME
GATEWAY=”172.24.21.1″

Locate Zombie Processes Easily…

Posted in Uncategorized on October 12th, 2011 by Brad Turnbough – Be the first to comment

While implementing a monitoring solution, I needed a way to count how many zombie processes there are.  This is a perfect way of doing so:

ps aux | awk ‘{ print $8 ” ” $2 }’ | grep -w Z | wc -l