Red Hat · Free Practice Questions · Last reviewed May 2026
51real exam-style questions organised by domain, each with the correct answer highlighted and a plain-English explanation of why it's right — and why the others are wrong.
12% of exam · 3 sample questions below
Refer to the exhibit. What is the most likely cause of this failure?
Another process is already bound to port 22.
The log message 'Cannot bind any address' is what OpenSSH emits when bind(2) returns EADDRINUSE, meaning another process already holds a listening socket on 0.0.0.0:22 or the specific address configured in sshd_config. This can happen after a failed shutdown leaves an old sshd running, or if another daemon (e.g., a second sshd, a proxy) grabbed port 22. Confirm by checking `ss -tlnp` or `sudo lsof -i :22` to identify the PID holding the port.
The sshd service is not enabled.
SELinux is blocking the service.
The /etc/ssh/sshd_config file is missing.
A junior administrator configured a new network interface (ens224) with a static IP address using a configuration file in /etc/sysconfig/network-scripts/ifcfg-ens224. After restarting the network service, the interface comes up but does not get the IP address. The administrator runs 'ip addr show ens224' and sees no IP address assigned. The interface is listed as DOWN. The administrator then runs 'ifup ens224' manually, which succeeds, and the IP address appears. What is the most likely cause?
The ONBOOT directive is set to no in the ifcfg file.
The ONBOOT directive in the interface's ifcfg file (e.g., /etc/sysconfig/network-scripts/ifcfg-eth0) explicitly controls whether the interface is activated when the system boots. When ONBOOT=no, the interface is fully configured but is deliberately skipped by the boot-time startup sequence, so it stays down until an administrator runs ifup or uses NetworkManager to connect manually. Manual activation succeeds because the rest of the configuration (e.g., IP address, netmask, gateway) is valid, and the service that performs ifup is already running. This exactly matches the symptom of an interface that is correctly configured but not active after a reboot.
The network service is not enabled to start at boot.
The interface name does not match the device file.
There is a conflict with NetworkManager managing the interface.
A system administrator is troubleshooting a custom service called 'database.service' that fails intermittently. The service is a proprietary database that requires large amounts of memory. The administrator runs systemctl status database and sees 'Active: failed (Result: core-dump)' and the journal shows 'Out of memory: Killed process (database) total-vm:...' The server has 8GB RAM and 2 CPU cores. The service unit file does not contain any memory limits. The application is configured to use up to 4GB. The administrator suspects the systemd service is being killed by the OOM killer. Which action should the administrator take to prevent this issue?
Set MemoryMax=6G in the service unit file.
Set OOMScoreAdjust=-1000 in the service unit file.
Setting OOMScoreAdjust=-1000 in the service unit file writes -1000 to /proc/<pid>/oom_score_adj, making the process's OOM score effectively zero and marking it as the kernel's last choice for OOM victim selection. This is a direct, unit-level mitigation that applies only to the custom service, so it doesn't weaken system-wide OOM behavior. It is the recommended way to protect a critical service from being killed.
Modify kernel parameters to disable the OOM killer.
Increase swap space to 16GB.
Want more Operate running systems practice?
Practice this domain11% of exam · 6 sample questions below
An administrator needs to ensure that a specific LVM logical volume is automatically mounted at boot with the 'noexec' option. Which configuration file and entry should be used?
/etc/fstab: /dev/vg/lv /mnt ext4 noexec 0 0
/etc/rc.d/rc.local: mount /dev/vg/lv /mnt -o noexec
/etc/fstab: /dev/vg/lv /mnt ext4 defaults,noexec 0 0
Correct fstab entry.
/etc/rc.local: mount -o noexec /dev/vg/lv /mnt
A server has a software RAID 5 array /dev/md0. One of its disks fails. The administrator wants to replace it without rebooting. Which command should be used to mark the disk as failed?
mdadm --fault /dev/md0 /dev/sdb
echo faulty > /sys/block/md0/md/dev-sdb/state
mdadm --set-faulty /dev/md0 /dev/sdb
mdadm --fail /dev/md0 /dev/sdb
This is the correct command: mdadm --manage --fail /dev/md0 /dev/sdb (the --manage action is implicit when using --fail) marks /dev/sdb as faulty in the RAID 5 array /dev/md0. Once marked, mdadm removes the device from the active array, and the array continues operating in a degraded state because RAID 5 tolerates a single disk failure. You can then remove the failed disk (mdadm --remove) and replace it (mdadm --add) to rebuild redundancy, which is the proper workflow for handling a failing disk.
An administrator wants to add the two 2G disks (sdc and sdd) as physical volumes, extend the 'data' logical volume in volume group 'vg' by 2G, and grow the filesystem. Which sequence of commands should be used?
pvcreate /dev/sdc /dev/sdd; vgextend vg /dev/sdc /dev/sdd; lvresize -L 2G /dev/vg/lv_data; xfs_growfs /data
pvcreate /dev/sdc /dev/sdd; vgextend vg /dev/sdc /dev/sdd; lvextend -L +2G /dev/vg/lv_data; resize2fs /dev/vg/lv_data
pvcreate /dev/sdc /dev/sdd; vgextend vg /dev/sdc; vgextend vg /dev/sdd; lvextend -L +2G /dev/vg/lv_data; xfs_growfs /dev/vg/lv_data
pvcreate /dev/sdc /dev/sdd; vgextend vg /dev/sdc /dev/sdd; lvextend -L +2G /dev/vg/lv_data; xfs_growfs /data
This command chain is fully correct. pvcreate initializes both /dev/sdc and /dev/sdd as physical volumes, then vgextend adds both to volume group vg in a single command. lvextend -L +2G grows lv_data by exactly 2 GiB (the plus sign means 'add' rather than 'set to'), and xfs_growfs /data expands the XFS filesystem that is mounted at /data to consume the additional space. This is the proper order: create PVs, extend the VG, extend the LV, and finally grow the filesystem online without needing to unmount.
A system administrator is setting up storage for a new application server. The application requires two separate filesystems: one for the database (needs to be at least 10GiB) and one for logs (needs at least 5GiB). The server has a single 20GiB disk /dev/sda. The administrator plans to use LVM and a single volume group 'vg_app'. They create physical volume on /dev/sda, create the volume group, and then create two logical volumes: 'lv_db' of 10GiB and 'lv_logs' of 5GiB. They format lv_db as ext4 and lv_logs as xfs, and mount them at /db and /logs respectively. After rebooting, the system fails to mount /logs. What is the most likely cause?
The logical volume 'lv_logs' overlaps with 'lv_db'.
The /logs entry is missing from /etc/fstab.
The /etc/fstab file is the persistent mount table that systemd reads at boot via fstab-generator to create mount units. Without an entry for /dev/vg_app/lv_logs (or its UUID) pointing to /logs, the filesystem will not be mounted automatically after a reboot. The storage device exists and is formatted, but the mount point is empty because no fstab line tells the system to mount it. This is the classic cause of a filesystem that is reachable manually but unavailable after the server restarts.
The physical volume /dev/sda is not recognized by LVM after reboot.
The volume group 'vg_app' is not automatically activated.
Which command can be used to create a logical volume using all available free space in a volume group?
lvcreate --size 20G vgdata lvdata
lvcreate -l 100%FREE -n lvdata vgdata
The -l flag accepts percentage-based allocation, and 100%FREE specifically targets only the unallocated physical extents in the volume group, so the resulting LV consumes all remaining free space. In contrast to a fixed-size command, this scales automatically as the VG's free space changes. It is the canonical way to create an LV spanning the full free capacity without requiring the administrator to calculate extent counts.
lvcreate -L 20G -n lvdata vgdata
lvcreate -l 100%VG -n lvdata vgdata
lvcreate -L 100%FREE -n lvdata vgdata
An administrator wants to add an additional swap partition of 2GB on device /dev/sdb1. Which set of commands should be used to enable swap and make it persistent across reboots?
parted /dev/sdb set 1 swap on
swapadd /dev/sdb1
mkswap /dev/sdb1; swapon /dev/sdb1; echo '/dev/sdb1 swap swap defaults 0 0' >> /etc/fstab
This is the correct sequence: `mkswap` initializes the partition with a swap signature, `swapon` activates it immediately for use by the kernel, and appending the line to `/etc/fstab` ensures the swap partition is automatically enabled at boot. The fstab entry uses the correct fields: device, mount point specified as `swap`, filesystem type `swap`, and `defaults` as the mount options. This covers both immediate activation and persistence across reboots, satisfying the administrator's requirement.
mkfs.ext4 /dev/sdb1; mount /dev/sdb1 /swap
None of the above
Want more Configure local storage practice?
Practice this domain11% of exam · 6 sample questions below
An administrator needs to add a 1GB swap partition on /dev/sdd1. Which series of commands accomplishes this?
mkswap /dev/sdd1 && echo '/dev/sdd1 swap swap defaults 0 0' >> /etc/fstab
mkfs.swap /dev/sdd1 && swapon /dev/sdd1
mkswap /dev/sdd1 && swapon /dev/sdd1
fdisk /dev/sdd, create partition, then mkswap /dev/sdd1, swapon /dev/sdd1, and add to /etc/fstab.
This is the complete and correct procedure: fdisk creates a 1 GB partition on /dev/sdd (assigned as /dev/sdd1), mkswap writes the swap signature to that partition, swapon activates the swap for immediate use, and adding the line to /etc/fstab ensures automatic activation at boot. The fstab entry alone or the swapon alone would be incomplete, but combining them covers both current-session and persistent swap. The fdisk step also ensures the partition actually exists with the desired size, unlike the other options that assume a preexisting /dev/sdd1.
A filesystem is reported as 'read-only' after a system crash. The admin runs fsck and sees 'clean' status. What is the most likely reason it remains read-only?
fsck cannot fix errors on ext4 filesystems.
The filesystem is still mounted; fsck cannot fix it while mounted.
The filesystem is XFS, and fsck does not repair XFS.
This is correct. XFS is not repairable by fsck; fsck only inspects the XFS log to see whether the filesystem was cleanly unmounted and reports a 'clean' status based on that flag alone, without traversing metadata structures. To actually verify and repair an XFS filesystem you must use the dedicated xfs_repair utility, so a read-only XFS filesystem after a crash would still be reported as 'clean' by fsck while remaining unusable for writes.
fsck detected errors but did not fix them automatically.
Which TWO commands are valid for resizing an XFS file system? (Choose exactly two.)
xfs_admin -L /mnt
xfs_growfs /mnt
xfs_growfs is the standard tool for resizing an XFS filesystem, and running it with a mount point grows the filesystem to occupy all available space in the underlying device or logical volume. This command works online—meaning the filesystem can remain mounted and in use during the operation—which is a key advantage in production environments. Therefore, xfs_growfs /mnt is a valid and correct answer for resizing an XFS filesystem.
resize2fs /dev/sda1
xfs_growfs -D 10g /mnt
xfs_growfs -D 10g /mnt is a valid resizing command because the -D option explicitly sets the new filesystem size to 10 gigabytes, overriding the default behavior of expanding to the full device capacity. It can be used as an alternative to the plain xfs_growfs /mnt when you want to control the exact final size, and the command still requires the target to be larger than the current filesystem since XFS only supports growing. This option is useful when extending a logical volume to a specific size rather than filling all available space.
xfs_repair /dev/sda1
A system administrator needs to create a file system on a new 10GB partition /dev/sdb1 for use with a database that requires high reliability and supports snapshots. Which file system type should be chosen?
xfs
XFS is the correct choice because it is the default filesystem on RHEL 9, and Red Hat fully supports it for production workloads. While XFS itself does not have native snapshot capabilities, it works seamlessly with LVM, which provides snapshot functionality for consistent backups and recovery. Its allocation groups, scalable inode handling, and high concurrency support make it ideal for large database files, exactly what the administrator needs.
ext4
vfat
btrfs
A technician runs 'mkfs.xfs /dev/sdb1' and later mounts it. The file system is reported as having a block size of 1024 bytes. What is the most likely reason?
The administrator used the -b size=1024 option.
The block size setting was ignored due to a kernel limitation.
The default block size for XFS is 1024 bytes.
The partition size is less than 1GB, so mkfs.xfs automatically used a 1024-byte block size.
When the partition on /dev/sdb1 is smaller than 1 GiB, mkfs.xfs automatically uses 1024-byte blocks instead of the usual 4096-byte blocks. This tuning improves space efficiency on small volumes by reducing the overhead associated with larger blocks, such as internal fragmentation and per-block metadata structures. The administrator did not need to specify any option; this is the default behavior for sub-1 GiB XFS filesystems.
Which command displays the UUID of all file systems on the system?
blkid
blkid is the dedicated utility that enumerates all block devices visible to the system and prints each file system's UUID, TYPE, LABEL, PARTUUID, and other attributes by default. Since it scans every block device under /dev via libblkid, a bare `blkid` command displays the UUIDs of all file systems without needing a device argument or a filesystem-specific tool.
dumpe2fs -h
lsblk
fdisk -l
Want more Create and configure file systems practice?
Practice this domain11% of exam · 6 sample questions below
A RHEL 9 system has a second disk /dev/sdb that needs to be partitioned with a single partition using all space, formatted with XFS, and mounted persistently at /data. The administrator uses fdisk to create the partition /dev/sdb1. Which filesystem creation command should be used?
mkfs.xfs /dev/sdb1
mkfs.xfs is the correct command because it explicitly initializes an XFS filesystem on the target partition. XFS is the default filesystem in RHEL 9 for root and many standard partitions, and this invocation creates the required on-disk structure, including the superblock, allocation groups, and B+tree metadata. After running this command, the partition can be mounted and used as an XFS volume.
mke2fs /dev/sdb1
mkfs -t ext4 /dev/sdb1
mkfs.ext4 /dev/sdb1
Refer to the exhibit. The administrator wants to add an additional 5GB to the /mnt/data filesystem. There is no unpartitioned space on /dev/sdb. Which is the correct procedure?
Use resize2fs /dev/sdb1 to expand filesystem.
Add a new disk, create a physical volume, extend volume group, and extend logical volume.
Use fdisk to delete and recreate /dev/sdb1 with larger size, run partprobe, then xfs_growfs /mnt/data.
Correct steps for XFS on a partition.
Use fdisk to delete and recreate /dev/sdb1 with larger size, then mount.
A system administrator needs to ensure that a web server running Apache httpd starts automatically after a system reboot. Which command should the administrator use to enable the httpd service?
systemctl daemon-reload
systemctl start httpd
systemctl reenable httpd
systemctl enable httpd
Enables the service to start at boot.
An administrator needs to configure a service to start automatically at boot and also start it immediately without rebooting. Which single command accomplishes both tasks?
systemctl start httpd.service
systemctl enable httpd.service
systemctl enable --now httpd.service
systemctl enable --now httpd.service combines boot-persistent enablement with immediate activation in a single atomic operation. The --now flag instructs systemd to both create the boot-enabling symlinks and start the unit right away, eliminating the risk of forgetting either step. This is the correct choice when the requirement explicitly states that the service must start automatically after reboot; it satisfies both the immediate runtime need and the persistent boot-time need simultaneously.
systemctl reenable httpd.service
A system fails to boot and drops into an emergency shell. The administrator suspects a misconfigured /etc/fstab. Which command should be used to determine which filesystem is causing the boot issue?
systemctl status local-fs.target
journalctl -xb -p err
Running journalctl -xb -p err reads the persistent journal from the current boot (-b), applies extended explanatory hints (-x) that describe what each message means, and filters to error priority and above (-p err). This will surface kernel driver errors, systemd mount failures, and device not found messages that directly explain why local-fs.target failed. Because the emergency shell runs early in the boot process, the journal still contains the relevant log entries, making this the most reliable diagnostic command.
fsck -A
mount -a
A user reports that they cannot create files in their home directory. The administrator checks permissions and sees drwxr-xr-x. What is the likely cause?
The directory has the sticky bit set
The filesystem is read-only
The user is not the owner of the directory
If the user is not the owner of their home directory, the owner permission set (typically rwx) does not apply to them. Depending on whether they belong to the directory's group, they fall under the group or other permissions, which in this case are r-x, lacking write permission. Write access to the directory is a prerequisite for creating a new entry, so without 'w' in the effective permission bits, the create operation fails with 'Permission denied'. The ownership mismatch is therefore the direct cause.
The user is not in the group
Want more Deploy, configure, and maintain systems practice?
Practice this domain11% of exam · 6 sample questions below
A system administrator needs to ensure that a user named 'bob' can access a shared directory '/data' owned by group 'developers'. The directory has permissions 2775 and is owned by root:developers. Bob is a member of the 'developers' group. However, when Bob tries to create a file in '/data', it fails with 'Permission denied'. What is the most likely cause?
The directory has incorrect SELinux context
Even when the directory's mode and ownership (2775, root:developers) grant Bob write access, SELinux performs a separate mandatory access control check. If /data carries a context type that Bob's domain is not allowed to write to (for example, default_t instead of a type like public_content_rw_t or a domain-specific type), the kernel denies the operation with EACCES. This appears as a permission problem though standard permissions are correct. To fix, restore or apply the correct context, e.g., restorecon -Rv /data or a custom semanage fcontext rule.
Bob's umask is set to 0077
The setgid bit is not set
Bob's primary group is not developers
An administrator wants to add the user 'jane' to the supplementary groups 'wheel' and 'docker' without removing her from other groups. Which command should be used?
groupmems -a jane -g wheel,docker
usermod -aG wheel,docker jane
The -aG form is a compact combined option where -a enables append mode and -G specifies the supplementary group list, so the effect is exactly the same as usermod -a -G. It adds jane to wheel and docker while retaining any other supplementary groups she already has. Although it is less readable than the separated form, it is a fully valid and correct way to accomplish the task.
usermod -a -G wheel,docker jane
Using -a alongside -G directs usermod to append the listed groups to the user's current supplementary groups instead of replacing them. This command explicitly adds jane to both wheel and docker, and because -a is present, all her existing supplementary memberships are left intact. It is the canonical, unambiguous way to satisfy the requirement, and the space between -a and -G is optional but harmless.
usermod -G wheel,docker jane
A server has a requirement that all users in the 'finance' group must have a password aging policy that forces password change every 90 days. Which approach best achieves this for existing users?
Set PASS_MAX_DAYS 90 in /etc/login.defs
Edit /etc/shadow and change the fifth field for all users
Configure pam_pwquality.so to enforce password age
Write a script to run 'chage -M 90' for each user in the finance group
A script that calls chage -M 90 for each user in the finance group is the correct approach because chage directly updates the maximum password age field in /etc/shadow for existing user accounts. For example, you can iterate over `getent group finance | cut -d: -f4`, and run chage for each member, which precisely targets the intended accounts and leaves all other users untouched.
Which TWO commands can change the primary group of an existing user?
usermod -aG
`usermod -aG` adds the user to a supplementary group, not the primary group.
gpasswd -a
`gpasswd -a` adds the user to a supplementary group, not the primary group.
vigr
groupmems -a
useradd -G
A company needs to create a user account for a temporary contractor who will work for exactly 90 days. The account must be automatically disabled after 90 days. Which command should the administrator use?
useradd -f 90 contractor
useradd -e $(date -d '+90 days' +%Y-%m-%d) contractor
Correct. The -e option specifies an account expiration date in YYYY-MM-DD format. Using $(date -d '+90 days' +%Y-%m-%d) dynamically calculates the date 90 days from today, ensuring the account is disabled after exactly 90 days.
useradd -e 90 contractor
useradd -f 90 -e 0 contractor
A user named jdoe is receiving 'Permission denied' errors when trying to access a file owned by root with permissions 644. The user is a member of the root group. What is the most likely cause?
The directory containing the file lacks execute permission for the group or others.
The directory containing the file lacks execute permission for the group or others. This is the most likely cause because to access a file inside a directory, the user needs execute (x) permission on the directory. Without it, even with correct file permissions, the user will get 'Permission denied'.
The file's group owner is not root.
The file's read permission is not granted to the root group.
The user needs to be added to the root group again.
Want more Manage users and groups practice?
Practice this domainA server's firewall is managed by firewalld. The admin adds a rule to allow HTTPS traffic to the public zone, but clients still cannot connect. What is the most likely cause?
The rule was added with --permanent but firewall-cmd --reload was not run.
Permanent rules do not affect runtime until reload.
The rule must be added as a rich rule, not a simple service.
The default zone is not set to public.
firewalld is just a wrapper for iptables, so iptables rules must be cleared.
After configuring sudo, a user reports: 'sudo: unable to open /etc/sudoers: Permission denied'. The admin checks the file permissions and sees '-rw-r-----' owned by root:root. What is the most likely cause?
The file is owned by the wrong user.
The sudo binary is missing the setuid bit.
The file permissions are too permissive (0640 instead of 0440).
Sudo requires /etc/sudoers to be owned by root:root and have mode 0440 (read-only for owner and group). A mode of 0640 grants write permission to root, which sudo considers unsafe because it suggests the file was modified manually outside visudo's validation; sudo then refuses to open it for policy parsing and reports an error. Changing the mode back to 0440 with `chmod 0440 /etc/sudoers` resolves the issue. The message may explicitly say 'sudo: /etc/sudoers is mode 0640, should be 0440'.
SELinux is blocking access.
A server uses firewalld with the default zone set to 'drop'. SSH is allowed only for the 192.168.1.0/24 subnet via a rich rule in the 'internal' zone. After a reboot, SSH connections from that subnet are refused. What is the most likely cause?
The subnet 192.168.1.0/24 is not a valid source for rich rules.
The network interface is not assigned to the 'internal' zone.
This is the root cause. firewalld applies zones to traffic based on the ingress interface or source address; if the interface is not permanently assigned to the `internal` zone, it remains in the default zone, which here is `drop` and thus silently discards all incoming packets. The rich rule lives in `internal`, but without the interface assigned there, the rule never sees the SSH traffic. You must run `firewall-cmd --permanent --zone=internal --change-interface=eth0` (then `--reload`) to make the assignment persistent across reboots.
The rich rule was not made permanent.
The SSH service is not enabled in the default zone.
Which command sets the password maximum age for user 'bob' to 30 days?
chage -M 30 bob
chage -M 30 bob is the standard command for configuring password aging in RHCSA environments, setting the maximum password age to exactly 30 days. This writes to the fifth field of bob's /etc/shadow entry, after which the password will expire and require change. It is the direct equivalent of passwd -x, but is more commonly seen in scripts and documentation.
passwd -x 30 bob
passwd -x 30 bob is a valid, albeit less commonly used, way to set the password's maximum age on Red Hat systems. The -x option directly controls the maximum number of days a password may be used before the user is forced to change it, and it writes the same shadow field as chage -M. Running it as root is required, and the change takes effect immediately for bob.
usermod -e 30 bob
chage -W 30 bob
A file has been assigned an incorrect SELinux context, preventing a service from accessing it. Which command restores the default SELinux context for that file?
restorecon
restorecon resets a file's SELinux context to the policy-defined default by consulting the file_contexts rules, typically with `restorecon -v /path/to/file`. It is the correct tool when a file's context has become incorrect because it determines the intended context from the policy rather than relying on a manually specified value, and it only changes files whose current context does not match the default.
chcon
fixfiles
setfiles
A systems administrator needs to list all currently defined firewall rules in firewalld, including rules for all zones. Which TWO commands can be used to accomplish this? (Choose exactly two.)
firewall-cmd --list-all-zones
Correct. This command displays the full configuration for all zones, including rules for each zone.
iptables -L
systemctl status firewalld
firewall-cmd --get-default-zone
firewall-cmd --list-all
Want more Manage security practice?
Practice this domainAn administrator is tasked with deploying a containerized application on a Red Hat Enterprise Linux 8 server that is part of a high-security environment. The application must run as a non-root user inside the container. The container image is based on Red Hat Universal Base Image (UBI) and exposes port 443 for HTTPS. The administrator needs to ensure that the container can be restarted automatically if it crashes and that the application logs are persisted on the host in /var/log/app. The application requires a configuration file that is generated dynamically at startup and must be accessible to the container. The administrator has created a systemd service file for the container but wants to use Podman's built-in features to manage the container. Which approach meets all requirements?
Create a systemd service file using 'podman generate systemd' on a running container, then enable the service with 'systemctl enable --now container-myapp'. The container should be started with '--restart=always' and appropriate volume and port mappings.
Create a 'podman service' unit using 'podman service create' to manage the container with automatic restart and boot-start.
Run the container with 'podman run --restart=always -v /var/log/app:/var/log -p 443:443 myapp' and rely on the container's restart policy.
The '--restart=always' policy only works if the Podman process is running; it does not survive a system reboot without systemd.
Use 'podman create --restart=on-failure -v /var/log/app:/var/log -p 443:443 myapp' and then start it with 'podman start'.
A container named 'web1' was created and ran briefly before exiting with status 0. The administrator needs to restart it and attach to the running container's console. Which command should be used?
podman run --name web1 -it registry.access.redhat.com/ubi8/httpd-24
podman start web1
podman restart web1 && podman attach web1
podman start web1 && podman attach web1
This combination first uses podman start web1 to take the existing stopped container and transition it to the running state, preserving its filesystem and configuration. Then podman attach web1 connects your terminal to the container's primary process' STDIN and STDOUT, giving you the same interactive console session that existed when it was originally run. This is the correct lifecycle sequence for resuming an existing interactive container without recreating it.
A user wants to run a container that will restart automatically unless explicitly stopped by the administrator. Which podman run option should be used?
--restart=on-failure
--restart=always
--restart=unless-stopped
--restart=unless-stopped is correct because it ensures the container is automatically restarted whenever it exits, for any reason, with one crucial exception: if an administrator explicitly issues 'docker stop', the container will not be restarted by the policy until it is manually started again. Docker distinguishes between a container that stopped on its own and one that was intentionally stopped, so this matches the requirement exactly. It also survives daemon restarts and host reboots, making it a robust production choice.
--restart=no
A team wants to run a container as a non-root user inside the container for security. Which instruction should be included in the Containerfile?
USER
The USER instruction is the standard Containerfile directive that sets the active user for subsequent instructions, including the final CMD/ENTRYPOINT runtime process. By specifying a non-root user or numeric UID (e.g., USER 1000), the container runs with least privilege. This is the only option here that directly changes the identity of the running container process.
PODMAN_USER
ENV USER
RUN useradd
Based on the exhibit, which command should be used to start the container named 'mycontainer'?
podman attach mycontainer
podman restart mycontainer
podman run mycontainer
podman start mycontainer
podman start is correct because it changes an existing, stopped container from the Exited state to the Running state without creating a new container or pulling an image. It resumes the container's configured entrypoint, command, and environment, making it the exact tool needed for the situation shown in the exhibit.
A system administrator wants to run a container as a systemd service that restarts automatically after a system reboot. Which approach follows Red Hat best practices?
Create a cron job that checks if the container is running and starts it if not.
Create a sysvinit script that calls podman commands.
Add 'podman run ...' to /etc/rc.local.
Use 'podman generate systemd --new --name mycontainer' and enable the generated service.
podman generate systemd --new --name mycontainer generates a complete systemd service unit that records the exact podman command, container ID, and environment required to create and start the container fresh on every invocation of the service. Placing this unit in /etc/systemd/system and enabling it with systemctl enable --now makes systemd the supervisor: it sets up dependencies such as After=network-online.target, can apply Restart=on-failure, and will tear down the container cleanly on service stop. This is the intended way to manage a container's lifecycle as a systemd service.
Want more Manage containers practice?
Practice this domain11% of exam · 6 sample questions below
A system administrator needs to create a shell script that checks if the user 'jdoe' exists in the system and, if not, creates the user with a home directory. The script should also verify that the creation was successful. Which of the following script snippets correctly implements this logic?
if grep -q '^jdoe:' /etc/passwd; then echo 'Exists'; else useradd 'jdoe' && echo 'Created'; fi
if id 'jdoe' &>/dev/null; then echo 'Exists'; else useradd -m 'jdoe' && echo 'Created' || echo 'Failed'; fi
Correctly checks existence, creates with home dir, and verifies.
if ! id 'jdoe' &>/dev/null; then useradd -m 'jdoe'; else echo 'Exists'; fi
[ -z $(id 'jdoe' 2>/dev/null) ] && useradd -m 'jdoe' && echo 'Created'
A developer wrote a shell script that is intended to back up log files by copying all .log files from /var/log/myapp to /backup/logs. The script runs daily via cron but the backup folder is empty. The script contains the following line: `cp /var/log/myapp/*.log /backup/logs/`. What is the most likely reason the backup fails?
The PATH variable in cron is not set, so cp cannot be found.
The script does not have execute permission for the user running cron.
No .log files exist in /var/log/myapp at the time of script execution, causing the glob to match nothing.
In a non-interactive shell, an unmatched glob like /var/log/myapp/*.log is not expanded and is passed literally to cp. cp then attempts to copy a file named `*.log`, which does not exist, producing a 'No such file or directory' error and creating no backup. Unless the script checks the glob result or has error handling, this failure can be silent, especially if cron's stderr output is not inspected.
The cron job is not enabled because the crontab syntax is incorrect.
An administrator writes a script that uses the 'set -e' option at the top. What is the primary effect of this option?
It treats unset variables as an error
It prints each command before execution
It enables debug mode with verbose output
It exits the script immediately if a command fails
This is the exact purpose of `set -e`, also known as `errexit`. When enabled, the shell immediately exits if any simple command, pipeline, or compound command (outside of contexts like `if`, `while`, `until`, `!`, or `&&`/`||` left operands) returns a non-zero status. This halts the script at the first error rather than continuing with unchecked failures.
A system administrator needs to create a shell script that processes a list of hostnames stored in a file, one per line, and runs a command on each host. Which loop construct is most appropriate?
while read host; do ... done < hosts
The `while read host; do ... done < hosts` construct is the correct approach because it reads the file line by line. On each iteration, `read` assigns the entire line (minus trailing newline) to the variable `host`, so the content is not subjected to word splitting or pathname expansion. This makes it robust for hostnames that might contain unusual characters, though for exact preservation one should add `IFS=` and `-r` to `read`. Additionally, the redirection `< hosts` attaches the file to the loop's standard input, and the loop runs in the current shell, so any variable updates inside the loop remain available afterward.
for i in $(seq 1 $(wc -l < hosts)); do ... done
for host in $(cat hosts); do ... done
until read host; do ... done < hosts
A developer wants to create a script that accepts a directory path as an argument and creates a timestamped backup of that directory. If no argument is provided, it should back up the current directory. How should the script handle the argument?
dir=${1:-.}
The parameter expansion `${1:-.}` explicitly targets the first positional parameter (`$1`) and applies the `:-` operator: if `$1` is unset or null, the expansion substitutes the literal `.` (the current directory). This precisely fulfills the requirement to accept a directory argument with a sensible default when no argument is supplied, because `$1` is the first argument passed to the script, and the default value is only used when that argument is missing or empty.
dir=${@:-.}
dir=${0:-.}
dir=${?:-.}
An administrator writes a script to check disk usage and send an alert if usage exceeds 80%. The script uses 'df -h /' and parses the output. To maintain portability and avoid common pitfalls, which approach is recommended?
Use 'df -h / | tail -1 | sed 's/.* //' | tr -d '%'
Use 'df -h / | tail -1 | cut -d' ' -f5'
Use 'df / | awk 'NR==2 {print $5}' | tr -d '%'
This option uses `df /` without `-h`, which produces a stable, machine-parseable output. The `awk` command extracts the fifth field (the percentage used) and `tr` removes the percent sign. This is portable across different Unix/Linux systems.
Use 'df -h / | grep -oP '\d+%'
Want more Create simple shell scripts practice?
Practice this domainA developer needs to search for the string 'ERROR' in all files under /var/log, but wants to exclude files ending with '.gz'. Which command is correct?
grep -r --exclude='*.gz' 'ERROR' /var/log
The -r flag makes grep recursively descend into /var/log and all of its subdirectories, while --exclude='*.gz' instructs grep to skip any file whose basename matches that glob, thereby avoiding compressed log files. This precisely implements the requested search: only uncompressed files under /var/log are examined for the string 'ERROR'. Using -r rather than the similar -R is also safer because -r does not dereference symbolic links, keeping the search confined to the named directory tree.
grep -R --exclude='*.gz' 'ERROR' /var/log
grep -l 'ERROR' /var/log/*.gz
grep -v '*.gz' -r 'ERROR' /var/log
Which TWO commands can be used to display the current date and time in a format like '2023-10-05 14:30:00'?
date '+%Y-%m-%d %H:%M:%S'
Formats date as required.
cal
timedatectl
date -Iseconds
hwclock
During boot, a server fails to mount an NFS filesystem listed in /etc/fstab. Which troubleshooting step should be taken first to isolate the issue?
Check the status of remote-fs.target with 'systemctl status remote-fs.target'
Checking 'systemctl status remote-fs.target' is the correct first step because systemd uses this target to synchronize the activation of all remote filesystem mounts, including NFS, during the boot sequence. If the target is in a 'failed' or 'degraded' state, the status output will directly show which mount unit failed and why, allowing you to then inspect that specific unit's logs or configuration rather than guessing. This target is explicitly ordered after network-online.target and pulls in the mount units, so its state is the authoritative indicator of whether boot-time NFS mounting was attempted and completed.
Check the status of nfs-client.target with 'systemctl status nfs-client.target'
Try to manually mount the NFS share with 'mount /mnt/nfs'
View kernel messages with 'dmesg | grep -i nfs'
A script needs to be run at system boot for a specific user. Which method ensures the script runs with that user's environment?
Place the script in /etc/rc.d/rc.local
Add an entry to ~/.xprofile
Create a systemd user unit in ~/.config/systemd/user/
A systemd user unit placed in ~/.config/systemd/user/ is managed by the per-user systemd manager and runs in the user's own runtime context, with access to the user's environment, PATH, and systemd user D-Bus. To have it launch at boot rather than only after login, the user must be enabled for lingering (loginctl enable-linger username), after which the user manager starts automatically at boot. This makes it the correct choice for boot-time per-user scripts.
Add the script to the user's crontab with @reboot
Refer to the exhibit. What does the file permission -rw------- indicate about /etc/shadow?
Root user can read, write, and execute; group and others have no access.
Owner can read and write; group can read; others can read.
Owner can read; group can read; others cannot access.
Only root user can read and write; others have no access.
The permission string begins with a hyphen indicating a regular file, followed by 'rw-' for the owner, which is root (or the file's owning user). The subsequent '---' for group and '---' for others show those classes have zero access, so only the owner can read and write (and not execute). This matches typical root-owned file permissions.
Refer to the exhibit. The backup script runs every 5 minutes but generates errors. What is the most likely cause?
The script is owned by root.
The cron daemon is not running.
The script uses absolute paths.
The script is not executable.
This is the cause. The exhibit shows the script has permissions 644, meaning there is no execute bit set for the owner, group, or others. When cron encounters a script path in a crontab, it invokes that file directly via execve(), which requires at least one execute bit; otherwise the kernel returns EACCES and the job logs 'Permission denied' or sends a non-zero exit status. The file must be made executable, for example with 'chmod +x', for cron to run it successfully.
Want more Essential Tools practice?
Practice this domainThe EX200 exam is performance-based — there are no multiple-choice questions. It is a hands-on lab exam completed within 180 minutes. You complete practical tasks in a live or simulated environment. Courseiva practice questions cover the underlying concepts.
Hands-on Linux administration tasks completed in a live RHEL environment.
The exam covers 9 domains: Operate running systems, Configure local storage, Create and configure file systems, Deploy, configure, and maintain systems, Manage users and groups, Manage security, Manage containers, Create simple shell scripts, Essential Tools. Questions are weighted by domain — higher-weight domains appear more on your actual exam.
No. These are original exam-style practice questions written against the official Red Hat EX200 exam objectives. They are not copied from the real exam. Courseiva focuses on genuine understanding, not memorisation of braindumps.
Courseiva tracks your accuracy per domain and routes you toward weak areas automatically. Free, no account required.