Based on the Linux Master 1 exam syllabusReport an error
destroy (forced shutdown) ≠ undefine (delete the definition).rm (container) / rmi (image), -p host:container, and RUN (build time) / CMD (run time) in the Dockerfile.| Category | Full virtualization | Paravirtualization |
|---|---|---|
| Guest OS modification | Not required (installed as is) | Required (kernel modified) |
| Hardware access | Hypervisor intercepts and handles it | Guest requests directly via hypercalls |
| Guest OS constraints | Even OSes that can't be modified, like Windows, are possible | Realistically only open-source kernels |
| Typical examples | KVM, VMware ESXi, Xen HVM | Xen PV |
Full virtualization "tricks" the guest. The guest kernel believes it is on real hardware and executes privileged instructions, but the hypervisor intercepts (traps) them and handles them on its behalf — which is why it can run OSes whose source cannot be touched, such as Windows. Paravirtualization modifies the guest kernel so that it asks through hypercalls instead of privileged instructions.
The performance problem of full virtualization was solved by Intel VT-x and AMD AMD-V. The CPU directly provides a guest mode, eliminating the interception cost, and so full virtualization became the standard. Paravirtualization remains only in the I/O area (virtio).
grep -E 'vmx|svm' /proc/cpuinfo # supported if you see the flag: Intel=vmx, AMD=svm
grep -c -E 'vmx|svm' /proc/cpuinfo # number of supporting logical cores (0 means unsupported or disabled in BIOS)| Category | Type 1 (bare metal) | Type 2 (hosted) |
|---|---|---|
| Position | Directly on the hardware | An application on a host OS |
| Host OS / Performance | Not needed / High | Needed / Low |
| Use | Servers, data centers, cloud | Desktop, development, learning |
| Typical examples | Xen, VMware ESXi, Hyper-V, KVM | VirtualBox, VMware Workstation |
[Type 1] [Type 2]
+------------------+ +------------------+
| VM | VM | VM | | VM | VM |
+------------------+ +------------------+
| Hypervisor | | Hypervisor (app) |
+------------------+ +------------------+
| Hardware | | Host OS |
+------------------+ +------------------+
| Hardware |
+------------------+
⚠️ Trap: How KVM is classified is the confusing point. KVM is a kernel module, so it looks like it is "on a host OS", but the moment it is loaded, the Linux kernel itself turns into a hypervisor. So it is usually classified as Type 1, and the standard answer choice on the exam is "KVM = Type 1, VirtualBox = Type 2".
lsmod | grep kvm # you should see kvm and kvm_intel (or kvm_amd)
modprobe kvm_intel # load the KVM module for Intel CPUs
ls -l /dev/kvm # the character device KVM exposes (crw-rw----)| Component | Role |
|---|---|
| KVM (kvm.ko, kvm_intel/kvm_amd.ko) | Kernel module. Handles CPU and memory virtualization via hardware acceleration |
| QEMU | User-space emulator. Emulates peripheral devices such as disk, NIC, graphics |
| libvirt / libvirtd | The virtualization management abstraction layer (API and daemon) |
| virsh / virt-manager | libvirt's command-line / GUI clients |
KVM and QEMU are not competitors but have a division of labor. KVM handles only CPU and memory with hardware acceleration, while peripheral devices like disk controllers, NICs, and VGA are emulated by QEMU. Memorize it as "KVM is the CPU, QEMU is the devices".
# RHEL/CentOS/Rocky family
dnf install qemu-kvm libvirt virt-install virt-manager
# Debian/Ubuntu family
apt install qemu-kvm libvirt-daemon-system virtinst virt-manager
systemctl enable --now libvirtd # common: start the libvirt daemonvirsh is the core of practical-exam short answers.virsh list # running domains only
virsh list --all # everything, including stopped ones
virsh start vm1 # start
virsh shutdown vm1 # graceful shutdown (sends an ACPI signal)
virsh destroy vm1 # forced shutdown (pulling the power cord) — not deletion!
virsh undefine vm1 # delete the domain definition (removal)
virsh suspend vm1 # pause (memory retained)
virsh resume vm1 # resume from pause
virsh dominfo vm1 # status, CPU, memory information
virsh dumpxml vm1 > vm1.xml # export the configuration as XML (the reverse: virsh define vm1.xml)
virsh autostart vm1 # start automatically when the host boots⚠️ Trap: Despite its name,
virsh destroydoes not delete the virtual machine. It forcibly turns it off like pulling the power cord; the disk and the definition remain, so you can turn it back on withvirsh start. The command that removes the registration isvirsh undefine.
The reason libvirt exists is abstraction. The virsh command works not only for KVM but also for Xen and LXC, by just changing the connection URI. The domain XML is in /etc/libvirt/qemu/, and the default storage for disk images is /var/lib/libvirt/images/.
virt-install, and disk images with qemu-img.raw : Simple and fast, but takes up the full capacity from the start.qcow2 : Supports thin provisioning, which grows only as much as is actually written, and snapshots, making it the default choice.qemu-img create -f qcow2 /var/lib/libvirt/images/vm1.qcow2 20G
qemu-img info /var/lib/libvirt/images/vm1.qcow2
virt-install --name vm1 --memory 2048 --vcpus 2 \
--disk path=/var/lib/libvirt/images/vm1.qcow2,size=20 \
--cdrom /iso/Rocky-9.iso --network bridge=br0 --graphics vnc| Kernel feature | What it does |
|---|---|
| namespace | Isolates what can be seen (PID, network, mount, hostname, user, IPC) |
| cgroup (control group) | Limits how much of a resource can be used (CPU, memory, I/O) |
| Comparison | Virtual machine (VM) | Container |
|---|---|---|
| Kernel | A separate kernel per guest | Shares the host kernel |
| Size / Boot | Several GB / tens of seconds | Tens to hundreds of MB / under 1 second |
| Isolation strength | Strong (hardware level) | Relatively weak (kernel shared) |
| Other OSes | Windows etc. possible | Linux containers run only Linux |
| Typical | KVM, VirtualBox | Docker, Podman, LXC |
ps inside a container, you see only its own processes, and ip addr shows only its own interfaces.The expression "a container is a lightweight virtual machine" is a wrong answer on the exam. A container has neither a guest kernel nor a hypervisor. That's why you can't run a Windows container on a Linux host, and if a kernel vulnerability is breached, the isolation is breached with it.
The roots of containers are Unix chroot from 1979. With cgroups and namespaces entering the Linux kernel the foundation was laid and LXC bundled them, and in 2013 Docker spread explosively by adding the distribution concepts of images and registries — the innovation was the "way of distribution" rather than the isolation technology.
| Concept | Definition |
|---|---|
| Image | A read-only template (layered structure). Does not run — equivalent to an installer |
| Container | A running instance made by placing a writable layer on top of an image |
| Registry | A repository that stores and distributes images (Docker Hub, etc.) |
docker pull nginx:1.25 # download an image from a registry (with a tag)
docker images # list of local images
docker run -d -p 8080:80 --name web nginx # create + run a container
docker ps # running containers (all: docker ps -a)
docker exec -it web /bin/bash # run a command in a running container (open a shell)
docker logs -f web # container standard output log (real time)
docker stop web # graceful stop
docker rm web # delete the container (must be stopped)
docker rmi nginx # delete the image
docker build -t myapp:1.0 . # build an image from a Dockerfile| Option | Meaning |
|---|---|
-d | detached, run in the background |
-it | interactive (-i keep stdin open + -t pseudo-terminal) |
-p host:container | Port mapping (publish) |
-v hostpath:containerpath | Volume / bind mount |
--name / -e KEY=VALUE / --rm | Specify a name / environment variable / auto-delete on exit |
There are questions that swap docker rm (delete a container) and docker rmi (delete an image) — with the i it is image. Also, in -p 8080:80, the host port comes first and the container port second, and a choice with the order reversed is wrong.
-v /host/data:/var/lib/mysql (a bind mount), the data remains even if you delete the container.FROM ubuntu:22.04 # base image (must be the first directive)
ENV APP_HOME=/app # environment variable
WORKDIR /app # working directory (created if absent)
COPY ./src /app # copy host files into the image
RUN apt-get update && apt-get install -y python3 # runs at build time
EXPOSE 8080 # document the port to be used
CMD ["python3", "app.py"] # default command to run when the container starts| Directive | Role |
|---|---|
FROM | Specifies the base image (always the first line) |
RUN | Runs a command at build time (the result remains in the image) |
COPY / ADD | Copy files (ADD supports URLs and automatic extraction) |
WORKDIR / ENV / USER | Working directory / environment variable / user to run as |
EXPOSE | Documents the exposed port (actual opening is via -p) |
CMD / ENTRYPOINT | Default command at run time (can be overridden) / fixed executable |
RUN and CMD differ in timing. RUN executes during docker build and its result is baked into the image, while CMD executes on docker run, and even if written several times, only the last one is effective. EXPOSE is only documentation and does not open external access.
podman run -d -p 8080:80 nginx works as is. Also know LXC/LXD, of the system container family.# Try it yourself — observing virtualization support and isolation features (safe: mostly queries)
grep -c -E 'vmx|svm' /proc/cpuinfo # number of cores supporting CPU virtualization (0 means unsupported)
lsmod | grep kvm # whether the KVM module is loaded
ls -l /dev/kvm 2>/dev/null || echo "KVM not in use"
lsns | head # list of namespaces on the system
ls /sys/fs/cgroup | head # cgroup hierarchy
virsh list --all 2>/dev/null || echo "libvirt not installed"
docker ps -a 2>/dev/null || echo "Docker not installed"VBoxManage command-line tool, with a consistent VBoxManage <subcommand> <VM name> [options] structure.VBoxManage list vms # list of registered VMs (running only: list runningvms)
VBoxManage showvminfo "vm1" # detailed VM information
VBoxManage startvm "vm1" --type headless # start in the background without a GUI
VBoxManage controlvm "vm1" acpipowerbutton # request graceful shutdown (forced: poweroff)
VBoxManage modifyvm "vm1" --memory 2048 # change settings (memory)
VBoxManage snapshot "vm1" take "before-update" # create a snapshotvirsh list --all / docker ps -a / VBoxManage list vmsvirsh destroy / docker kill / controlvm poweroffvirsh undefine / docker rm / unregistervm| Confusing pair | How to tell apart |
|---|---|
docker rm vs docker rmi | With the i, it deletes an image |
virsh destroy vs undefine | destroy = forced shutdown, undefine = delete definition |
RUN vs CMD | RUN = build time, CMD = run time |
| Type 1 vs Type 2 | Hardware below means 1, host OS below means 2 |
| Full vs paravirtualization | Guest kernel modification not required means full, required means para |
| VM vs container | A separate kernel means VM, shared means container |
vmx/svm flags in /proc/cpuinfo.virsh destroy vs undefine : Forced shutdown like pulling the power cord (can be turned back on) vs deleting the domain definition itself.docker rm vs rmi : Delete a container vs delete an image. The trailing i is image.RUN vs CMD : A directive executed at build time and baked into the image vs the default command executed when the container starts.Click a choice to reveal the answer and explanation.
Question 1
Which best describes the difference between Full Virtualization and Para Virtualization?
Question 2
Which correctly pairs the classification of Type 1 (bare metal) and Type 2 (hosted) hypervisors?
Question 3
Which statement about KVM is NOT correct?
Question 4
Which virsh command forcibly shuts down (cuts the power of) a running virtual machine vm1?
Question 5
Which is the most appropriate description of the fundamental difference between a virtual machine (VM) and a container?
Question 6
In Docker, which is the correct command to run a container in the background while connecting the host's port 8080 to the container's port 80?
Question 7
Which Docker command and role pairing is incorrect?