KVM and Ubuntu 11 i686 and iptables

May 6th, 2012

I was creating virtual guests in KVM on my Ubuntu 11 host. The problem I was experiencing was not having the ability to connect to the guest from outside the host’s console.

The guest was a Window’s Server 2008 Standard. I needed to connect to the server via RDP. Here were the two lines I ran against iptables to get it to work:

sudo iptables -t nat -I PREROUTING -p tcp –dport 3389 -j DNAT –to-destination 192.168.122.187:3389
Read the rest of this entry »

Firefox, Flash Player 11, and Ubuntu 8.04 not working – Google Chrome

April 9th, 2012

Hi,

It appears the Ubuntu is having problems with THEIR modifications to FireFox and how it handles Adobe Flash with version 11. Developers can say what they want about about Flash supporting 64 bit. The bottom line is that users are having problems with Ubuntu FireFox 11.

I do allot of work with Firefox in managing websites and overall web browsing. I also do alot of development for other software and cannot find the time right now to fix the package problems. I over came this by installing google-chrome online. The package comes ready for use with the Debian installer.

After installing google-chrome (5 minute process) I was able to open the browser and start viewing videos with Flash Player. There was no special package installations or grabbing addons. After the installation, I was even provided the oportunity to migrate my bookmarks from a previous FireFox installation.

Ubuntu has great server and desktop operating systems. Being open source is only another plus to the operating systems. However, I have seen where open source projects start to get skewed by developers trying to compete with the “big boys”. I think that Ubuntu has let the debian crew take too much control of the project. If I wanted to install debian packages I would have installed Debian on the PC or server.

Please take a chance to get your house in order. Many open source projects have suffered due to a course change in the middle of gaining acceptance. For now install Google-Chrome to use flash and import your Bookmarks from FireFox.

Installing CentOS 6.2 from the net installer ISO on a 1 GB Kingston DataTraver USB stick

March 29th, 2012

What is nice about CentOS 6.2 is the ability to install the OS from a USB stick. Here is how I performed my installation.

  1. The USB stick had been used before, so I reformatted it to NTFS to simulate the file system when it was first acquired. I plugged it into my Windows 7 system and reformatted the stick.
  2. On another Linux system I downloaded the ISO at http://mirror.ncsa.illinois.edu/centos/6.2/isos/i386/CentOS-6.2-i386-netinstall.iso.
  3. I mounted the USB stick on the Linux system. You will need to install the ntfs-3g package if you want to see the memory stick. With CentOS 6.2 the package is fuse-nfts-3g. You can mount it anywhere because we are more concerned with the device name than the mount point. Once it is mounted run a `df` command to see the device name.
  4. The command to run is:
    `dd if=/path/to/iso/CentOS-6.2-i386-netinstall.iso of=/dev/sdb (or the device name for your USB stick as found with the `df` command) bs=1M`
  5. It will return to a command prompt when finished.
  6. Un-mount the USB stick: `umount /dev/sdb`
  7. ENSURE your machine is set to boot from a USB device. Re-mount the USB stick and restart the machine.
  8. The machine should boot into the install mode.
  9. I found it is better to select “Install with minimal video drivers” instead of shooting for the Gnome installation.
  10. The URL I used for the installation was http://mirror.centos.org/centos/6/os/i386/. Your URL will vary by the platform you are building.
  11. NOTE: Since you are using the Internet for the installation, download and there for installation times will vary.
  12. You can perform the default partitioning. It will basically divide the hard drive into 1 primary partition /boot and three logical partitions swap, / , and /home. If you have a large hard drive you might not like that, because now you have lost the ability to use the space for other projects unless you want to perform and lvmresize. The default file system is ext4.
  13. How you configure the software is up to you. If you are running on an x86 machine, KVM will not longer be supported with CentOS 6. Seems like a shame to just drop the platform, but the business side won. So you will need to compile another virtual environment or by-pass the whole CentOS installation and install VMWare ESX, which is free.

These directions also work for the LiveCD installation on a 1GB Memory stick.

Enjoy!

Grub error 15 File not found on Ubuntu and Linux

March 28th, 2012

Don’t normally do this, but I was editing the menu.lst file  on my Ubuntu machine and thought I would be cool and just replace some of the file names. Well, I did not fair too well. I received the infamous Grub error 15: File not found with any of my boot selections.

While I wanted to upgrade the system, this was not the time. So here is what I did to rectify the situation without having to install the system.

  1. Download a Linux LiveCD. If you cannot find a LiveCD, then download an installation CD for the OS.
  2. I happened to have my old and trusty Ubuntu 8.04 CD.
  3. At the Ubuntu prompt, I selected “Try Ubuntu without any change to your computer”, which should be a LiveCD version..
  4. This is where we tell the Linux Administrators apart from the rest. You should have the disk partitioned and know which partition everything is on. Remember, the boot partition needs to be physical and not an LVM partition. So, I know that /boot is located on /dev/hda2 because Windows is running on /dev/hda1.
  5. It takes a couple of minutes for the LiveCD to boot, so be patient. If you are watching the LED on the CD player and it stops for a couple of minutes, just restart the machine after cleaning the CD.
  6. The mistake I had to correct was stupid. See if you can pick it out from these screen shots.
  7. Here is a listing of the boot packages I have under /boot.
  8. Now, here is the fixed menu.lst file.
  9. The moral of the story is don’t panic when you make a mistake. Look towards the learning experience. After all, a Linux Administrator is someone who breaks things to see how they work.

Enjoy your Linux system and don’t be affraid to experiment. After all you are getting good backups right?

Configuring Windows Updates on Windows 2003/2008 to benefit your organization

March 11th, 2012

There are advantages to configuring Windows Updates to automatically install on workstations. However, having Windows updates set to automatically install can be catastrophic to the organization. The default Windows Update time is 3 AM, which can cause interference with backing up data, month and year end reporting, and users working late on a project.

Here is how to configure Windows Updates for Windows Server 2003/2008.

  1. Click on Server Manager on the task bar.
  2. Under Security Information click on Configure Updates.
  3. Select Change Settings
  4. Under Important Updates select  “Download updates but let me choose  whether to install them”
  5. If you have limited Internet bandwidth, you might want to select “Check for updates but let me choose whether to download and install them.” This will allow you to choose a good time when the organization is not placing a load on your Internet.
  6. Now, go to http://technet.microsoft.com/en-us/security/dd252948 and sign up for security notifications. Businesses today rely heavily upon data housed within the Windows server environment. Can you afford not to know what could prove to be a liability to the live-blood of your business.

Perl: Random dice game using array, case, and for Windows with Perl installed

March 4th, 2012

I had a bit of free time, so I created this craps game for Windows. You can also run it on Linux and Unix by changing the path to where your Perl is located on the system. The application uses variable, a pre-defined array length, functions, and a do – while loop with a sentinal value to terminate the loop.

I was a little tired of looking for examples of how to use Perl functionality and not seeing anything with practical usage. You can download Active Perl for free at: http://www.activestate.com/activeperl/downloads .

Enjoy!

 

#!C:\Perl64\bin\perl -w

#Crap Shoot is a fun dice game
#Programmer: Mike Kniaziewicz
#Version: 1.0.0
#Revision Date: 3/3/2012 

use strict;
use warnings;

#Declare variables
my $counter;
my $x;
my $rand_number;
my $answer;
my $totalroll;
my @dice = (1..3);
my $dice;

#Using a do - while loop because everyone would want to play at least
# once.

do {

print "\n\nRoll #:\t" . ++$counter . "\n\n";

#Generate the random number and total for the roll.
$totalroll = 0;
for ($x = 1; $x < $#dice + 1 ; $x++)
{
$dice[$x] = &random_number;
print "Roll # " . $x . ":\t" .  $dice[$x] . "\n\n";
$totalroll = $dice[$x] + $totalroll;
&draw_dice;
print "\n";
}

print "Total roll is:\t" . $totalroll  . "\n";
&makepoint;

&Instructions;

#Get the response to playing again
$answer = <STDIN>;
chomp($answer);
} while ($answer eq "y");

sub Instructions
{
	print "\nEnter y to roll again: ";
}

sub random_number
{
	my $rand_dice = int( rand(6)) + 1;
	return $rand_dice ;
}

sub draw_dice
{
 	if ($dice[$x] == 1)
		{
			print "\t\t.......\n";
			print "\t\t.     .\n";
			print "\t\t.  *  .\n";
                        print "\t\t.     .\n";
                        print "\t\t.......\n";
		}
	elsif ($dice[$x] == 2)
		{
			print "\t\t.......\n";
			print "\t\t.     .\n";
			print "\t\t. * * .\n";
                        print "\t\t.     .\n";
                        print "\t\t.......\n";
		}
	elsif ($dice[$x] == 3)
		{
			print "\t\t.......\n";
			print "\t\t.   * .\n";
			print "\t\t.  *  .\n";
                        print "\t\t. *   .\n";
                        print "\t\t.......\n";
		}
	elsif ($dice[$x] == 4)
		{
			print "\t\t.......\n";
			print "\t\t. * * .\n";
			print "\t\t.     .\n";
                        print "\t\t. * * .\n";
                        print "\t\t.......\n";
		}
	elsif ($dice[$x] == 5)
		{
			print "\t\t.......\n";
			print "\t\t. * * .\n";
			print "\t\t.  *  .\n";
                        print "\t\t. * * .\n";
                        print "\t\t.......\n";
		}
	elsif ($dice[$x] == 6)
		{
			print "\t\t.......\n";
			print "\t\t. * * .\n";
			print "\t\t. * * .\n";
                        print "\t\t. * * .\n";
                        print "\t\t.......\n";
		}	

}

sub makepoint
{
	if ($counter == 1)
	{
		if($totalroll == 7)
		{
			print "YOU WON!!!\n";
			$counter = 0;			

		}
	}
	if ($counter == 1)
	{
		if ($totalroll == 11)
			{
				print "YOU WON!!!\n";
				$counter = 0;
			}
	}
	if ($counter > 1)
	{
		if ($totalroll == 7)
		{
			print "YOU LOSE! Craps\n";
				$counter = 0;
		}
		if ($totalroll == 11)
		{
			print "YOU WIN!!!\n";
			$counter = 0;
		}
	}
}

You can see how to actually create an array and us it for math.

C# Create Class with Properties for the temperature conversion Celcius and Fahrenheit

February 26th, 2012

Here is the main program:

/*This is a console application to introduction to classes. Every program requires a heading, which is below. The fields will vary according to the class or organization you are creating this program. For this class we will use temperature conversions.

What is a variable? Think of a variable as a container that holds items.
Program: Introduction to Classes

Programmer: Mike Kniaziewicz
Date: February 26, 2012
Version: 1.0.0 */

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Temperature_Class

{

class Program

{

static void Main(string[] args)

{

/*This is where you declare variables to be used I generally place the first letter of the variable type before the variable for readability in the Main function. Here are the formulas we will be using:
C = (F  32) * 5/9
F = C * 9/5 + 32*/

Console.WriteLine(“Enter a temperature in Fahrenheit to convert to Celcius:”);

Class1  fahrenheit = new Class1();

fahrenheit.Sfahrenheit = Console.ReadLine();

Console.WriteLine(“The Fahrenheit you entered is {0} and the degrees in Celsius are {1:F1}”, fahrenheit.Sfahrenheit, fahrenheit.fahrenheit(fahrenheit.Sfahrenheit));

Console.WriteLine(“Enter a temperature in Celcius to convert to Fahrenheit:”);

Class1 celcius = new Class1();

celcius.Scelcius = Console.ReadLine();

Console.WriteLine(“The Celcius you entered is: {0} and the degrees in Fahrenheit are {1:F1} “, celcius.Scelcius,celcius.celcius(celcius.Scelcius) );

Console.ReadKey();

}

}

}

Here is the Class:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace Temperature_Class

{

class Class1

{

public double dfahrenheit, dcelcius;

public string scelcius, sfahrenheit;

public string Scelcius

{

get

{

return scelcius;

}

set

{

scelcius = value;

}

}

public string Sfahrenheit

{

get

{

return sfahrenheit;

}

set

{

sfahrenheit = value;

}

}

//Constructor

public double fahrenheit(string sfahrenheit)

{

dfahrenheit = double.Parse(sfahrenheit);

dcelcius = (dfahrenheit – 32) * 5 / 9  ;

return dcelcius;

}

public double celcius( string scelcius)

{

dcelcius = double.Parse(scelcius);>

dfahrenheit = dcelcius * 9 / 5 + 32;

return dfahrenheit;

}

}

}

C# Variable Basics Using Temperature Conversion Fahrenheit and Celsius

February 26th, 2012

Here is a brief introduction to variable within C#.  We will be using temperature conversions to demonstrate variable declaration, usage, and formatting. Simply copy and paste the code into any new Microsoft Visual C# console application and you should be good to run this application.

/*This is a console application to introduction to variables.

Every program requires a heading, which is below. The fields

will vary according to the class or organization you are

creating this program. For this class we will use temperature

conversions.

 

What is a variable? Think of a variable as a container that

holds items.

 

Program: Introduction to Variables

Programmer: Mike Kniaziewicz

Date: February 26, 2012

Version: 1.0.0 */

using  System;
using  System.Collections.Generic;
using  System.Linq;
using System.Text;

namespace Introduction_to_Variables //namespace is a system level object

{

class Program

{

//Every C, C++, and C# will have a Main method

static void Main(string[] args)

{

/*This is where you declare variables to be used
I generally place the first letter of the variable type before the variable for readability in the Main function. Here are the formulas we will be using:
C = (F – 32) * 5/9
F = C * 9/5 + 32*/

double dcelcius, dfahrenheit;

string scelcius;

Console.WriteLine(“Enter a temperature to convert to celcius:”);

//always returns a string value,so you will need to parse (convert) it to a double

dfahrenheit =double.Parse(Console.ReadLine());

/* For math always remember Please (Parenthesis) Excuse(Exponents)

My (Multiplication) Dear (Division) Aunt (Addition)  Sallie (Subtraction)*/

dcelcius = (dfahrenheit – 32) * 5 / 9;

//Format the double output, so there are 0 decimal places

Console.WriteLine(“You entered {0:F0} F, celcius is {1:F0}\n”, dfahrenheit, dcelcius);

//Convert Celcius to Fahrenheit; however do not convert the string

//until performing the math

Console.WriteLine(“Enter a temperature to convert to Fahrenheit:”);

scelcius =Console.ReadLine();

dfahrenheit =double.Parse(scelcius) * 9 / 5 + 32;

Console.WriteLine(“You entered {0} C, fahrenheit is {1:F0}\n”, scelcius, dfahrenheit);

//Console.ReadKey will keep the Console application open waiting for a keyboard response

Console.ReadKey();

}

}

}

 

Restart Windows 2008 automatically with a batch (bat) file

January 18th, 2012

This is not difficult to perform and can be used for Windows Servers 2003 and 2008. A reason for performing this type of restart would be to restart the server on the weekend when no one is working. Be warned: Unassisted server restarts can experience undocumented features that may facilitate the necessity to return to work during your time off.

The basic command is: shutdown

The flag for restart is: /r

Now, if you have a “reason” screen you will need to add the reason. If the restart is planned you will use: p if the restart is unplanned you will use: u. To find a listing of the reasons for the restart open a command window and type: shutdown /?.

Here is an example: shutdown /r  /d p:4:1

Now let’s do this step-by-step.

Create the BAT file. Log into the server with Admnistrator rights and privelages. Open Windows explorer and right click on the directory you would like to create the .bat file and create a new text file. I will call this file restart_server.bat.

Notice the file is still type “Text Document?” In order to change that go to: Organize -> Folder and Search Options

Select the View tab and unselect the Hide extensions for known file types. Then press OK.

Rename the restart_server.bat.txt to just restart_server.bat. You will receive a warning message about the dangers of changing file extensions. Just click OK.

Right click on restart_server.bat and select edit.

Add the script shown above to the file and save the file. Be very careful here, because you now have a batch file that will restart the server if it is run.

Now to add the batch file to Task Manager.

Open Task Scheduler and select Create Basic Task…

On the first screen give the task a name and description. You must give it a name. I would recommend giving it a description as well, becuase you might not remember what it was 1 month or 1 year from now. Then click Next.

On the Trigger screen select when you would like the restart to run. I selected weekly for this example. Click Next

Select the day and time you want the task to run. I selected Saturday and 8:30:33 PM. Click Next.

On the Action screen ensure Start a program is selected. Click Next.

On the Start a script section browse to the batch file you just created. Click Next.

The Finish section will provide a summary of the task just created. Click Finish

The task is now schedule to run on Saturday night at 8:30:33 PM. Now comes the task of letting all users know that the server will restart every Saturday night.

To remove the task, click on the Task Scheduler Library. Highlight the task and delete it. Also remember to remove the batch file, because you do not want someone to run it.

Enjoy!

Adding an email group to Google Applications for Education

December 28th, 2011

Here is a brief post on adding an email group to your organization in Google Applications for Education. The reason to add groups is so that multiple recipients can receive the email sent to a single address. This will guard against request not being processed when one person is out on vacation or move on to new life adventures.

  1. Log into your Google Application for Education account as an administrator. The URL is generally
  2. Click “Create a new group”
  3. “Group name” – What you want to call the group.
  4. “Group email address” – This is the email address that email will be sent for everyone in the group to receive.
  5. “Group description” – The description should help other administrators understand why the group was created so he or she can add and remove users in the future.
  6. “Access level” – This is used to determine who will be able to send email, or a Google Apps describes it “post” messages to the group. I want anyone to send in information for the group to process, so I opened the group to the Internet. You can also add the entire organization at this time.
  7. Once you save the new group, you are redirected to add members to the group. This is where you can add organizational members. As you type in the email addresses to add, click the “Add” button to add them to the group.

That is all you have to do. Now you can send email to the group email address you create and each member will receive a copy of the email. You might not be able to send email immediately because the MX records need to update so the email server knows where to route the email.

Enjoy!