0% found this document useful (0 votes)
143 views9 pages

RHCSA Practice Questions & Solutions Guide

Rhcsa topicwise sample questions
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
143 views9 pages

RHCSA Practice Questions & Solutions Guide

Rhcsa topicwise sample questions
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

RHCSA Topic-Wise Practice Questions with

Solutions (Expanded with Firewall)


This is a detailed topic-wise practice guide with questions, solutions, and additional exercises for
RHCSA preparation. Includes expanded SELinux and firewalld tasks.

1. Essential Tools & Basic Commands


Questions & Solutions

1. Create and compress files:

mkdir -p /tmp/testdir && cd /tmp/testdir


touch file{1..5}
tar -czvf [Link] file*

2. Find files owned by root modified in last 7 days:

find /etc -user root -mtime -7

3. Display lines 10-20 from /etc/passwd:

sed -n '10,20p' /etc/passwd

4. Search 'sudo' in /var/log/secure and count occurrences:

grep -c sudo /var/log/secure

5. Display first column of /etc/fstab:

awk '{print $1}' /etc/fstab

Extra Practice: Find large log files:

find /var/log -type f -size +50M

1
2. User & Group Administration
Questions & Solutions

1. Create user with custom UID and shell:

useradd -u 2025 -s /bin/bash -c "Developer" devuser

2. Create group and add user:

groupadd devops
usermod -aG devops devuser

3. Set password expiry and force reset:

echo "Password123" | passwd --stdin devuser


chage -M 30 devuser
chage -d 0 devuser

4. Lock a user account:

passwd -l testuser

5. Create SGID collaborative directory:

mkdir /shared
chown :devops /shared
chmod 2775 /shared

Extra Practice: Remove user from secondary group:

gpasswd -d devuser devops

3. File Permissions & ACL


Questions & Solutions

1. Give ACL to user john:

2
setfacl -m u:john:rw /project/[Link]

2. Remove write for others and make file immutable:

chmod o-w /test/file1


chattr +i /test/file1

3. Set default ACL for group devops:

setfacl -m d:g:devops:rw /project

Extra Practice: Remove all ACLs:

setfacl -b /project

4. Storage Management (Partitions, LVM,


Mounts)
Questions & Solutions

1. Create partition and format:

parted /dev/sdb mklabel gpt


parted /dev/sdb mkpart primary xfs 1MiB 501MiB
[Link] /dev/sdb1

2. Create VG, LV, format, mount and persist:

pvcreate /dev/sdb1
vgcreate vg_data /dev/sdb1
lvcreate -L 1G -n lv_logs vg_data
mkfs.ext4 /dev/vg_data/lv_logs
mkdir -p /mnt/logs
echo "$(blkid -o value -s UUID /dev/vg_data/lv_logs) /mnt/logs ext4
defaults 0 0" >> /etc/fstab
mount -a

3. Extend LV safely:

3
lvextend -L +500M /dev/vg_data/lv_logs
resize2fs /dev/vg_data/lv_logs

Extra Practice: Reduce LV size safely:

umount /mnt/logs
e2fsck -f /dev/vg_data/lv_logs
resize2fs /dev/vg_data/lv_logs 800M
lvreduce -L 800M /dev/vg_data/lv_logs
mount -a

5. Networking
Questions & Solutions

1. Configure static IP:

nmcli con mod ens33 [Link] [Link]/24


nmcli con mod ens33 [Link] [Link]
nmcli con mod ens33 [Link] "[Link]"
nmcli con mod ens33 [Link] manual
nmcli con up ens33

2. Verify configuration:

ip a
ping -c 4 [Link]

Extra Practice: Add secondary DNS:

nmcli con mod ens33 [Link] "[Link] [Link]"


nmcli con up ens33

6. Firewalld & SELinux (Expanded)


Firewalld Questions & Solutions

1. Open port 8080/tcp permanently:

4
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --reload

2. Add HTTP service permanently:

firewall-cmd --permanent --add-service=http


firewall-cmd --reload

3. List all active zones:

firewall-cmd --get-active-zones

4. Add interface ens33 to public zone:

firewall-cmd --zone=public --change-interface=ens33 --permanent


firewall-cmd --reload

5. Block an IP address:

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source


address="[Link]" reject'
firewall-cmd --reload

6. Allow a service only temporarily:

firewall-cmd --add-service=ssh --timeout=5m

7. Enable masquerading for NAT:

firewall-cmd --permanent --add-masquerade


firewall-cmd --reload

Extra Practice: Remove a rule and verify:

firewall-cmd --permanent --remove-port=8080/tcp


firewall-cmd --reload
firewall-cmd --list-all

5
SELinux Questions & Solutions

1. Check SELinux mode:

getenforce
sestatus

2. Change SELinux context for /webdata:

semanage fcontext -a -t httpd_sys_content_t "/webdata(/.*)?"


restorecon -Rv /webdata

3. Enable a boolean permanently (allow httpd network connection):

setsebool -P httpd_can_network_connect on

4. List SELinux booleans:

getsebool -a

5. Analyze denial and generate custom policy:

audit2allow -a -M mypolicy
semodule -i [Link]

6. Restore default contexts for directory:

restorecon -Rv /var/www/html

Extra Practice: Switch SELinux to permissive mode temporarily:

setenforce 0

Make it permanent (edit /etc/selinux/config and set SELINUX=permissive ).

6
7. Process Management & System Monitoring
Questions & Solutions

1. Find and kill high CPU process:

top # find PID


kill -9 <PID>

2. Change process priority:

renice -n -5 -p <PID>

Extra Practice: Show top memory processes:

ps aux --sort=-%mem | head -n 11

8. Software Management (YUM/DNF, Flatpak)


Questions & Solutions

1. Configure local repo:

cat > /etc/[Link].d/[Link] <<EOF


[local]
name=LocalRepo
baseurl=[Link]
enabled=1
gpgcheck=0
EOF

dnf clean all dnf repolist

2. **Install httpd:**
```bash
dnf install httpd -y

2. List flatpak remotes and install app:

7
flatpak remotes
flatpak install flathub [Link]

9. System Boot & Troubleshooting


Questions & Solutions

1. Set default target:

systemctl set-default [Link]

2. Reset root password:

mount -o remount,rw /sysroot


chroot /sysroot
passwd root
touch /.autorelabel
exit
reboot

Extra Practice: Rebuild initramfs:

dracut -f

10. Containers (Podman)


Questions & Solutions

1. Create and run container:

podman run -d --name testctr -p 8080:80 [Link]/ubi9/


ubi

2. Commit container:

podman commit testctr myimage:v1

8
Extra Practice: Auto-start container:

podman generate systemd --name testctr --files --new


mv [Link] /etc/systemd/system/
systemctl enable --now container-testctr

Would you like me to include firewalld zone diagrams (trusted, public, internal) and example
topologies for better visualization and memory retention?

Common questions

Powered by AI

Blocking an IP address using `firewall-cmd` involves adding a rich rule with the `reject` action, such as `firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.50" reject'`. It's crucial to ensure the rule does not conflict with existing policies that might unintentionally block legitimate traffic. After adding such rules permanently, it's necessary to reload the firewall with `firewall-cmd --reload` and verify the rule using `firewall-cmd --list-all` to ensure it's correctly applied and active within the intended zone .

SELinux enhances security by enforcing mandatory access controls, constraining processes to operate within defined roles, types, and booleans, such as permitting network connections through booleans like `httpd_can_network_connect`. It effectively contains threats within defined boundaries. However, challenges include complexity in policy management, compatibility issues with existing applications requiring specific contexts, and the potential for configuration errors that may disrupt services if policies aren't meticulously maintained and customized to the environment .

SGID (Set Group ID) on a directory ensures that files created within inherit the directory’s group rather than the user's default group. This is particularly significant for collaborative environments since all users working within an SGID directory like `/shared`, created with `chmod 2775`, will have group ownership aligned, facilitating shared access and management of files. This enhances workflow efficiency and security by maintaining consistent group permissions across newly created files without requiring manual group reassignment .

`audit2allow` complements SELinux troubleshooting by parsing audit logs to extract denial events and generate corresponding policy modules, thus allowing administrators to adjust policies based on logged access violations. It integrates seamlessly with standard audit infrastructure to provide an automated way to trial and subsequently refine security policies. This integration reduces manual policy adjustments and expedites problem resolution by directly translating logged incidents into actionable policy changes, thereby enhancing the upkeep of security while minimizing downtime .

`audit2allow` helps system administrators create custom SELinux policies by analyzing denial logs and generating modules to allow denied operations. This tool reads denial messages from audit logs and translates them into policy statements, which can be compiled and loaded using `semodule`. This significantly aids administrators in troubleshooting and resolving access issues quickly by providing a systematic way to update SELinux policies without manually writing complex policy statements, thus maintaining security while adapting to application needs .

The `setfacl` command allows the modification of ACLs (Access Control Lists) on files, which provides more granular permission settings beyond the traditional owner-group-others model. This is beneficial in collaborative environments where users other than the file owner need specific permissions. For example, using `setfacl -m u:john:rw /project/data.txt` grants read-write access to the user 'john' that can coexist alongside the default permissions. This fine-grained control enhances flexibility and security in managing file access .

ACLs provide a more detailed permission scheme than traditional UNIX file permissions, allowing permission granularity per user or group beyond the basic owner-group-others model. This flexibility enhances security by granting specific permissions without altering group membership or file ownership, reducing the risk of privilege escalation. However, this complexity can increase administrative overhead, as ACLs require careful management to ensure consistency and security, particularly in large environments. The trade-off between granular control and management complexity must be well-considered .

Configuring a static IP using `nmcli` involves setting the IP address, gateway, and DNS with commands like `nmcli con mod ens33 ipv4.addresses 192.168.1.100/24`, and bringing the connection up with `nmcli con up ens33`. This method is preferred over manual editing of network configuration files due to its interactive nature, ability to apply changes without directly modifying files, and integration with the NetworkManager, which handles network changes more gracefully and reduces errors associated with manual file edits .

LVM provides a layer of abstraction over physical storage, allowing volumes to be easily resized. To extend a logical volume, commands like `lvextend -L +500M /dev/vg_data/lv_logs` followed by `resize2fs /dev/vg_data/lv_logs` dynamically increase the space without data loss. For reducing volumes safely, it's necessary to unmount the file system, check it with `e2fsck`, resize it with `resize2fs`, and then reduce the volume size with `lvreduce -L 800M /dev/vg_data/lv_logs`. This flexibility aids in dynamically managing storage as needs change .

Generating systemd services from Podman containers using the command `podman generate systemd --name testctr --files --new` allows containers to be managed as system services. This integration benefits orchestration by enabling automatic start-up, better system-level management through standard service controls, and improved lifecycle management. It ensures that containers start at boot and can be controlled through familiar systemd mechanisms, thereby enhancing reliability and consistency in container deployment across system reboots .

You might also like