Archive for the ‘Linux’ Category

KVM and Ubuntu 11 i686 and iptables

Sunday, 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
(more…)

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

Monday, 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

Thursday, 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

Wednesday, 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?

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

Sunday, 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.

Installing VNCserver on CentOS 5.7 and Ubuntu 11 for remote desktop in Windows

Monday, December 26th, 2011

I run an Apache web server from my home. It is basically used to create test and development websites for my domains. The problem I was experiencing was how to allow my son and others work within a desktop in CentOS similar to Windows.

I decided a good method would be VNC. The first step is to set up the vncserver to deliver a desktop to remote sessions. I like the concept of connecting via HTTP, because we all have web browser.

You can enable HTTP access to a remote desktop on the web server with VNCserver. You can also create separate accounts for each user to view his or her own desktop. Security can also be maintained through the granting of rights and privileges for the session. Here are the steps I took to allow my son to work on his website through a web-based, VNC session on his Windows 7 laptop.

 

So if this is what you are looking to do with Windows 7 and Internet Explorer to access a Linux desktop, then read on to see how it is done.

CentOS 5.7 : Install vncserver via yum

Ubuntu 11: Install X11VNC Server via sudo apt-get intall x11vnc.

CentOS 5.7 set-up after installing vncserver.

  1. Add user to server.
    sudo /usr/sbin/useradd thefrugaltech
    sudo passwd mikey (to assign a password to the account)
  2. Install vnc-server
    sudo yum install vnc-server
  3. Provide VNC user with password
    sudo su – thefrugaltech
    Run:vncpasswd
    Password: New Password
    Verify: Type New Password again
    Logout as user by typing “exit”
  4. Vi /etc/sysconfig/vncservers
    Edit: VNCSERVERS=”2:myusername” to read VNCSERVERS=”2:thefrugaltech”
    Edit: VNCSERVERARGS[2]=”-geometry 800×600 -nolisten tcp -nohttpd – localhost” to read VNCSERVERS=”-geometry 1024×768″
  5. Start vncserver
    su – root (provide root password)
    /sbin/service vncserver start (if it does not start due to permissions issues ensure you are using an account with sudo rights)
  6. Change the xstartup options for the user account created in step 3
    su - root
    vi  ~thefrugaltech/.vnc/xstartup
    Uncomment: “unset SESSION_MANAGER” and “exec /etc/X11/xinit/xinitrc”
  7. Open Internet Explorer on your Windows. Goto “http:<ip of vncserver>:5802″ click “OK” for the session and enter the password for the user, then press OK.

Ubuntu 11 set-up after installing x11vnc

  1. Run: vncpasswd (This will set the current users password).
  2. You can log out of the session or simply restart the server.
  3. If you are viewing from a Windows server or PC install RealVNC viewer. Open the viewer and type in the Ubuntu 11 server’s IP address.
  4. You should see the desktop.

Not working?

  • Ensure Java is installed on the PC.
  • If you are not getting a GNOME desktop, check the default settings for new users. What I found to be expedient is to log the user into a desktop session.