Friday 9 July 2010

Creating Your First Virtual Machine: Ubuntu Linux (Part 2)

Running your Ubuntu Linux VM

This is going to be the most entertaining section of the article: you'll get to play with your brand-new Ubuntu Linux virtual machine! If you haven't used Linux before, I'd definitely recommend that you browse through the Ubuntu documentation at https://help.ubuntu.com/9.10/index.html.

Time for action – running Ubuntu Linux

The best way to test your new virtual machine is experimenting, so let's get on with it!
  1. Open VirtualBox (in case you closed it after the last section's exercise), select your UbuntuVB virtual machine, and click on Start to turn it on:
    VirtualBox 3.1: Beginner's Guide
  2. Ubuntu will start to boot in your virtual machine. Eventually, the Ubuntu logo will show up along with the progress bar and, after a few seconds (or minutes, depending on your hardware), the Ubuntu login screen will show up. Click inside the virtual machine screen to capture the mouse and keyboard, type the username you assigned in the installation process, and hit Enter to continue.
  3. Now type the password for your username, and hit Enter again. Ubuntu will start to load. When finished, you'll see the Ubuntu GNOME Desktop screen:
    VirtualBox 3.1: Beginner's Guide
  4. One of the first things you'll notice is the Update Manager dialog. This dialog shows up when your Ubuntu system needs software updates. Click on Install Updates to start the updating process. Normally, the Update Manager will ask for your administrator password. Type it, press Enter, or click on OK and then wait for the Update Manager to finish its job so you can work with your Ubuntu system fully updated.
  5. If the Update Manager asks you to restart your Ubuntu system after updating, click on the Restart Now button, and wait for your Ubuntu virtual machine to reboot.

What just happened?

Isn't it cool to have a little Ubuntu system running inside your real PC? Just like a pregnant mother feeling her baby's first movements! Well, not as touching, but you get the point, right?
Ubuntu is one of the friendliest Linux distributions available. That's why I decided to use it for this article's exercises. Now let's go and test the Internet connection on your new Ubuntu virtual machine!

Web browsing with Mozilla Firefox

One of the best things about the Ubuntu Desktop edition is that you can use Mozilla Firefox out of the box. And the Ubuntu Update Manager keeps it updated automatically for you!

Time for action – web browsing in your Ubuntu VM

You have your virtual machine installed. What's next? Let's surf the web! After all, what could be more important than that?
  1. Open the Applications menu on your Ubuntu virtual machine, and select Internet | Firefox Web Browser from the menu:
    VirtualBox 3.1: Beginner's Guide
  2. The Mozilla Firefox window will show the Ubuntu Start Page. Type virtualbox.org on the address bar and press Enter:
    VirtualBox 3.1: Beginner's Guide
  3. The VirtualBox homepage should appear as an indication that you have Internet access in your virtual machine. You can close Mozilla Firefox now.
If you cannot connect to Internet from your virtual machine, check your host's network settings. If you can connect from your host, try using another virtual network adapter type in your virtual machine to see if the problem disappears.

What just happened?

Well, this exercise is not really hard, right? But this is a cool way to test if your new virtual machine has Internet enabled by default. Later on, we'll talk about the different settings related to virtual network interfaces and VirtualBox. You can also know if your virtual machine can connect to Internet through the Ubuntu Update Manager because it will issue a warning if it cannot access the Ubuntu software sources. For now, it's good to know we can surf the web! Now let's see how you can do some real work inside your Ubuntu VM…

Using OpenOffice.org in your virtual machine

Ok, we have Internet enabled on our Ubuntu virtual machine; what else could we ask for? How about some word processing, a spreadsheet, and some presentations, for starters? I know it's boring, but some of us also use VirtualBox to work!

Time for action – using OpenOffice.org

Ubuntu comes with OpenOffice.org, the open source productivity suite that has proven to be an effective alternative to MS Office for Linux users. Now let's try it out on your new Ubuntu virtual machine...
  1. Open the Applications menu on your Ubuntu virtual machine, and select Office | OpenOffice.org Word Processor from the menu:
    VirtualBox 3.1: Beginner's Guide
  2. The Untitled 1 – OpenOffice.org Writer window will appear. You can use OpenOffice Writer as if you were on a real machine:
    VirtualBox 3.1: Beginner's Guide
  3. Now go to the Applications menu again, and this time select the Office | OpenOffice.org Spreadsheet option.
  4. The Untitiled 2 – OpenOffice.org Calc window will show up, overlapping the Writer window. You can also work with it as in a real PC:
    VirtualBox 3.1: Beginner's Guide
  5. And now, go back to the Application menu, and select the Office | OpenOffice.org Presentation option.
  6. The Presentation Wizard screen will show up. Select the Empty Presentation option, click on Next twice, and then click on Create to continue. The Untitled 3 – OpenOffice.org Impress window will show up, overlapping the other two windows:
    VirtualBox 3.1: Beginner's Guide
  7. Now you can close all the application windows inside your virtual machine.

What just happened?

How about that? A complete office productivity suite inside your main PC! And Internet access too! So, if you always wanted to learn about Linux or any other operating system but were afraid of messing up your main PC, VirtualBox has come to your rescue!
Now let's see how to turn off your virtual machine…

Have a go hero – trying out Ubuntu One: your personal cloud

Now that you have an Ubuntu virtual machine, you would likely benefit from trying out the Ubuntu One service, where you can back up, store, sync, and share your data with other Ubuntu One users. And the best of all, it's free! To open an account, select Applications | Internet | Ubuntu One, and follow the instructions on screen.

Have a go hero – sharing information between your VM and your host PC

Use your Ubuntu One account to transfer some files between your virtual machine and your host PC. If you're using Windows, you can work with the Ubuntu One web interface at http://one.ubuntu.com.

Shutting down your virtual machine

I know you're thinking, "Geez, I can't believe this guy! He's actually going to spend an entire subsection of this article just to show us how to shutdown a virtual machine! Aw, come on!"
Now it's my turn: Remember we're talking about a virtual machine here, not a real PC! You need to consider several things before shutting this baby down!

Time for action – shutting down your VM

Now it's time to stop whining and start learning how to shut down your virtual machine...
  1. Make sure you close all the applications inside your virtual machine, open the Mozilla Firefox Web browser, 'uncapture' your keyboard and mouse so that you can move to the VirtualBox main menu, and select the Machine | Close option.
  2. The Close Virtual Machine dialog will show up with three choices for shutting down your virtual machine. Select the Save the machine state option, and click on OK to continue:
    VirtualBox 3.1: Beginner's Guide
  3. VirtualBox will show the following dialog before shutting down the virtual machine:
    VirtualBox 3.1: Beginner's Guide
  4. Once your virtual machine's state is saved, it will shut down automatically, and you'll be returned to the VirtualBox main screen. Also, your UbuntuVB virtual machine status indicator will change from Powered Off to Saved. If you start it again, it will continue exactly where it was left off, with the Mozilla Firefox web browser window open.
  5. Start your UbuntuVB virtual machine again, leave the Mozilla Firefox window open, and select the Machine | Close menu option from the VirtualBox main menu again to open the Close Virtual Machine dialog.
  6. This time select the Send the shutdown signal option, and click on OK to continue. This has the same effect as if you had pressed the power off button on a real PC. The Shutdown the computer dialog from Ubuntu will show up:
    VirtualBox 3.1: Beginner's Guide
  7. Click on the Shut Down button to continue. Your Ubuntu virtual machine will shutdown without saving its state. This is the same as using the regular shutdown process in Ubuntu: you select the Shut Down… option from the pull-down menu in the upper right corner of your Ubuntu virtual machine. If you later start it again, the Mozilla Firefox window won't open.

What just happened?

Well, it was pretty much just a simple 'shutdown your virtual machine' exercise, don't you agree? In VirtualBox, you have three choices when shutting down your virtual machines. We already saw the first choice –Save the machine state –in action. It's kind of like suspending or hibernating a laptop computer. Your virtual machine's state 'freezes' and stays that way until you later start it again. Then, it resumes normal operation as if nothing happened. All the applications you left open will still be there.
The second choice, Send the shutdown signal, acts as if you pushed the power button on a real machine. Most modern operating systems will try to use a proper shutdown mechanism.
The third choice, Power off the machine, is like pulling the power plug on a real PC, so be careful! You could lose sensitive data if you use it carelessly! I only use this option when a virtual machine crashes and I can't shut it down with the other two choices...
Always try to use the guest operating system interface first to shutdown the virtual machine. If that fails, you can use the Send the shutdown signal option instead, but it's better to treat your virtual machine as if it were a real PC, don't forget it.
Remember that the Send the shutdown signal option only works if your guest operating system supports ACPI events. For example, this option is useless when your virtual machine is showing up the Ubuntu GRUB loader boot screen.

Have a go hero – experimenting with a KUbuntu virtual machine

There's another Ubuntu-derived distribution around called KUbuntu. Why the K? Well, the primary difference between Ubuntu and KUbuntu is that Ubuntu uses the GNOME window manager (http://www.gnome.org), and KUbuntu uses the KDE window manager (http://www.kde.org/). And which one is better? Well, that's what you need to try out for yourself...
Go and grab a copy of KUbuntu from http://www.kubuntu.org, create a virtual machine named KUbuntuVB or something like that, and install KUbuntu on it. If possible, try to run your Ubuntu and KUbuntu virtual machines at the same time to compare them, so you can decide which one is better!
And if you're feeling reckless, you should definitely try out other Linux distributions, for example: SuSE, Red Hat, Slackware, or Fedora. Come on, I know you can do it!

Summary

I hope you enjoyed the exercises in this article, especially if you've never used Ubuntu Linux before (or any other Linux distro whatsoever). Here you learned about the basic settings needed to create a virtual machine, installed the Ubuntu operating system, ran the virtual machine, and shut it down appropriately.
Specifically, we covered:
  • How to download the Ubuntu Linux Desktop Live CD
  • How to configure a new virtual machine in VirtualBox
  • How to adjust your virtual machine's basic settings to install Ubuntu on it
  • How to install the Ubuntu Linux Desktop operating system on your VM
  • How to use the VirtualBox host key and to 'capture'/'uncapture' the mouse and keyboard in your virtual machine
  • How to run your Ubuntu virtual machine and test some basic functions such as Internet access and OpenOffice.org applications
  • The different choices available when shutting down your virtual machine