How to Set Up A Virtual Machine for Windows To Learn C — Ubuntu Environment

With Lots of pictures 😀

Jehdi Aizon
7 min readAug 2, 2020

When first learning C, it’s recommended to work in a virtual machine. That way, you don’t risk deleting or corrupting your files on your actual computer. A virtual machine (VM) lets you operate other operating systems. Operating systems are system software that manages your computer. Some examples are Windows, macOS, Ubuntu.

The operating system we’ll use is Ubuntu.

Getting What You Need

To set up a basic Virtual Machine, you need 3 things:

  1. Have enough memory (at least 10 GB or more)
  2. Download Ubuntu Desktop (the iso file)
  3. Download Oracle Virtual Machine (runs Ubuntu)

1: Have enough memory

Make sure you have at least 10 GB. I recommend 20 GB to get a faster Virtual Machine. But if you’re greedy with memory like me, stick with the 10 GB and increase it by 2 GB whenever your OS warns you that you don’t have enough memory.

2: Download Ubuntu Desktop

Now you need to download the operating system (OS). We download it as a Disc Image File (.iso). This is a whopping 2.5 GB download, so download it while you’re doing some other work.

Head over to Ubuntu, click Download and click the green button under the “Ubuntu Desktop” category.

After clicking the green button, it should lead you to a “Thank you for downloading” page.

3: Download Oracle Virtual Machine

Alright, so while the Ubuntu OS is downloading. We need to download and install 2 things:

  1. The VirtualBox program and,
  2. The Extension Pack.
    This lets you use USB 2.0 and 3.0 devices within your VM.

Head over to Oracle VirtualBox’s download page, and under the heading, ‘VirtualBox x.xx.x platform packages,’ select ‘Windows hosts’ to download the .exe file. The file size is around 100 MB.

After you finish downloading the VM manager, install the Extension pack and go through the installation steps.

Setting it All Up

So now that you have everything you need, we need to set up our Virtual Machine (VM).

Step 1. Adding a new Virtual Machine

Open Oracle VirtualBox. Click New. Another window will pop up.

Step 2. Name and operating system

Name: I put Ubuntu here but I’ll name it Ubuntu 2 instead.
Machine folder: leave this one alone (unless you want to)
Type: Linux
Version: Ubuntu 64 or 32

To know which version of Ubuntu you should use, go to Start > Search ‘About your PC’ and under ‘System Type’, it should say 32 or 64-bit operating system.

Mine is a 64-bit operating system.

Step 3. Memory size

So a lot of people (including me) get memory size confused with disk space. The 2 most common types of disk space are Hard Drives and SSDs (faster file handling because it has no moving parts).

Disk space is where your files and programs are stored whereas memory (RAM) basically handles all your open programs. Like when all your chrome tabs are open, file explorer, or Stardew Valley.

The more memory (RAM) you have the less ‘Program not responding’ and less lag you’ll encounter.

Okay, so what VirtualBox is asking here is,

“How much memory can I use when I’m running the VM?”

This depends on what you do and how much you’ll use the VM. To give you some choices it’s either: 4 GB, 8 GB, 16 GB, or 32 GB. If it’s just for learning C then I’d go with 4 GB or 8 GB.

Don’t use the arrows and instead use the slider only!

I gave mine around 4 GB since I’m only using it to learn C.

1 GB = 1,000MB
easy way to remember, add 3 zeros.
So 4GB = 4,000 MB.

Step 4. Hard disk

This is the part where you give away a chunk of memory. Again, I recommend 10 GB or more. The more memory you give it, the faster it performs.

BUT before we go chucking memory at it, make sure you have space. Go to your file explorer > ‘This PC’ and check if you have enough space to give VM your desired amount of memory.

For the next part, it’s a bit confusing so just stick with Dynamically allocated. If you’re curious you can check the VirtualBox manual to learn more.

Also, yes, it’s ok to give it less memory! My current VM started out with around 4 GB (I’m greedy with my memory like that 🙄) and I increased it by 12 GB.

Running Your Virtual Machine

We are almost done! Now, follow the steps in the image below and find the .iso file you downloaded. Don’t delete the iso afterwards. Keep it in case you plan on creating another VM.

Find your iso file and press ok when finished.
Let’s start this baby!
Use your arrow keys and enter key to make you selections
Wait for a little bit and the install window should appear. Go through the installation process.
Ubuntu installing in your VM. Just wait until it finishes and restart it. 😥 There will be a black screen with a prompt that says to press ENTER, press ENTER.

Setting Up Workspace to Learn C

Congrats! You are officially running a Virtual Machine! Now it’s time to set your Ubuntu to work well for you during your learning of C.

Add Terminal to Shortcut

CTRL + ALT + T opens your terminal window. This is where all the magic happens.

Right-click on the terminal icon for the window to show up and add to favourites.

Install Code Editor (Emacs)

You can install other code editors but I’ll be installing emacs (open source) in this tutorial.

There are 2 ways to download it: using the app store or the terminal window.

Install using the App Store

Using the app store

Install using the Terminal window

Type sudo apt-get install emacs and press ENTER.
Type your password (you won’t be able to see it while you type) and press ENTER.

When it prompts you, type Y and press ENTER. Wait for it to finish installing.

Right-click on the Emacs (GUI) icon for the window to show up and add to favourites.

Tweaking (Optional)

There are few settings we can play with to give us a better experience

Scaled Resizing

When you try and resize the window or go full screen the screen doesn’t change resolution. We can fix this.

Left, resizing. Right, full screen. 😞

This is what we want.

The window can be resized to any size and its resolution will scale with it.
Reset after it’s installed.

Keeping the screen resolution every time you launch VM

Whenever you open a VM it’s always stuck in this resolution. Let’s fix it.

Now whenever you open this VM, it will always open to the resolution you chose.

Happy Coding!

References

Official VirtualBox Getting Started Tutorial

Well, that’s it from me for now. Talk to you soon! 👋👋👋

--

--