Lab setup, getting help & vim
Run a RHEL-compatible and an Ubuntu VM and find answers with man, --help and vim.
By Invicly Tech, , in Linux Administration (RHCSA-style). About 10 minutes to read.
In short
You learn administration by breaking and fixing real systems, so start with two virtual machines: a RHEL-compatible one such as Rocky or AlmaLinux, and Ubuntu Server. Snapshots let you experiment without fear. The RHCSA gives you no internet, so you must get answers from man pages and --help, and edit files quickly in vim.
Explained simply
To learn Linux administration you need machines you are allowed to break. A virtual machine (VM) is a whole computer simulated inside your own computer. You can install Linux on it, change anything, and if it stops working, you lose nothing real. Most learners run two VMs: one from the Red Hat family (Rocky Linux or AlmaLinux) and one Ubuntu Server.
Why two? Companies use both families, and they differ in small but important ways: the package tool, the firewall tool and the name of the admin group. Doing each lab on both teaches you what is Linux in general and what is just one distribution's habit.
A snapshot is a saved moment of a VM. Before a risky lab, such as editing the boot loader or resizing a disk, you take a snapshot. If the VM no longer boots, you go back to the snapshot in a few seconds, as if nothing happened.
Servers often have no web browser and exams like the RHCSA give you no internet. So you must find answers on the machine itself. man pages are the built-in manual, --help prints a short usage summary, and vim is the editor you will find on almost every server. Learning these three makes you independent.
Press Play on a diagram to walk through it one step at a time.
- Packages: dnf and rpm
- Firewall: firewalld
- MAC: SELinux
- Admin group: wheel
- Packages: apt and dpkg
- Firewall: ufw (on nftables)
- MAC: AppArmor
- Admin group: sudo
- 1Normal mode
Move, delete (dd), copy (yy), paste (p).
- 2Insert mode
Press i or o, then type text.
- 3Back to Normal
Press Esc.
- 4Command-line mode
:w saves, :q quits, :wq both, :q! discards.
- Back to step 1
- 1Snapshot
Name it after the lab, for example before-lvm
- 2Read the docs
man page, --help, /usr/share/doc
- 3Make the change
One step at a time, check each one
- 4Reboot and test
Proves the change is persistent
- 5Keep or revert
Revert if broken, then try again
In depth
Building a useful lab
Any hypervisor works: KVM with virt-manager on a Linux host, VirtualBox or VMware Workstation on Windows, and UTM on Apple Silicon Macs (use the ARM64 builds of Rocky, Alma and Ubuntu there). A minimal server install is happy with 2 virtual CPUs, 2 GB of RAM and a 20 GB disk.
Two extras save you time later. First, add one or two small empty disks (for example 5 GB each) to every VM now; the storage and LVM labs need disks with nothing on them. Second, give each VM a network you can reach from your host, such as a host-only or bridged network, so you can SSH in from your normal terminal and copy and paste commands. Working over SSH is also closer to real server work than typing into the VM console.
- Choose the minimal or server install, not a desktop
- Create a normal user with admin rights during install
- Note each VM's IP address with ip -br addr
- Keep the install ISO around for rescue labs later
How snapshots really work
A snapshot does not copy the whole disk. The hypervisor freezes the current disk image and sends every new write into a separate overlay file. Reading a block checks the overlay first and falls back to the frozen image. Reverting simply throws the overlay away, which is why it is so fast.
This has two consequences. A snapshot lives on the same storage as the VM, so it is not a backup: if the host disk dies, both are gone. And long chains of snapshots make disk access slower and waste space, so delete the ones you no longer need. Take snapshots with the VM shut down when you can; a running snapshot also has to save the RAM, which is bigger and slower.
- 1What the VM sees
One normal disk, nothing looks different
- 2Overlay (new writes)
Every change since the snapshot lands here
- 3Frozen base image
Read only, the state at snapshot time
- 4Host disk
Holds both files, so it is not a backup
Getting answers from man pages
man pages are split into numbered sections. The same word can exist in several of them: passwd(1) is the command, passwd(5) is the format of /etc/passwd. man 5 passwd picks the section, and man -f passwd lists every page with that name.
man -k (also called apropos) searches a small database of page names and short descriptions. If it says nothing appropriate even for common words, the database has not been built yet; run sudo mandb once. Inside a page, type /word to search, n for the next hit, G to jump to the end (where EXAMPLES often live) and q to quit.
Minimized Ubuntu images, common in the cloud, strip man pages to save space; the unminimize command puts them back. Also look in /usr/share/doc, where many packages ship sample configs.
- 1: user commands
- ls, grep, passwd
- 5: file formats
- fstab, passwd, sudoers
- 7: overviews
- hier, regex, signal
- 8: admin commands
- useradd, mount, lvcreate
vim beyond save and quit
Most admin editing is small: find a line, change a value, save. A handful of Normal mode keys covers it. gg jumps to the top and G to the bottom. /PermitRoot searches forward and n repeats the search. x deletes a character, dd deletes a line, u undoes and Ctrl-r redoes. cw replaces the word under the cursor. :set number shows line numbers, and :%s/old/new/g replaces text in the whole file.
On a minimal RHEL-family install, vi comes from the small vim-minimal package and the full vim command comes from vim-enhanced. Tools like visudo, crontab -e and systemctl edit open the editor named in the EDITOR or VISUAL variable, so export EDITOR=vim if you get nano and wanted vim.
- Esc always brings you back to Normal mode
- :wq or :x saves and quits
- :q! quits and throws away changes
- vimtutor is a 30-minute built-in lesson
Learn it in 4 short steps
About 45m each. Track them with a timer in your plan.
- 1Install Rocky or Alma and Ubuntu VMs~45m
- 2Snapshot VMs before risky changes~45m
- 3Search docs with man -k and --help~45m
- 4Edit, save and quit files in vim~45m
Key points
- Take a VM snapshot before every risky lab so you can roll back in seconds.
- man -k keyword searches page descriptions; man 5 shows file formats.
- Many packages ship examples under /usr/share/doc.
- In vim, Esc then :wq saves and quits, and :q! quits without saving.
Key terms
Tap a card to flip it. 0/5 known
Examples
man -k partition # which commands deal with partitions?
man 5 fstab # file format pages live in section 5
nmcli --help | less
ls /usr/share/doc/chrony*
vimtutor # 30-minute interactive vim lessonFinding answers offline.
Snapshot and revert a KVM lab VM
You are about to practise resetting the root password, which can leave the VM unbootable if you make a typo. Step 1: shut the VM down. Step 2: take a named snapshot. Step 3: start the VM and do the lab. Step 4: if something goes wrong, shut it down and revert. Step 5: list and delete old snapshots so the chain stays short. VirtualBox users can do the same with VBoxManage snapshot NAME take, restore and delete.
virsh shutdown rocky9
virsh snapshot-create-as rocky9 before-rootpw "before root password lab"
virsh start rocky9
# ... lab goes wrong ...
virsh destroy rocky9 # hard power off
virsh snapshot-revert rocky9 before-rootpw
virsh snapshot-list rocky9
virsh snapshot-delete rocky9 before-rootpwFind the right command with no internet
A task says: change the time zone. You do not remember the command. Step 1: search descriptions with man -k. Step 2: the list shows timedatectl (Control the system time and date), so read its short help. Step 3: list valid zone names and filter them. Step 4: set the zone and check the result. The same three moves (man -k, --help, man) answer most questions on an exam.
man -k date | grep -i time # if empty: sudo mandb, then retry
timedatectl --help
timedatectl list-timezones | grep -i kolkata
sudo timedatectl set-timezone Asia/Kolkata
timedatectlQuick reference
- man -k word searches page descriptions; run sudo mandb once if it finds nothing
- man -f passwd lists every section that has a passwd page
- Inside man or less: /word searches, n next match, G end, q quit
- ls /usr/share/doc/PACKAGE often has sample config files
- vim: gg top, G bottom, dd delete line, u undo, :%s/a/b/g replace all
- export EDITOR=vim makes visudo, crontab -e and systemctl edit use vim
- virsh snapshot-create-as VM NAME and virsh snapshot-revert VM NAME
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Without the internet, find which command shows the system's host name and how to change it permanently.
- Exercise 2medium
In vim, open a copy of /etc/ssh/sshd_config, show line numbers, jump to the line with PermitRootLogin, change it to no, save and quit. Confirm with grep.
- Exercise 3hard
Prepare both lab VMs for the storage labs: add two empty 5 GB disks to each, confirm Linux sees them, and take a snapshot named clean-disks.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Rocky Linux or AlmaLinux for RHCSA practice?
- Either is fine. Both are free rebuilds that aim to match RHEL closely, so commands and file locations are the same as on the exam.
- Can I use containers instead of VMs for the lab?
- Not for most of it. Containers share the host kernel and usually have no systemd, boot loader or real disks, so labs on boot, storage, SELinux and services need a full VM.
- Do I have to use vim?
- No, nano is easier and fine for daily work. But vi or vim is installed on nearly every server and rescue environment, so knowing the basics avoids being stuck.
- What is the difference between man and --help?
- --help prints a short summary built into the program. man opens the full manual with every option, file formats and often examples.