Posted 10-3-2010 by
Matthew Downey
Adding a user to the sudoers file on Red Hat or CentOS is a fairly simple process. All we need to do is edit the /etc/sudoers file as root, and add a line.
First, open up a terminal and switch to the root user by typing the following:
Enter the root user's password, and then load the /etc/sudoers file in vi using the visudo command:
Scroll down until you find the following section:
## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
Push 'i' to enter insert mode, and uncomment the second line so it looks like this:
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
Uncommenting this line gives everyone in the group "wheel" the ability to run all commands. Exit insert mode by pressing escape, and then save the file and exit the editor by typing ':wq' without quotes.
Now we need to add our user to the "wheel" group:
usermod -G wheel username
Substitute your username where it says username, of coarse. Type "exit" to exit the root shell. You should now be able to execute all commands as root by prefixing them with sudo. You may notice that certain commands such as ifconfig don't work with sudo as expected, and this is because /sbin is not in the user's path. The solution to this problem is covered in this post.
Posted 10-2-2010 by
Matthew Downey
Virtualbox allows you to share files between the guest and host operating systems. For the purposes of this tutorial, the host OS is Windows 7 and the guest OS is CentOS 5.5, although we could use any flavor of Linux.
To start with, create a folder on the host operating system. You can exist anywhere you like. For ease of access, we'll just place ours on the desktop. To do this, right-click on the Windows desktop and select “New > Folder.” Give this folder the name “share.”

Next, run Virtualbox and start the guest operating system. From Virtualbox's menu, select “Devices > Shared Folders.”

This will open up a dialog box with the title “Shared Folders.”

On the top right of the dialog, click on the folder icon with the green plus sign. This will open up a file browser.

Browse to the share folder that was created on the host desktop and make sure to check the box labeled “Make Permanent.” If this box is unchecked, it will create a transient share folder that will disappear the next time the guest OS is started. Click OK. The share should now appear in the list under the heading labeled “Machine Folders.”

After clicking OK, the configuration is complete on the host operating system. Now we need to configure the guest OS. Login to the guest machine, and open up a terminal. We need to create a directory for the shared folder to reside. This can be anywhere on the filesystem, but for our purposes, we will be creating the directory /share. Since we will be creating this directory in the root folder, we need be root. Either change to the root user using su -, or prefix the command with sudo. We will be using sudo. Issue the following command:
Now we must mount the host's share folder to the /share directory we just created on the guest operating system. We could do this with the mount command, however that would require us to mount the folder every time we start the guest OS. Since we want this share to be permanent, it needs to be mounted on startup. To do this, we must add a line to the /etc/fstab file. We must be root to edit this file, so issue the following command:
This will open up the /etc/fstab in vi. Scroll down to the bottom of the file, and push o to switch to edit mode and insert the following line at the end of the file:
share /share vboxsf defaults 0 0
The first column is the name of the share we are mounting, given to us from the name column of the shared folders dialog. The second column is the mountpoint, the name of the directory we created on the guest that we will be mounting the folder to. The third column is the filesystem type, and the remaining columns are various options, of which we will use the default setting. After adding the line, save and edit the editor using :wq.
At this point, everything is setup, and all that is required is a reboot of the guest OS for the system to reload the /etc/fstab file. But before we do so, it would be nice to have a shortcut to our share on our linux desktop. To do this, we need to create a symbolic link, and store it in the ~/Desktop directory. Make sure you are logged in as your normal user, and type the following into the terminal:
ln -s /share ~/Desktop/share
A link to the /share folder should now appear on your desktop.

Now, reboot the guest OS and test the shared folder by placing some files into it. If everything went well, the files should show up in the folder on both the host and guest operating systems.
Posted 10-2-2010 by
Matthew Downey
In this post we will install CentOS 5.5 as a guest operating system in Virtualbox. In order to do this, we need to have some kind of installation media handy. Virtualbox will allow us to install via DVD or, more conveniently, an ISO located on the host operating system's hard disk.
If you don't have a CentOS DVD or ISO handy, you're going to need to download one; in order to download it, you're going to need a bittorrent client, a good one for Windows is uTorrent. Hop on over to the CentOS mirrors page and grab a copy of the DVD torrent for your computer's architecture. If your computer is 64 bit, choose x86_64, otherwise if it is 32 bit or you are unsure, get the i386 version. After selecting an architecure, choose a mirror from the list to be taken to a download page. The file that you are interested in is either CentOS-5.5-i386-bin-DVD.torrent or CentOS-5.5-x86_64-bin-DVD.torrent, depending on your architecture. The torrent will download two DVDs, but we really only need the first one.
After downloading a copy of the media to your hard disk, it's time to get started. Go ahead and fire up Virtualbox. You should be presented with a screen that looks something like this:

Click the button labeled "New" in the upper lefthand corner to create a new virtual machine. This will start a wizard to take you through the process of creating a new machine. After clicking "Next," the Wizard will ask you for the VM Name and OS Type, like so:

Give your machine a name. If you give it the name CentOS, it will automatically change the operating system to Linux and version to Red Hat. Red Hat is the correct version, because CentOS is a clone of Red Hat. It is important that if you downloaded a 64 bit image to change the version to "Red Hat (64 bit)."
After clicking next, the wizard takes us to a screen where we can select the amount of memory that the guest operating system will have available to it:

Virtualbox recommends 512 megabytes and that is a good number to go with, since setting up a virtual lab is going to require us to run multiple guest OS at once, and each one is going to need it's own block of RAM. You can always change the amount of RAM the guest has available to it later in the virtual machine's settings.
Click next and move on to the virtual hard disk setup:

Here, we basically have the option of creating a new hard disk, using an existing disk, or attaching disks later. We're going to go with the first option and create a new disk, so go ahead and click next.
This will open up another wizard, where we create the disk for the machine. Go ahead and click next again, which should bring you to a window that looks like this:

This screen gives us the option to choose whether we want to use dynamically expanding or fixed-size storage. Since the guest operating system will live in a .vdi file on your hard disk, it's nice to just have the file increase in size as the guest operating system grows. Dynamic disks save space on the host and make backups easier because you end up with a smaller file. Click next and move on to the next screen, where we will define the size of the virtual disk.

When we first get to this screen, Virtualbox gives us a recommended default size of 8GB. That's fine if you don't want to use a custom partition layout or install all the packages, but for the purposes of this tutorial, we'll be using a 15GB disk, since it will allow us to install all of the packages if we choose to do so, and also give us enough room to play around with. Change the size of the disk to where you want it, and click next.
Both wizards are at the end now, and are going to display a summary. Go ahead and click finish for both of them, and there should be a new virtual machine in your list:

Now that that's taken care of, click the green start arrow to fire up the virtual machine. At various points while running the machine, Virtualbox will pop up with some windows with various information about keyboard and mouse capture:


These dialogs are confusing at first, but they are basically telling you that once you use your mouse or keyboard inside the guest OS, in order to make them available to the host you have to press the host key, which is defined as the right control key. The left control key functions as normal in the guest, but pushing the right one will release the mouse and keyboard back to the host operating system.
The first time you run the machine, it will bring up the first run wizard. Go ahead and click next to get started.

Click the folder with the green arrow to select the ISO file we downloaded to install from. This will take us to the Virtual Media Manager, which should be empty. Click the "Add" button and browse to the folder where you downloaded the CentOS DVD ISO and select it. The Virtual Media Manager should now look something like this:

Highlight the ISO you want to install from and click select. The ISO should now be available in the wizard's drop down box:

Make sure it's selected and click next. Next a summary screen will be displayed. Click "Finish." This will boot into the CentOS installer.

The rest of the tutorial will focus on the actual CentOS install process. Hit enter to begin.

This screen will perform an optional check on our installation media. Since we are installing our system from an ISO we downloaded and not a scratched DVD, we'll skip this step. Push tab to highlight the "Skip" option and select it with the spacebar. This will load the graphical installer. Click "Next," which will take us to a screen where you can select the language you want to use for installation. Click "Next," and select your appropriate keyboard, which is most likely "U.S. English" if you are in the United States. Click "Next," and you should be presented with the following dialog:

This screen is informing us that we are going to erase all of the data on our virtual hard disk. This is okay, it will not delete all of the files on your host operating system. Go ahead and click "Yes."

At this screen, the installer is going to ask us how we want to partition the disk. You could use the default layout, but we will be creating a custom layout, which is the more advanced option. Select "Create custom layout" from the dropdown box and click "Next" to define the partitions.

From here, click "New" to get started adding the first partition.

Select "/" for the first mountpoint from the dropdown box, and give it a size of 1 GB (technically 1GB is equal to 1024MB, but we will just use multiples of 1000 for simplicity's sake). Click "OK." You should now see the new partition in the editor, which should now look something like this:

Go ahead and click "New" again to create another partition. This time, we are going to create the swap partition:

Typically, it is a good idea to set the swap size to twice the size of your RAM. Since we setup our virtual machine with 512MB of RAM, we want a swap size of 1024MB. Set the filesystem type to swap and enter the proper number of megabytes, then click "OK." Continue adding partitions just like before, with a layout as follows:
| Mount Point |
Size |
| / |
1 GB |
| swap |
1 GB |
| /usr |
8 GB |
/usr/local |
1 GB |
/home |
1 GB |
| /opt |
1 GB |
| /tmp |
1 GB |
| /var |
1 GB |
| /boot |
100 MB |
After setting up your partitions, you should notice that there is a little bit of free space left at the end of the drive.

Let's take care of that free space, by adding it to the /home partition. Highlight the /home partition in the list, and click "Edit."

We want to leave everything the way we had it, only selecting "Fill to maximum allowable size" from the section labeled "Additional Size Options." This will add the rest of the free space to the partition.

Finally, our partitions are set up, so click "Next." This will take us to the boot loader configuration, and we can just accept the default option and use GRUB, so click "Next." Next is the network configuration, and we want to accept the default here and use DCHP. Click "Next" again. You should now be at a map where you can select your timezone:

Select your timezone, either from the dropdown menu or by clicking one of the locations on the map. Then click "Next" where you will be asked to setup the root password:

The root user is the administrative user for the system that can change anything, so it is a good idea to set a strong password. Enter your password twice, then click "Next."

Now it's time to select the packages we want to install on the system. I just checked the "Server" and "Server GUI" packages in addition the default GNOME package. If you think there is something else you want, feel free to add it, otherwise, don't worry, you can always add more packages later. If you choose the "Customize now" option, you will be taken to a page where you can do a more detailed package selection. For the sake of speeding things along, we are just going to leave the default, "Customize later."
After selecting packages, click "Next." This will take us to a page that will tell us installation is about to begin, so go ahead and click "Next" to get things going.

The installation process takes a bit of time, so now would be a good time to go do something else. After it is finished, the installer will tell you installation is complete, but that's not true. Click "Reboot," and after the system reboots, you will be taken to a configuration phase of the install process. Click "Next" through the "Welcome," "Firewall," "SELinux," "KDump," and "Date and Time" screens, accepting the defaults for each. Now you should be at the screen where you create your regular user that you will be logging in with to do most day to day tasks. It is good to have a user besides the root user to do most work on a system, to prevent accidentally misconfiguration. Go ahead and enter your credentials:

After creating a user, you will be taken to a screen to configure the sound card. It should work, but feel free to test it. After testing, click "Next" and you will be taken to a screen asking for additional CDs. We don't have any additional CDs, so just click "Finish" to complete the installation.

At long last, our system is now ready to use! Login with the user you created, and enjoy the benefits of using Linux as a virtual machine!
Posted 10-1-2010 by
Matthew Downey
The installation of Virtualbox is fairly straightforward. Oracle has done their best to make the installation process as painless as possible.
First, point your browser to http://download.virtualbox.org/virtualbox/vboxdownload.html and grab the latest version. Navigate to where you downloaded the executable package, and run it.

Click Next, and read and accept the license agreement.

This will bring you to a dialog which will list custom install options. For our purposes, it is best to use the default options, so just click Next.

After clicking Next, you will be asked whether or not you would like to create a desktop shortcut and a quick launch icon. Select your preference, and click Next to move on. This will bring up a dialog warning you that installation will reset your network interface. It is just letting you know that during the installation process, you will lose internet connectivity for a few seconds. Click Yes to proceed.

After clicking Yes at this dialog, we are finally ready to begin the actual installation. Click Install, and get on with it already!
This will proceed with a very typical install process, with your standard progress bar.

During the middle of the installation, "Windows Security" dialogs will pop up asking you if you want to install various drivers. These are necessary for your guest virtual machines to have access to things like USB and network interfaces. Be sure to click Install for all of these.

After a few of these security dialogs, installation is finally complete, and we can now proceed to the more exciting process of guest operating system installation!
