How to install Ubuntu on a Virtual Machine
Author: Nabeel Ahmed
Please scroll down to the operating system you use. (Windows or Mac).
Windows πΎ
It is much easier to set up a CLI (Command-Line Interface) environment for Windows as Microsoft has already implemented a Ubuntu subsystem virtual machine that is built onto Windows. Follow the steps below to install the subsystem:
- Open the following link: https://www.microsoft.com/en-us/p/ubuntu/9nblggh4msv6.
- Click on the
Get
button and it should redirect you to the Microsoft Store app on your machine. - Install and wait for it to finish.
- Once finished, type
Ubuntu
into the Start search box, and the app should pop up- click on it. - Once a Terminal is opened it should automatically begin the installation processes.
- If you are prompted with the following message:
The Windows Subsystem for Linux optional component is not enabled. Please enable it and try again
. Complete the following steps to fix this else move to step 7:- Open Powershell as Administrator (right-click Powershell in Start and select
Run as administrator
). - Paste the following command into it:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
. - After the previous command is done running, paste the following:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
. - Finally, paste the following:
wsl --set-default-version 2
.- If you run into the error of
wsl is not recognized
, paste the following command instead:Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
- If you run into the error of
- Once complete close Powershell and the Ubuntu Subsystem App and reopen the Ubuntu Subsystem App.
- Open Powershell as Administrator (right-click Powershell in Start and select
- You will now be asked to fill in some details such as a
UNIX username
(pick anything you will remember your first name all lowercase should be enough) and aUNIX password
(pick something you will remember because you will be using it a lot). - You are done! π
macOS π
It is a little bit harder to install a Linux virtual machine on macOS as you have to create the Virtual Environment yourself. Follow the steps below to install the Virtual Machine:
- Head over to the following URL and download VirtualBox, a free hypervisor that allows you to create virtualized environments on your machine. Make sure to click
OS X hosts
to start the download: https://www.virtualbox.org/wiki/Downloads. - As VirtualBox is downloading, install the Ubuntu Minimal disk alongside it, which will give us the CLI (Command-Line Interface) version of Ubuntu. Link for the download. Scroll down until you see your computer's architecture (64bit or 32bit) and click the latest version of Ubuntu within the list. The latest version should be number 1: https://help.ubuntu.com/community/Installation/MinimalCD.
- Once VirtualBox has finished downloading, open the VirtualBox
.dmg
file. Double click on the.pkg
icon in the VirtualBox drive folder to open the installation wizard. Once you complete the installation steps, close the drive window, and eject the drive. - Open System Preferences on Mac. Can be located by the following steps: Apple Logo (Absolute top-left of the screen) > System Preferences.
- Open
Security & Privacy
and switch the tab toGeneral
. - Unlock the Lock that is located on the bottom left of the window. You will be prompted to enter your password.
- Click
Allow
beside the blocked software warning (This is a security warning because VirtualBox enables virtualization onto your computer). - Finally, open the VirtualBox app. This can be located by simply typing
VirtualBox
into the Spotlight Search (which can be open by pressingcmd + space
). - After opening VirtualBox, you should be prompted to a window that has an image of a Penguin with building tools.
- Click the
New
button and complete the following steps:- On the window presented to you, type
CS Ubuntu Machine
into the name field- or whatever you'd like as long as you can remember the particular virtual machine. - For the
Machine Folder
, it should default to/Users/[your_username]/VirtualBox VMs
, which is fine. If it doesn't default to that, make a folder calledVirtualBox VMs
in theHome
directory and select that in VirtualBox. - For the
Type
field select:Linux
. - For the
Version
field select:Ubuntu (64-bit)
orUbuntu (32-bit)
depending on your computer's architecture (64bit or 32bit). Once done, clickContinue
. - For
Memory Size
drag the slider until it says2048 MB
or type2048
into the input box on the right. (2GB is a healthy amount of RAM for Ubuntu Minimal). Once done, clickContinue
. - For
Hard Drive
clickCreate a virtual disk now
. Once done, clickCreate
. - For
Hard disk file type
clickVDI (VirtualBox Disk Image)
. Once done, clickContinue
. - Select
Dynamically allocated
. Once done, clickContinue
. -
Do not edit the text input that has the location to the .vdi file. The allocated drive space should be set to at least
20.00 GB
(You can always change this later if you require more space). Once done, clickCreate
.
- On the window presented to you, type
- At this point, you should have an empty machine on the left with the name:
CS Ubuntu Machine
or whatever you named it. - From here we need to add the
.iso
file of Ubuntu Minimal we downloaded earlier. This can be done by right-clicking the machine on the left and selectingSettings...
from the drop-down menu. - Navigate to the
Storage
tab on the top menu and click theEmpty
CD/DVD icon under theController: IDE
on the left. - Beside
Optical Drive
make sure it saysIDE Secondary Master
. Also, click on the checkbox that saysLive CD/DVD
if it isn't checked already. - Click on the CD/DVD icon beside
Optical Drive
and selectChoose a disk file...
in the drop-down menu. Navigate to yourDownloads
folder, select themini.iso
file (this is the Ubuntu Minimal Disk), and pressOpen
. - Press
OK
in the settings menu and you should be brought back to the home page of the VirtualBox program. - Then, go ahead and select the machine on the left and press
Start
on the top menu above. This should pop up a window that has Ubuntu Minimal booting within it. If you are presented with a screen that asks to choose yourvirtual optical drive
just pressstart
asmini.iso
should already be selected. Ifmini.iso
is not appearing in the input box, you might have to restart steps starting from 12. - At this point in your virtual machine window should be presenting you with the
Installer boot menu
. If you accidentally click the screen and a message pops up askingYou have clicked the mouse
and tocapture
it, selectcancel
. If you pressedCapture
by accident press the leftcmd
button to uncapture your mouse. - If the screen is too small, solve this by clicking the display option on the bottom row (The row should be filled with icons. The display icon is between the gray folder icon and the film camera icon). In the drop-down menu select:
Virtual Screen 1
>Scale to 200% (autoscaled output)
. - From here select
Install
on the Ubuntu boot menu by pressingreturn
on your keyboard. - Below are the steps to setup Ubuntu:
- For language, choose
English
. Press theup arrow key
ordown arrow key
to highlight an option and pressreturn
to select it. - For the country, select
United States
. - Select
No
toDetect keyboard layout?
. - Select
English (US)
forCountry of origin for keyboard
. - Select
English (US)
again forKeyboard layout
. - Wait for installation.
- Leave hostname as
ubuntu
by pressing thedown arrow key
and selectingContinue
. - Select
United States
forUbuntu archive mirror country
. - Select
us.archive.ubuntu.com
forUbuntu archive mirror
. -
Do not enter
HTTP proxy information
leave it blank. Just pressreturn
. - Wait for further installation (this might take a minute or two).
- After installation is complete, type your full name into the text field. Enter your first name with the last name; separated by a space. (e.g
Nabeel Ahmed
). SelectContinue
once you are done. - The next menu should automatically type your first name in lowercase as a username, which is fine. If you don't see anything in the input field, type your first name only in lower-case only (e.g
nabeel
) (You can technically write any lowercase username but it is better if you can remember it so you can log in with ease). SelectContinue
once you are done. - For the next menu type a password for your system. Make sure it is rememberable as you will be using it often. Select
Continue
once you are done. - Re-enter your password for the next menu for verification. Select
Continue
once you are done. - Select
Yes
if Ubuntu is properly displaying your timezone. SelectNo
if it isn't and complete the steps it prompts you with fixing that. - Wait for more installation.
- For the
Partitioning method
make sure to selectGuided - use entire disk
. - For
Select disk to partition
, you should only have one option as we only created one drive. Select the only option. If you see multiple drives you might need to delete your virtual machine and start back at step 10 (close the Ubuntu virtual machine window by pressing the close button and selectingPower off the machine
. Once you are back to the VirtualBox's main page, right-click the virtual machine and select delete and then selectremove
thenDelete all files
). - Finally, select
Yes
toWrite the changes to disks?
- Wait for further installation (this might several minutes).
- Once the installation has completed, select
No automatic updates
. - Wait for further installation.
- For
choose software to install
do not select anything. Just pressreturn
. - Wait for further installation.
- Select
Yes
forInstall the GRUB boot loader to the master boot record?
- Wait for further installation.
- Select
Yes
forIs the system clock set to UTC?
- Wait for further installation.
- Finally, select
Continue
forInstallation complete
. - Once the virtual machine brings you back to the
Installer boot menu
, close the virtual machine window and selectPower off the machine
. The window should be gone now.
- For language, choose
- Once you return to the VirtualBox homepage, right-click your virtual machine on the left and select
Settings...
- Switch to the
Storage
tab and select themini.iso
belowController: IDE
. - On the right, click the CD/DVD icon beside the
Optical Drive
and selectRemove Disk from Virtual Drive
from the drop-down menu. - Press
OK
on the settings menu located at the bottom right of the menu. - Finally, click
Start
on the virtual machine. - Once a prompt for
ubuntu login
comes up type in your username (this should be just your first name lowercase). - For the
Password
prompt type in the password you chose. - If you did everything correctly, you should be logged in now and presented with a Linux shell.
- You are done! π
Top comments (0)