Search Filesystem for String in a File

Uncategorized No Comments

To scan a linux filesystem and find all files containing a specific string.

find / -type f -print0 | xargs -0 grep -i STRING

Server Archived Log Files

Uncategorized No Comments

We have a policy to retain our security log files for 90 days. Our domain policy is setup to auto archive the logs instead of overwriting them. The problem is that the 90 day rule doesn’t stick since there aren’t any entries in the current log file for longer than 90 days. Over the course of the year the log files will eventually fill up our servers c:\ drive.

A quick remedy….

forfiles -p "c:\windows\system32\winevt\logs" -s -m Archive-Security* -d -90 -c "cmd /c del @path"

Batch file to delete all but latest two files

Uncategorized No Comments

@echo off
set folder=C:\test

pushd "%folder%"
for /f "skip=2 tokens=*" %%i in ('dir /a:-d-s /b /o:-d') do echo "%%i"

*** Stolen from Major Geeks forum member GermanOne

pfSense – Captive Portal

Uncategorized 1 Comment

To have reusable vouchers:

Edit /etc/inc/ and modify:

/* This user was already logged in so we disconnect the old one */
captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"CONCURRENT LOGIN - TERMINATING OLD SESSION");


/* This user was already logged in so we disconnect the old one */
if (isset($config['captiveportal']['noconcurrentlogins']))  {
captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"CONCURRENT LOGIN - TERMINATING OLD SESSION");

To get smaller voucher codes:

Generate new private and public key pair (can be done on any computer.)

openssl genrsa 31 > key.private
openssl rsa -in key.private -pubout -out key.public

Paste key.private and key.public in Services > Captive Portal > Vouchers under Voucher Public Key and Voucher Private Key.

I also changed the Character Set to: “2345678abcdefhjkmnpqrstuvwxyz”

It then generated 7 character voucher codes.

Grub2 Customizer

Linux No Comments

My previously written custom script to make Windows and Ubuntu show as the first two items in Grub no longer works after my latest install of Ubuntu 12.04. Looks like its back to using a utility to do the job.

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer

Taken from:

Disable IPv6 from CLI

Uncategorized No Comments

This must be run from a Administrator Command Prompt.

\Tcpip6\Parameters /v "DisabledComponents" /t REG_DWORD /d 0xffffffff

Windows XP Add New Hardware USB

Uncategorized No Comments

Recently ran into a problem where an XP Machine was always popping up asking to install drivers for every little thing including USB Mouse and USB Mass Storage Device which shouldn’t ever happen. To fix it where it automatically installs the driver and assigns a drive letter go to the Command Prompt and type each of the following:

regsvr32 Softpub.dll
regsvr32 Wintrust.dll
regsvr32 Initpki.dll
regsvr32 Dssenh.dll
regsvr32 Rsaenh.dll
regsvr32 Gpkcsp.dll
regsvr32 Sccbase.dll
regsvr32 Slbcsp.dll
regsvr32 Mssip32.dll
regsvr32 Cryptdlg.dll

Software Activation Workaround

Windows No Comments

Was working in a local Dr. Office who is no longer paying a subscription/maintenance on their software since I am now taking care of supporting them. All of a sudden, without warning, their software required activation. I have saved the activation file for the server but this time it didn’t work to just put the file back. Turns out it was connecting back to their activation server. I ended up tracking down the solution with…

c:\>ipconfig /displaydns

Windows IP Configuration

         Record Name . . . . . :
         Record Type . . . . . : 1
         Time To Live  . . . . : 601260
         Data Length . . . . . : 4
         Section . . . . . . . : Answer
         A (Host) Record . . . :


At this point I knew that it was resolving “”. I simply added the following line to the hosts file and the server no longer checks for activation and my LEGIT license file still works!
*Obviously for privacy and security the “” is a fictional domain. The subdomain was identical but the domain is fictional.

Custom Grub Script for Dual Booting Ubuntu 9.10 and Windows XP

Linux No Comments

Most of the work I do with Ubuntu Linux is on home computers where the user needs to have Windows XP (Vista, 7) as a boot option. The best way for Ubuntu, or Linux in general, to work is if its on its own partition and not installed with the Wubi Installer. One of the main issues I have with installing Ubuntu on its own partition is that the Grub2 Boot Loader menu looks terrible and is confusing once you’ve gone through several kernels updates. I wanted a simple and easier to understand Grub2 menu and something that would take care of itself in the long run.

This script makes four entries at the top of the Grub2 boot menu.


Other boot options:

The one titled “Ubuntu” should be the same as your first Ubuntu option and most updated kernel. The “Windows” is the first option returned by “/etc/grub.d/30_os-prober”. Which should return a bootable Windows Partition. This still leaves all the original boot options underneath so you can still take advantage of selecting an older kernel or the recovery mode. It will also include any Windows Recovery partitions as well towards the very bottom.

Disclaimer: I have no idea what this will actually do out in the wild. I surely can’t account for every scenario but I’ve done MY best and tested with a couple of systems with success!

Note: Do not use this if you are doing more than just dual booting Ubuntu and Windows!

Here is what my partition tables look like on the computer I tested with today. The script worked perfectly on it. As well as another Windows 7 machine I tested on.

/etc/grub.d/05_custom :


awk '/BEGIN\ \/etc\/grub\.d\/10_linux/,/END\ \/etc\/grub\.d\/10_linux/' /boot/grub/grub.cfg > /tmp/grub1.tmp
LINE1=`grep menuentry /tmp/grub1.tmp -n | cut -f1 -d: | head -n1`
LINE2=`grep } /tmp/grub1.tmp -x -n | cut -f1 -d: | head -n1`
echo 'menuentry "Ubuntu" {'
sed -n "${LINE1},${LINE2}p" /tmp/grub1.tmp | sed -n "2,${LINE2}p"

#check for NTFS partitions!
#This also means this script is only for XP, Vista, or Win 7. (Not tested with Vista and Win7 yet!)
chkntfs=`sfdisk -l 2> /dev/null | grep NTFS -n | cut -f1 -d:`

if [ -n "$chkntfs" ]; then 
#grub-mkconfig 2> /dev/null | awk '/BEGIN\ \/etc\/grub\.d\/30_os-prober/,/END\ \/etc\/grub\.d\/30_os-prober/' > /tmp/grub2.tmp
awk '/BEGIN\ \/etc\/grub\.d\/30_os-prober/,/END\ \/etc\/grub\.d\/30_os-prober/' /boot/grub/grub.cfg > /tmp/grub2.tmp
LINE1=`grep menuentry /tmp/grub2.tmp -n | cut -f1 -d: | head -n1`
LINE2=`grep } /tmp/grub2.tmp -x -n | cut -f1 -d: | head -n1`
echo 'menuentry "Windows" {'
sed -n "${LINE1},${LINE2}p" /tmp/grub2.tmp | sed -n "2,${LINE2}p"
echo "There were no NTFS partitions found!" >&2

#entries must point somewhere or they don't show up.
#might as well be the partition that houses our kernel. 
#also, when its selected it just shows the menu again.
#which makes it a nice dummy file.

echo "menuentry \\" \\" {"
echo "	insmod ext2"
echo `cat /tmp/grub1.tmp | grep "set root" | head -n1`
echo "}"

echo "menuentry \\"Other boot options:\\" {"
echo "	insmod ext2"
echo `cat /tmp/grub1.tmp | grep "set root" | head -n1`
echo "}"

To create the file and mark it executable… Open Terminal (Applications > Accessories > Terminal)

sudo gedit /etc/grub.d/05_custom
sudo chmod +x /etc/grub.d/05_custom
sudo update-grub

End result:

At this point you could make Windows default by editing /etc/default/grub and chaning the line:


I welcome any and all suggestions on how to improve this script. I make no claim to be very good at BASH scripting but I needed this and couldn’t find any other solutions!

Favorite Wallpapers for Ubuntu

Uncategorized No Comments

Here are two of my favorite wallpapers for Ubuntu. I like to go Distro themed when I work on computers by default.


Originally from Atkarus Designs.

« Previous Entries Next Entries »