Virtualbox and Cygwin

July 18, 2021

Differences between physical, virtual, and cloud setups

So you can do the hands-on labs, I’ll introduce you to the concept of virtual machines. This is just a way of running one operating system within another operating system. So, it doesn’t matter whether you’re running Windows, macOS, or Linux on your host machine. In any case, you can run a Linux virtual machine that you can use for practice, and that you won’t have to worry about if it gets trashed.

Oracle’s VirtualBox, which is what we’ll be using, is great for what we’ll be doing. In an enterprise setting, you’ll find other forms of virtualization software that are better suited for use in data centers. In the past, server hardware could only handle doing one thing at a time, which meant that you had to have one server running DNS, another running  DHCP, and so on. Nowadays, we have servers with gobs of memory, gobs of drive space, and CPUs with as many as 64 cores each. So, it’s now cheaper and more convenient to install multiple virtual machines on each server, with each virtual machine doing its own specific job. This also means that you not only have to worry about security on the physical server that hosts these virtual machines, you also need to worry about the security of each virtual machine. An added problem is that you need to ensure that the virtual machines remain properly isolated from each other, especially ones that contain sensitive data.

And then, there’s the cloud. Many different outfits provide cloud services, where a person or a company can spin up an instance of either Windows or their choice of Linux distro. When setting up a Linux distro on a cloud service, there are things that you’ll have to do right away to enhance security. And realize that when you set up a server on a cloud service, you’ll always have more concerns about proper security, because it will have an interface that connects to the wild and woolly internet. (Your on-premises servers, except for ones that are meant to serve the public, are usually isolated from the internet.)

With our introductory material out of the way, let’s get to the real meat of the matter, starting with an introduction to our virtualization software.

Introducing VirtualBox and Cygwin

Whenever I write or teach, I try very hard not to provide students with a cure for insomnia. Throughout this book, you’ll see a bit of theory whenever it’s necessary, but I mainly like to provide good, practical information. There will also be plenty of step-by-step hands-on labs and an occasional bit of humor.

The best way to do the labs is to use Linux virtual machines. Most of what we’ll do can apply to any Linux distribution, but we will also do some things that are specific to either Red Hat Enterprise Linux (RHEL) or Ubuntu Linux. (RHEL is the most popular for enterprise use, while Ubuntu is the most popular for cloud deployments.)

Since Red Hat is a fee-based product, we’ll substitute CentOS 7 and CentOS 8, which are built from Red Hat source code and are free of charge. (We’re using both CentOS 7 and CentOS 8 because there are some differences between them, and both will be supported for quite some time to come.)

For Ubuntu, we’ll concentrate on version 18.04, since it’s the newest Long Term Support (LTS) version. A new LTS version of Ubuntu comes out in April of every even-numbered year, and non-LTS versions come out in April of every odd-numbered year, and every October. For production use, you’ll mainly want to stick with the LTS versions, because the non-LTS versions can sometimes be a bit problematic.

There are several different virtualization platforms that you can use, but my own preferred choice is VirtualBox.

VirtualBox is available for Windows, Linux, and Mac hosts, and is free of charge for all of them. It has features that you have to pay for on other platforms, such as the ability to create snapshots of virtual machines. 

Some of the labs that we’ll be doing will require you to simulate creating a connection from your host machine to a remote Linux server. If your host machine is either a Linux or a Mac machine, you’ll just be able to open the Terminal and use the built-in Secure Shell (SSH) tools. If your host machine is running Windows, you’ll need to install some sort of Bash shell, which you can do by either installing Cygwin or by using the Bash shell that’s built into Windows 10 Pro.

Installing a virtual machine in VirtualBox

For those of you who’ve never used VirtualBox, here’s a quick guide to get you going:

  • Download and install VirtualBox and the VirtualBox Extension Pack. You can get them from
  • Download the installation .iso files for Ubuntu Server 18.04, CentOS 7, and CentOS 8. You can get them from and (Note that for Ubuntu 18.04, you’ll need to use this alternate installer. The default installer that you get from the main Download page lacks some of the features that you’ll need to complete the exercises.)
  • Start VirtualBox and click the New icon at the top of the screen. Fill out the information where requested. Increase the virtual drive size to 20 GB, but leave everything else as the default settings, as shown in the following screenshot:
  • Start the new virtual machine. Click on the folder icon at the bottom-left corner of the dialog box and navigate to the directory where you stored the .iso files that you downloaded. Choose either the Ubuntu ISO file or the CentOS ISO file, as shown in the following screenshot:
Ubuntu virtualbox
  • Click the Start button on the dialog box to start installing the operating system. Note that, for Ubuntu Server, you won’t be installing a desktop interface. For the CentOS 7 virtual machine, choose either the KDE desktop or the GNOME desktop, as you desire. For CentOS 8, your only desktop choice is GNOME. (We’ll go through at least one exercise that will require a desktop interface for the CentOS machine.)
  • When installing Ubuntu, choose Install Ubuntu Server when you get to the following screen:
ubuntu on virtualbox
  • Repeat the procedure for the other Linux distributions.
  • Update the Ubuntu virtual machine by entering the following commands:
$ sudo apt update
$ sudo apt dist-upgrade
  • Hold off on updating the CentOS virtual machine because we’ll do that in the next exercise.
  • For Ubuntu, choose No automatic updates on the Configuring tasks screen, and choose to install the OpenSSH Server on the Software selection screen.


When installing Ubuntu, you’ll be asked to create a normal user account and password for yourself. It won’t ask you to create a root user password, but will instead automatically add you to the sudo group so that you’ll have admin privileges.

When you get to the user account creation screen of the CentOS installer, be sure to check the Make this user administrator box for your own user account, since it isn’t checked by default. It will offer you the chance to create a password for the root user, but that’s entirely optional—in fact, I never do.

The user account creation screen of the RHEL 8 installer—which looks the same as the one on CentOS 7 and CentOS 8—is shown here:

VMware Debian VM creation screen

For Ubuntu 18.04, you’ll go through several self-explanatory screens to set up your real name, a username, and a password. The Ubuntu installer will automatically add your user account to the sudo group, which will give you full administrator privileges. 

Here’s the user account creation screen for Ubuntu 18.04:

ubuntu virtualbox

So, now, let’s change gears and move on to CentOS 7.

Installing the EPEL repository on the CentOS 7 virtual machine

While the Ubuntu package repositories have pretty much everything that you need for this course, the CentOS package repositories are—shall we say—lacking. To have the packages that you’ll need for the CentOS hands-on labs, you’ll need to install the EPEL repository. (The EPEL project is run by the Fedora team.) When you install third-party repositories on Red Hat and CentOS systems, you’ll also need to install a priorities package and edit the .repo files to set the proper priorities for each repository. This will prevent packages from the third-party repository from overwriting official Red Hat and CentOS packages if they just happen to have the same name. The following steps will help you install the required packages and edit the .repo files:

  • The two packages that you’ll need to install EPEL are in the normal CentOS 7 repositories. Run the following command:
sudo yum install yum-plugin-priorities epel-release
  • When the installation completes, navigate to the /etc/yum.repos.d directory, and open the CentOS-Base.repo file in your favorite text editor. After the last line of the base, updates, and extras sections, add the line priority=1. After the last line of the centosplus section, add the line priority=2. Save the file and close the editor. Each of the sections that you’ve edited should look something like this (except with the appropriate name and priority number):


name=CentOS-$releasever - Base
  • Open the epel.repo file for editing. After the last line of the epel section, add the line priority=10. After the last line of each remaining section, add the line priority=11.
  • Update the system and then create a list of the installed and available packages by running the following commands:
$ sudo yum upgrade
$ sudo yum list > yum_list.txt

Now, let’s move on to CentOS 8.

Installing the EPEL repository on the CentOS 8 virtual machine

To install the EPEL repository on CentOS 8, all you have to do is run the following command:

$ sudo dnf install epel-release

There’s no priorities package as there is on CentOS 7 and earlier, so we won’t have to worry about configuring the repository priorities.

When the package installation is complete, create a list of available software packages with the following commands:

$ sudo dnf upgrade
$ sudo dnf list > dnf_list.txt

Next, let’s configure our network.

Configuring a network for VirtualBox virtual machines

Some of our training scenarios will require you to simulate creating a connection to a remote server. You would do this by using your host machine to connect to a virtual machine. When you first create a virtual machine on VirtualBox, the networking is set to NAT mode. In order to connect to the virtual machine from the host, you’ll need to set the virtual machine’s network adapter to Bridged Adapter mode. Here’s how you can do this:

  • Shut down any virtual machines that you’ve already created.
  • On the VirtualBox Manager screen, open the Settings dialog for a virtual machine.
  • Click the Network menu item, and change the Attached to setting from NAT to Bridged Adapter, as shown in the following screenshot:
virtualbox network
  • Expand the Advanced item, and change the Promiscuous Mode setting to Allow All, as shown in the following screenshot:
virtualbox network
  • Restart the virtual machine and set it to use a static IP address.


If you assign static IP addresses from the high end of your subnet range, it will be easier to prevent conflicts with low-number IP addresses that get handed out from your internet gateway.

Creating a virtual machine snapshot with VirtualBox

One of the beautiful things about working with virtual machines is that you can create a snapshot and roll back to it if you mess something up. With VirtualBox, that’s easy to do, by following these steps:

  • At the top right-hand corner of the VirtualBox Manager screen, click the Snapshots button.
  • Further left on the screen, click on the Take icon to bring up the snapshot dialog box. Either fill in the desired Snapshot Name or accept the default name. Optionally, you can create a description, as shown in the following screenshot:
virtualbox snapshot
  • After you’ve made changes to the virtual machine, you can roll back to the snapshot by shutting down the virtual machine, then highlighting the Snapshot Name, and clicking on the Restore button.

Using Cygwin to connect to your virtual machines

If your host machine is either a Linux or Mac machine, you’ll simply open the host’s Terminal and use the tools that are already there to connect to the virtual machine. But if you’re running a Windows machine, you’ll need some sort of Bash shell and its networking tools. Windows 10 Pro now comes with a Bash shell that’s been provided by the Ubuntu folk, and you can use that if you desire. But if you don’t have Windows 10 Pro, or if you prefer to use something else, you might consider Cygwin.

Cygwin, a project of the Red Hat company, is a free open source Bash shell that’s built for Windows. It’s free of charge and easy to install.

Installing Cygwin on your Windows host

Here’s a quick how-to to get you going with Cygwin:

  • In your host machine’s browser, download the appropriate setup*.exe file for your version of Windows from
  • Double-click on the setup icon to begin the installation. For the most part, just accept the defaults until you get to the Package selection screen. (The one exception will be the screen where you select a download mirror.)
  • At the top of the Package selection screen, select Category from the View menu.
  • Expand the Net category, as shown in the following screenshot:
  • Scroll down until you see the openssh package. Under the New column, click on Skip (this causes a version number to appear in place of the Skip), as shown in the following screenshot:
  • After you have selected the proper package, your screen should look like this:
  • In the bottom right-hand corner, click Next. If a Resolving Dependencies screen pops up, click Next on it as well.
  • Keep the setup file that you downloaded, because you’ll use it later to either install more software packages or to update Cygwin. (When you open Cygwin, any updated packages will show up on the Pending view on the View menu.)
  • Once you open Cygwin from the Windows Start menu, you can resize it as you desire, and use either the Ctrl + + or Ctrl + – key combinations to resize the font.

Next, we’ll look at the Windows 10 Bash shell.

Using Windows 10 Pro Bash shell to interface with Linux virtual machines

If you’re using either Windows 10 Pro or Windows 10 Enterprise, you already have an SSH client built into your operating system.

So, let’s see how to do this:

  • To get to it, you can open the traditional Command Prompt from the Windows System menu, like so:
windows bash
  • Then, just type in the SSH commands the same as you would from a Mac or Linux machine, like this:
windows bash
  • A better option is to use Windows PowerShell instead of the normal Command Prompt. Get to it as you see here:
windows bash
  • As before, let’s use it to log in to my Orange Pi device, as shown here:
windows bash

If you have the choice, go with PowerShell instead of Command Prompt. PowerShell is a bit closer to the Linux Bash shell experience, and you’ll be much happier with it.

Cygwin versus Windows Bash shell

Both Cygwin and the SSH client that’s built into Windows 10 have their pros and cons. In favor of Cygwin, you can install a variety of packages to customize it pretty much any way you want. Also, if you’re stuck using Windows 10 Home Edition or—heaven forbid—Windows 7, you can use Cygwin.

In favor of the Windows 10 built-in SSH client, there’s the fact that on the Pro and Enterprise editions of Windows 10, it’s already there. Also, it’s much easier to use if you need to access your normal Windows folders because Cygwin traps you in its own sandboxed directory structure.

Related Articles

How to add swap space on Ubuntu 21.04 Operating System

How to add swap space on Ubuntu 21.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...

read more

Lorem ipsum dolor sit amet consectetur


Submit a Comment

Your email address will not be published. Required fields are marked *

one × 4 =