Free Red Hat EX200 RHCSA practice questions

10 free Red Hat EX200 RHCSA practice tasks with the correct answer and a full explanation for each, taken from the CertStash pack of 111 tasks. Work through them, then open each answer to check your reasoning.

Question 1

Show the case study this question is based on

SIMULATION

Configure your host name, IP address, gateway and DNS.

Host name: station.domain40.example.com

/etc/sysconfig/network hostname=abc.com hostname abc.com

IP Address: 172.24.40.40/24

Gateway: 172.24.40.1

DNS: 172.24.40.1

Completed Answer

Configure the host name, IP address, gateway, and DNS server for a Linux system.

Host Name configuration file → /etc/sysconfig/network

Host Name variable and value → HOSTNAME=station.domain40.example.com

Network interface configuration file → /etc/sysconfig/network-scripts/ifcfg-eth0

IP Address variable and value → IPADDR=172.24.40.40

Network prefix variable and value → PREFIX=24

Gateway variable and value → GATEWAY=172.24.40.1

DNS server variable and value → DNS1=172.24.40.1

How To Work It Out

1. The host name must be set in /etc/sysconfig/network file using the HOSTNAME variable with the full qualified domain name.

2. Network interface settings including IP address, gateway, and DNS are configured in the interface-specific file /etc/sysconfig/network-scripts/ifcfg-eth0.

3. The IP address 172.24.40.40 with subnet mask /24 (PREFIX=24) identifies the host on the network.

4. The gateway 172.24.40.1 provides the default route for traffic to other networks.

5. The DNS server 172.24.40.1 enables hostname resolution for the system.

Linux network configuration on RHEL/CentOS systems uses text files in /etc/sysconfig/. The hostname is stored separately in /etc/sysconfig/network, while interface-specific settings like IP address, gateway, and DNS are configured in /etc/sysconfig/networ-cripts/ifcfg-eth0. The configuration uses key-value pairs with specific variable names (HOSTNAME, IPADDR, PREFIX, GATEWAY, DNS1) that the network service reads to apply the settings. The IP address 172.24.40.40/24 represents the host address and network prefix, the gateway provides routing capability, and DNS1 specifies the nameserver for domain name resolution.

Exhibit for question 1

Exhibit for question 1

Show answer and explanation

Question 2

Show the case study this question is based on

SIMULATION

Create three users: harry, natasha, and tom, according to the following requirements: harry and natasha must have the admin group as a supplementary group; tom must have a non-interactive login shell.

Completed Answer

Add three users with specific group memberships and login shell configurations using command-line tools.

Command to add harry to admin group → useradd -G admin harry

Command to add natasha to admin group → useradd -G admin natasha

Command to add tom with non-interactive shell → useradd -s /sbin/nologin tom

Command to verify group membership → id harry;id natasha

Command to verify login shells → cat /etc/passwd

How To Work It Out

1. Harry and Natasha both need to be members of the admin group, so use the -G flag with the useradd command for each user.

2. Tom requires a non-interactive login shell to prevent direct login access, so specify /sbin/nologin with the -s flag.

3. Verify that harry and Natasha have been added to the admin group by running id commands to check their supplementary groups.

4. Confirm that tom's login shell is set to /sbin/nologin by examining the /etc/passwd file where login shells are defined.

This configuration correctly creates three users with their required attributes. The -G flag adds users to supplementary groups (harry and natasha to admin), while the -s flag sets the login shell for tom to /sbin/nologin, which is a non-interactive shell that prevents direct user login while allowing the account to function for service purposes. The verification commands confirm these settings were applied correctly by checking group membership through id and shell assignment through /etc/passwd.

Exhibit for question 2

Show answer and explanation

Question 3

SIMULATION

Create a directory named admins under /home. Its group must be the admin group. Group members must be able to read and write, while other users must not be able to access it. Files created in it by users of the same group must also belong to the admin group.

Completed Answer

Create a directory with specific permissions so the admin group can read and write, others cannot access it, and files inherit the admin group ownership.

Line 1 → cd /home/

Line 2 → mkdir admins

Line 3 → chown .admin admins/

Line 4 → chmod 770 admins/

Line 5 → chmod g+s admins/

How To Work It Out

1. Navigate to /home/ where the directory will be created.

2. Create the admins directory to serve as the catalog.

3. Change ownership to set the group to admin without changing the owner.

4. Set permissions to 770 so owner and group have full access (7) while others have no access (0).

5. Apply the setgid bit (g+s) so files created within inherit the directory's admin group instead of the creator's group.

The configuration establishes a shared directory owned by the admin group with rea-rite permissions only for the owner and group members (770). The setgid bit (g+s) is critical because it forces any files created within the directory to automatically inherit the admin group as their group owner, rather than defaulting to the creator's primary group. This ensures consistent group ownership for all content in the directory while preventing access from other users.

Exhibit for question 3

Show answer and explanation

Question 4

SIMULATION

Configure a scheduled task to run the echo hello command at 14:23 every day.

Completed Answer

Configure a cron job to execute the echo hello command every day at 14:23 (2:23 PM).

Line 1 → # which echo

Line 2 → # crontab -e

Line 3 → 23 14 * * * /bin/echo hello

Line 4 → # crontab -l (Verify)

How To Work It Out

1. First, verify the location of the echo command using which to ensure the correct path.

2. Open the crontab editor with crontab -e to create or modify the scheduled task.

3. Enter the cron expression with minute 23, hour 14 (24-hour format), and asterisks for day, month, and day-of-week to run daily at 14:23.

4. After saving, verify the cron job was created successfully by listing the crontab entries with crontab -l.

Cron uses a five-field format: minute hour day month day-of-week. To run a command at 14:23 every day, set the minute field to 23 and the hour field to 14 (in 24-hour format), with asterisks in the remaining fields to match every day of every month. The full path /bin/echo is used to ensure the correct executable is called. The crontab -e command opens the editor, and crontab -l verifies the job was saved correctly.

Exhibit for question 4

Exhibit for question 4

Show answer and explanation

Question 5

SIMULATION

Find all files owned by harry and copy them to the directory /opt/dir.

Completed Answer

Find all files owned by the user harry and copy them to the /opt/dir directory.

Line 1 → # cd /opt/

Line 2 → # mkdir dir

Line 3 → # find / -user harry -exec cp -rfp {} /opt/dir/ ;

How To Work It Out

1. Change to the /opt/ directory to establish the working location where the target directory will be created.

2. Create the destination directory called 'dir' inside /opt/ to prepare the location for copied files.

3. Use find command with -user harry to search the entire filesystem for files owned by harry, then use -exec with cp -rfp to recursively copy those files with preserved permissions to /opt/dir/.

The solution requires three sequential steps. First, navigate to /opt/ where the destination will be created. Second, create the 'dir' subdirectory to serve as the target location. Third, use find / -user harry to search all directories starting from root for files owned by the user harry. The -exec cp -rfp {} /opt/dir/ ; clause executes a copy command for each found file, where -r copies recursively, -f forces overwrite, and -p preserves file attributes. The {} placeholder represents each found file and the backslash-escaped semicolon terminates the -exec action.

Exhibit for question 5

Exhibit for question 5

Show answer and explanation

Question 6

SIMULATION

Find all lines containing the string abcde in the file /etc/testfile and write them to the file /tmp/testfile. The lines must appear in the same order as in /etc/testfile.

Completed Answer

Write a command to find all lines containing 'abcde' from /etc/testfile and write them to /tmp/testfile while preserving the original sequence.

Command to execute → grep 'abcde' /etc/testfile > /tmp/testfile

How To Work It Out

1. The task requires searching for lines containing the pattern 'abcde' in the source file /etc/testfile.

2. grep is the appropriate tool for pattern matching and line filtering.

3. The output must be written to /tmp/testfile, which requires output redirection using > (overwrite mode).

4. The > operator writes all matching lines to the destination file in the order they appear in the source, preserving sequence.

5. Using grep directly with output redirection is simpler and more efficient than piping through a while loop with tee.

The grep command searches for lines matching 'abcde' in /etc/testfile. The > redirection operator sends these matching lines to /tmp/testfile, creating or overwriting the file. This approach maintains the original sequence of matching lines from the source file. While the alternative approach using a while loop with tee -a would also work, the direct grep with redirection is the most straightforward and efficient solution for this task.

Exhibit for question 6

Show answer and explanation

Question 7

Show the case study this question is based on

SIMULATION

Create a 2G swap partition that activates automatically at boot, without affecting the existing swap partition.

Completed Answer

Create a new 2G swap partition that activates at boot without affecting the existing swap partition.

Disk to partition → /dev/sda

Command to view current partitions → p

Action to create new partition → n

Partition size specification → +2G

Command to change partition type → t

Command to list partition type codes → l

Command to write partition table → w

Command to notify kernel of partition changes → partx -a /dev/sda

Command to update partition table cache → partprobe

Command to format partition as swap → mkswap /dev/sda8

Command to activate swap partitions → swapon -a

File to edit for persistent swap activation → vim /etc/fstab

Entry to add in /etc/fstab → UUID=XXXXX swap swap defaults 0 0

How To Work It Out

1. Open fdisk on /dev/sda and display the partition table to see the current layout and identify where the new partition will be created.

2. Create a new partition with the n command and set its size to +2G.

3. Change the partition type to swap (hex code 82) using the t command, listing available types with l if needed.

4. Write the changes to disk using w to make the partition table permanent.

5. Notify the kernel of the new partition with partx and update the partition cache with partprobe.

6. Format the new partition as swap space with mkswap /dev/sda8.

7. Add a UUID-based entry to /etc/fstab to ensure the swap partition activates automatically at boot, then activate it immediately with swapon -a.

To create a persistent 2G swap partition that activates automatically at boot without affecting the original swap, you must first use fdisk to create the partition and change its type to swap (82). After writing the changes and notifying the kernel with partx and partprobe, format the partition with mkswap. Finally, add a UUID-referenced entry to /etc/fstab so the system automatically activates it at boot, and use swapon -a to activate it immediately. Using UUID instead of device name ensures the entry remains valid even if device naming changes.

Exhibit for question 7

Exhibit for question 7

Show answer and explanation

Question 8

SIMULATION

Create a user named alex with the user ID 1234 and the password alex111.

Completed Answer

Create a user named alex with user ID 1234 and set the password to alex111.

Command 1 → useradd -u 1234 alex

Command 2 → passwd alex

First password prompt response → alex111

Second password prompt response → alex111

How To Work It Out

1. Use useradd with the -u flag to specify the user ID 1234 and create the user named alex.

2. Execute passwd alex to enter the password change mode for the newly created user.

3. When prompted for the new password, type alex111.

4. When prompted to confirm the password, retype alex111 to verify it matches.

To create a user with a specific user ID in Linux, the useradd command with the -u option is required. The useradd -u 1234 alex command creates the user alex with UID 1234. The passwd command then allows setting the password interactively by prompting twice to confirm the password matches. Both prompts must receive alex111 for the password to be successfully set.

Exhibit for question 8

Show answer and explanation

Question 9

Show the case study this question is based on

SIMULATION

Install an FTP server and allow anonymous downloads from the /var/ftp/pub directory. (You must configure yum to point to the existing file server.)

Completed Answer

Install and configure a vsftpd FTP server with anonymous access enabled, using a local yum repository pointing to an existing file server.

Repository configuration file location → /etc/yum.repos.d

Repository file name → local.repo

Repository section header → [local]

Repository name parameter → name=local.repo

Repository base URL → baseurl=file:///mnt

Repository enabled setting → enabled=1

Repository GPG check setting → gpgcheck=0

First package installation command → yum install -y vsftpd vsftpd service startup command → systemctl restart vsftpd vsftpd boot enablement command → systemctl enable vsftpd vsftpd configuration file location → /etc/vsftpd/vsftpd.conf

Anonymous access configuration parameter → anonymous_enable=YES

How To Work It Out

1. Navigate to the yum repository directory and create a local repository configuration file pointing to the existing file server mounted at /mnt.

2. Configure the repository with proper metadata, enabling it while disabling GPG signature checks for a lab environment.

3. Cache the yum repository metadata to make packages available from the local source.

4. Install vsftpd using the configured local repository, then restart the service and enable it to start at boot.

5. Modify the vsftpd configuration file to permit anonymous FTP access as required for the /var/ftp/pub catalog.

This configuration establishes a yum repository pointing to an existing file server via the file:///mnt URL scheme, then uses it to install vsftpd. The FTP daemon is started and enabled for persistence across reboots. Finally, the vsftpd configuration is modified to enable anonymous access, allowing users to download files from the designated FTP public directory. This approach leverages an existing file server rather than configuring external network repositories, which is ideal for isolated lab environments.

Exhibit for question 9

Exhibit for question 9

Show answer and explanation

Question 10

Show the case study this question is based on

SIMULATION

Configure an HTTP server that is accessible at http://station.domain40.example.com. Download the page to be published from http://ip/dir/example.html.

Completed Answer

Configure an HTTP server accessible via http://station.domain40.example.com by installing httpd, downloading a page, and setting up a virtual host.

Package to install → httpd

Service startup configuration → systemctl enable –now httpd

Working directory → /var/www/html

File download command → wget http://ip/dir/example.html

Index file setup → cp example.html index.html

Configuration file location → /etc/httpd/conf/httpd.conf

Listen directive (already set) → no NameVirtualHost needed

VirtualHost address and port → 192.168.0.254:80

DocumentRoot path → /var/www/html/

ServerName value → station.domain40.example.com

How To Work It Out

1. Install the Apache HTTP server package (httpd) using yum with the -y flag to proceed automatically.

2. Enable httpd to start automatically on boot using systemctl enable –now httpd.

3. Navigate to the document root directory where web content will be served.

4. Download the example.html page from the specified remote location.

5. Copy the downloaded file and rename it to index.html to serve as the default page.

6. Edit the httpd configuration file to add virtual host directives.

7. Apache 2.4 needs no NameVirtualHost; just define the VirtualHost block.

8. Create a VirtualHost block matching the IP and port, with the correct domain name and document root path.

To configure a functional HTTP server accessible by domain name, you must first install and enable the httpd service for automatic startup. The downloaded content is placed in the standard document root (/var/www/html/) and renamed to index.html so it serves as the default page. The httpd.conf file is then edited to define a virtual host bound to the server's IP address on port 80, with the ServerName directive pointing to the fully qualified domain name station.domain40.example.com. This virtual host configuration allows the server to respond to requests for that specific domain while serving content from the designated document root directory.

Exhibit for question 10

Exhibit for question 10

Show answer and explanation

That was 10 of 111.

The full Red Hat EX200 RHCSA pack has all 111 tasks, each with the answer, the explanation and why the other options are wrong, plus a questions-only copy for timed runs. US$39, paid once, with free monthly updates and a pass-or-your-money-back guarantee.

Get the full pack