Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
What the course covers
This course teaches Linux on Red Hat Enterprise Linux (RHEL).
- It follows the goals of the RHCSA EX200 exam. It is a full study path.
- You start with files, text, and the shell. Then you move to users, services, storage, and security.
- You learn the tools an admin uses every day:
grep,awk,sed,vim,tar,systemctl,journalctl. - You build storage: partitions, swap, LVM, NFS shares, and autofs mounts.
- You harden the host with SELinux,
firewalld,sudo, and file permissions. - You run containers with Podman. You make them start at boot with
systemd. - The last part is a mock exam with 41 tasks. Each task has a check script.
Welcome to Alta3 Research Labs!
Three short lessons. They show how to use the Academy, the lab, and the VIRGIL coach.
- The lab has Linux machines:
bchd,rhel-1, andrhel-2. You move between them withssh. - To paste in the terminal: right-click Paste, or press
Shift+Insert, orCtrl+Shift+V. - The prompt shows
user@host:~$. The~is your home. The$means a normal user. Root shows#.
Required Tools
tmux is a terminal multiplexer. It keeps many shells in one window.
- Press
Ctrl+B, let go of the keys, then press the next key. %splits the screen left and right."splits it top and bottom.- Arrow keys move between panes.
zzooms one pane.[opens scrollback.Ctrl+Dcloses a pane.
Understand and use essential tools
grep finds text. -i ignores case, -n shows line numbers, -r searches folders, -v shows lines that do not match.
- Regex:
^start of line,$end of line,[abc]one of these letters,[^0-9]not a digit,.any one character,*zero or more. awkworks on fields.awk '{print $1}'prints the first field.sed 's/old/new/g'replaces text in a stream.-iedits the file in place.- Vim is a modal editor.
ito type,Escto stop typing,:wqto save and quit,:q!to quit and drop changes. findlooks for files by name, owner, size, type, or empty state.lnmakes a hard link.ln -smakes a soft link.- Redirection:
>writes,>>appends,2>sends errors,&>sends both,|sends output to the next command. - Archives:
tar -cf,tar -xf,tar -czffor gzip,tar -cjffor bzip2,tar -cJffor xz. - Copy between hosts with
scp,rsync(add-uor--delete), andsftp.
Manage users and groups
useradd -m john makes a user with a home. Other options: -d home path, -s shell, -G extra groups.
usermod -aG wheel johnadds a group.-Llocks,-Uunlocks,-d ... -mmoves the home.passwd johnsets a password.-eforces a change at next login.-llocks and-uunlocks.chage -l johnshows the age policy.-Mmax days,-mmin days,-Wwarning days,-Eexpiry date.groupadd,groupmod -n, andgroupdelmanage groups.gpasswd -d john developersremoves one member.- The
wheelgroup is the usual way to give a usersudo.
Create simple shell scripts
A script starts with #!/bin/bash.
- Use variables:
name="Alice"thenecho "$name". - Read arguments with
$1,$2, and$#. - Use
if [ -f /etc/passwd ]; then ... fi, plusforandwhileloops. - Make it executable with
chmod u+x script.sh, then run./script.sh. You can also runbash script.sh.
Operate running systems
systemctl start, stop, restart, status, enable, and disable. systemctl --failed lists broken units.
journalctl -bshows this boot.-u sshdfilters one unit.-p errfilters by priority.--since "1 hour ago"filters by time.logrotateruns from/etc/logrotate.d/. Directives:daily,rotate 7,compress,notifempty.topshows live load.ps auxlists processes.ps aux --sort=-%cpusorts by CPU.nice -n 10 ./job.shstarts a job at lower priority.renice 5 -p 1234changes a running job.tuned-adm list,tuned-adm profile latency-performance, andtuned-adm activemanage tuning profiles.- Boot targets:
systemctl get-default,systemctl isolate multi-user.target,systemctl set-default graphical.target. - Rescue and emergency targets help when a system will not boot. GRUB can be edited at boot time to reset the root password.
Configure local storage
lsblk shows disks and partitions.
fdisk /dev/vdbmakes partitions. Inside:nnew,pprint,ddelete,wwrite.mkfs.xfs /dev/vdb1ormkfs.ext4puts a file system on the partition.mount /dev/vdb1 /mntmounts it.umount /mntunmounts it.- Add a line to
/etc/fstabto mount at boot. Usedefaults 0 0at the end. Test withmount -abefore you reboot. - Swap:
mkswap /dev/vdb2,swapon /dev/vdb2, check withswapon --showorfree -h.
Create and configure file systems
LVM has three layers: physical volumes, volume groups, and logical volumes.
pvcreate /dev/sdb, thenvgcreate my_vg /dev/sdb, thenlvcreate -L 10G -n my_lv my_vg.- Format the LV with
mkfs.ext4 /dev/my_vg/my_lv, then mount it. - Grow a group with
vgextend. Grow a volume withlvextend -L +5G. - After you grow the LV, grow the file system:
resize2fsfor ext4,xfs_growfs /mntfor XFS. - NFS server: install
nfs-utils, share a folder in/etc/exports, thenexportfs -arvand enablenfs-server. - An export line looks like
/srv/nfs_share 192.168.1.0/24(rw,sync,no_root_squash). autofsmounts an NFS share only when someone uses it. Set it in/etc/auto.masterand a map file.
Deploy, configure, and maintain systems
dnf install, dnf remove, dnf update, and dnf autoremove. Add --enablerepo= to pick a repo.
dnf repolistand repo files under/etc/yum.repos.d/control where packages come from.- Flatpak installs desktop apps outside
dnf. at 14:30runs one job later. Close the input withCtrl+D.atqlists jobs andatrmdeletes them.crontab -eedits repeat jobs. The five fields are minute, hour, day, month, weekday.*/15 * * * *runs every 15 minutes.0 9 * * 1runs at 09:00 on Monday.- Time sync uses
chrony. Enablechronyd, then set aserver ... iburstline in/etc/chrony.conf.
Manage basic networking
sshd is the SSH server. Set Port, PermitRootLogin no, AllowUsers, and PubkeyAuthentication yes in /etc/ssh/sshd_config, then restart it.
ssh-keygen -t rsa -b 4096makes a key pair.ssh-copy-id user@hostsends the public key to the server.- Keep the keys safe:
chmod 700 ~/.sshandchmod 600 ~/.ssh/authorized_keys. nmcli connection modify ens4 ipv4.addresses 192.168.100.20/24 ipv4.gateway 192.168.100.1 ipv4.dns 1.1.1.1 ipv4.method manual.- Apply the change with
nmcli connection up ens4.nmtuidoes the same job with a menu. hostnamectl set-hostnamesets the host name.
Manage security
ls -l shows ugo/rwx permissions. chmod u+x, chmod g-w, and chmod 754 change them.
chown alice:developers filechanges owner and group.umasksets default permissions for new files and folders.chmod g+s foldermakes a set-GID folder. New files inside take the group of the folder. This helps teams share work.- SELinux has three modes: enforcing, permissive, and disabled.
getenforcereads the mode.setenforce 0or1changes it for now. - Contexts:
ls -Zshows labels,chcon -tchanges one for now,restorecon -Rputs the default back. - To make a context permanent, use
semanage fcontext -a -t httpd_sys_content_t /path. - Booleans:
getsebool -a, thensetsebool -P httpd_enable_homedirs on. The-Pmakes it stay after reboot. - Ports:
semanage port -a -t http_port_t -p tcp 8081lets HTTP use a new port.semanage port -llists labels. firewall-cmd --get-active-zonesshows zones. Add a service with--add-service=sshand a port with--add-port=8080/tcp.- Add
--permanentto save a rule, then runfirewall-cmd --reloadto apply it. - You can make a custom zone with
--new-zone=webapp, then add services, ports, and a source network to it.
Manage containers
podman pull nginx downloads an image. podman images lists images. podman tag adds a second name.
podman run -d --name mynginx -p 9090:80 nginxstarts a container in the background and publishes a port.podman pslists running containers.podman stopandpodman rmclean up.podman volume create myvolumemakes storage. Mount it with-v myvolume:/data, or bind a host folder with-v /host:/container.podman generate systemd --name mynginx --files --newwrites a unit file.- Move that file to
/etc/systemd/system/, thensystemctl enable --now container-mynginx. Now the container starts at boot.
Crush the RHCSA Exam!
The mock exam has 41 tasks. It looks and feels like the real EX200.
- Setup: install
git, clone therock-the-rhcsarepo onrhel-1andrhel-2. - Each page has a task and a check script, for example
bash ~/rock-the-rhcsa/check/13_vg_starfleet_check.sh. - Users and access: create users, set password policy, switch user, allow one
sudocommand without a password. - Text and files: find files by owner, grep by case,
sedin place, default file in each home, permissions, set-GID folder, soft link,scp. - Time and logs:
atjob,cronplustarevery five minutes, NTP server,logrotatedaily with five backups, export boot logs withjournalctl. - System: find the top CPU process,
renicecron, set SELinux enforcing, fix a context, set a boolean, configureens4, add an EPEL repo, autofs, NFS, boot target,tuned. - Storage: make a partition, a swap partition,
vg-starfleet,lv-spockon XFS, then grow it from 4G to 5G. - Security and services: reset the root password from GRUB, set the
homefirewall zone, install and enablehttpd. - Containers: pull and tag
nginx:examprep, runtoystorywith a volume, then make it asystemdservice. - Tip from the course: if a task does not survive a reboot, it is not done. Check your work twice.
Key commands and tools
- Text:
grep -in,grep -r,awk '{print $1}',sed -i 's/old/new/g',wc -l,less file. - Files:
touch,cp -r,mv,rm -r,find / -user frank,ln -s,tar -czf,tar -xzf. - Remote copy:
scp file user@host:/tmp/,rsync -av,sftp user@host. - Docs:
man ls,man -k network,apropos,command --help,less /etc/ssh/sshd_config. - Users:
useradd -m,usermod -aG,userdel -r,passwd,chage -l,groupadd,groups. - Permissions:
chmod,chown,chgrp,umask 027,chmod g+s,ls -l. - Services:
systemctl status,systemctl enable --now,journalctl -u,systemctl --failed. - Processes:
ps aux,top,nice,renice,kill. - Storage:
lsblk,fdisk,mkfs.xfs,mount,umount,blkid,df -h,mkswap,swapon. - LVM:
pvcreate,pvdisplay,vgcreate,vgextend,lvcreate,lvextend,lvremove. - NFS:
exportfs -arv,showmount -e,systemctl enable --now nfs-server,autofs. - Network:
ip addr,nmcli,nmtui,hostnamectl,ss -tln. - Security:
getenforce,setenforce,sestatus,ls -Z,chcon,restorecon,semanage,getsebool,setsebool -P. - Firewall:
firewall-cmd --list-all,--add-service,--add-port,--permanent,--reload. - Containers:
podman pull,podman run -d -p,podman ps,podman volume create,podman generate systemd. - Package and time:
dnf install,dnf repolist,flatpak install,timedatectl,chronyc sources.
Key terms
The words of this course in one table. Learn them before the quiz or exam.
| Term | Meaning |
|---|---|
| autofs | A service that mounts a share only when someone uses it. |
| Context | The SELinux label of a file or process, for example httpd_sys_content_t. |
| dnf | The package manager on RHEL. It installs, updates, and removes software. |
| EX200 | The code of the RHCSA exam. The mock exam in this course copies its style. |
| firewalld | The firewall service on RHEL. firewall-cmd changes its rules. |
| journalctl | The command that reads the systemd log (the journal). |
| Logical volume (LV) | A slice of a volume group. You format and mount it like a disk. |
| logrotate | The tool that rotates, compresses, and deletes old log files. |
| LVM | Logical Volume Management. A flexible layer between disks and file systems. |
| NFS | Network File System. It shares a folder from one host to other hosts. |
| Physical volume (PV) | A disk or partition prepared for LVM with pvcreate. |
| Podman | A tool that runs containers without a daemon. |
| Redirection | Sending command output to a file with >, >>, or 2>. |
| Regular expression | A pattern for matching text, used by grep and sed. |
| RHCSA | Red Hat Certified System Administrator. A Linux admin certificate from Red Hat. |
| RHEL | Red Hat Enterprise Linux. The Linux version used in the labs. |
| SELinux | Security-Enhanced Linux. It labels files and processes and blocks actions that break policy. |
| set-GID | A folder bit (chmod g+s) that makes new files keep the folder's group. |
| sudo | A tool that lets a normal user run one command as root. |
| Swap | Disk space used as extra memory when RAM is full. |
| systemd | The service manager on RHEL. systemctl controls it. |
| Target | A systemd state such as multi-user, graphical, rescue, or emergency. |
| umask | A mask that sets the default permissions of new files and folders. |
| Volume group (VG) | A pool of space built from one or more physical volumes. |
| Zone | A named set of firewall rules, such as public, home, or a custom webapp. |
Useful links
Official documentation and pages for this course.
Oefenen
Alle commando's in dit hoofdstuk
grepawksedvimtarsystemctljournalctlsudosshtestfindlnscprsyncsftpusermodpasswdchagegroupaddgpasswdechochmodbashlogrotatetoppsnicerenicetuned-admfdiskwmkfs.xfsmkfs.ext4mountumountmkswapswaponfreepvcreatevgcreatelvcreatevgextendlvextendresize2fsxfs_growfsexportfsdnfatcrontabssh-keygenssh-copy-idnmclinmtuihostnamectlchownumaskgetenforcelschconrestoreconsemanagegetseboolfirewall-cmdpodmangitapachectlwclesstouchcpmvrmmanaproposuseradduserdelgroupschgrpkilllsblkblkiddfpvsshowmountipsssestatusflatpaktimedatectlchronyc