Linux Tutorial / Build a Linux Practice Environment in a Virtual Machine
A virtual machine (VM) provides a separate Linux computer inside your current computer. Install it on a new virtual disk and prepare console access and snapshot recovery before working through file, service, and network exercises.
Choose the host, guest, and course environment
The host runs the virtualization program; Linux inside the VM is the guest. The course reference environment is a conventional Ubuntu 26.04 LTS or Rocky Linux 9 VM using Bash and systemd. Start with one distribution. Add a second VM when you want to compare APT and DNF or distribution-specific service names.
The creation menus below follow VirtualBox 7.2. Check Oracle’s VM creation guide for your installed version and supported guests. These allocations are practice examples, not official minimum requirements. Leave enough resources for the host to continue working.
| Use | Example allocation | Reason |
|---|---|---|
| Ubuntu Desktop 26.04 | 2 virtual CPUs, 8 GB RAM, 40 GB dynamic disk | Graphical desktop and terminal |
| Ubuntu Server or minimal Rocky | 2 virtual CPUs, 4 GB RAM, 30 GB dynamic disk | Command-line work; increase for additional services |
The Ubuntu 26.04 release notes recommend resources including 6 GB RAM and 25 GB free storage for a comfortable Desktop experience. Virtual disk files and snapshots also consume host storage. A dynamically allocated disk can grow, so reserve capacity for future use.
Match the CPU architecture and installation image
On Windows, inspect Settings → System → About → System type. On macOS, inspect About This Mac. An Intel or AMD 64-bit host generally uses an amd64/x86_64 guest image; an ARM64 host needs an arm64/aarch64 image and virtualization software supporting that host. The name amd64 includes compatible Intel processors. Renaming an image does not convert its CPU architecture.
Get an Ubuntu Desktop or live-server ISO from the official Ubuntu 26.04 image listing. If choosing Rocky, select the 9 series and matching architecture on the Rocky Linux download site. Do not automatically substitute a newer major release for the course baseline.
Compare the downloaded ISO’s SHA-256 with the checksum from the official distribution location. In Windows PowerShell, replace the path below with your actual file. A matching hash detects corruption; authenticate the checksum through the official HTTPS site and the distribution’s signature-verification instructions.
Get-FileHash -Algorithm SHA256 "C:\Downloads\YOUR-LINUX-IMAGE.iso"
Create the VM and a new virtual disk
- Install the host-specific VirtualBox package from its official distribution site. In Manager, choose Home → New; tool placement can differ by version.
- Use a name such as
linux-course-ubuntu, choose a VM folder, and select the ISO Image. ClearInstall OS Using Unattended Installationto learn the interactive installer. Older screens may express this asSkip Unattended Installation. - Allocate CPU and memory within the host’s spare capacity, then create a new dynamically allocated virtual disk. Do not attach a physical host disk or use raw-disk access.
- Under the VM’s Settings → Network, keep the first adapter on NAT and confirm it is connected. Initially leave shared folders, bidirectional clipboard, and drag-and-drop disabled.
- Review the virtual disk, ISO, and memory before selecting Start. If hardware virtualization fails, check host and hypervisor compatibility. Investigate the cause before disabling unrelated security or virtualization features.
Install the guest and sign in
For Ubuntu Desktop, confirm language, keyboard, and network settings and follow the interactive installer. Use the official Ubuntu installation walkthrough alongside this lesson. Confirm the target is the newly created virtual disk by checking its capacity and device list. With a single new virtual disk attached, an automatic whole-disk layout applies to that guest disk. Do not run host disk-initialization tools.
Choose a user name, computer name, time zone, and password. Use an ordinary account and sudo for administrative work. In Rocky’s installation summary, check the target disk and software selection, and choose whether the created user is an administrator. After login, confirm sudo is allowed. A server installation can correctly present a text login prompt without a graphical desktop.
Reboot after installation. If prompted to remove installation media, or if the installer starts again, detach the ISO from the VM’s virtual optical drive and boot the virtual disk. Open Terminal from the Desktop application list, or sign in at the Server console.
Record installation and network details
cat /etc/os-release
uname -m
uname -r
bash --version
ps -p 1 -o comm=
ip -brief address
ip route
Record the distribution and VERSION_ID from /etc/os-release, CPU architecture, kernel, and Bash version. Check whether PID 1 is systemd. If the result differs from the intended environment, inspect the image used. Addresses and routes depend on your VM network; do not expect a fixed address. The terminal and basic commands lesson explains how to read and enter commands.
NAT is convenient for guest outbound access, but does not guarantee direct host access to the guest’s private address. For SSH, configure an explicit NAT port forward or a suitable separate network. Bridged networking can expose the guest on the physical LAN: check firewall settings, address conflicts, and workplace policy before choosing it. Internet-facing port exposure is unnecessary for initial practice.
Take a snapshot and verify a restore
Once installation works, shut down from inside the guest so the VM is Powered Off. Select the VM in Manager and choose Snapshots → Take, using a name such as clean-install. See the Snapshots section in the VirtualBox 7.2 user guide for the controls and restore behavior.
Start the VM after taking the snapshot and create this disposable marker file:
mkdir -p "$HOME/linux-course-recovery"
printf 'created after snapshot\n' > "$HOME/linux-course-recovery/after-snapshot.txt"
cat "$HOME/linux-course-recovery/after-snapshot.txt"
- Shut down normally. Save any needed changes outside the VM before reverting.
- Select
clean-installunder Snapshots and choose Restore. Check the effect of any option to preserve the current state as another snapshot. - Boot and sign in again. The following check should print
snapshot restoredif the marker did not exist when the snapshot was taken.
if test ! -e "$HOME/linux-course-recovery/after-snapshot.txt"; then
printf "snapshot restored\n"
else
printf "file still present; check selected snapshot\n"
fi
A snapshot reverts VM state on the same storage; it is not an independent backup. Protect against host-disk failure or a damaged VM folder with separate backups of important data and an appropriate powered-off VM copy or export. Guest snapshots do not revert shared folders, external services, or data already sent outside the VM.
Confirm recovery before system exercises
Before proceeding, confirm guest login, terminal access, sudo permission, NAT connectivity, console reconnection, and snapshot recovery. Use this VM for package, SSH, firewall, and mount changes, saving a snapshot and a record of changes first. Keep console login available so a broken SSH connection does not remove your recovery path.




