RHCSA Exam Questions & Answers
RHCSA Exam Questions & Answers
Lab setup:
● If we click on “exam view”, the exam question document will be displayed (make sure to read it)
● If we click on “vm monitor”, we see:
********Note: Network question needs to be done in the console and after that we need to perform a reboot (after the
network has been configured. We can use ssh root@hostname from the terminal)*********
NODE1 QUESTIONS
1. Configure the network. (enp0s8)
Assign hostname and ip address for your virtual machine.
Hostname - servera.lab.example.com
Ip address – 192.168.1.42
Netmask - 255.255.255.0
Gateway – 192.168.1.1
NameServer – 64.59.135.148
#hostnamectl set-hostname servera.lab.example.com
#nmcli connection show (Note ethernet type)
#nmcli connection modify "enp0s8" ipv4.addresses 192.168.1.42/24
#nmcli connection modify “enp0s8” ipv4.gateway 192.168.1.1
#nmcli connection modify “enp0s8” ipv4.dns 64.59.135.148
#nmcli connection modify “enp0s8” ipv4.method manual
#nmcli connection up "enp0s8"
#ping 192.168.1.42 (Do it from the other server. To check pinging with ip)
#ping 192.168.1.1 (To check ping with gateway)
#ping 64.59.135.148 (To check ping with DNS)
#hostnamectl
#reboot
2. Create a repository
http://classroom.example.com/rhel8.0/x86_64/dvd/AppStream
http://classroom.example.com/rhel8.0/x86_64/dvd/BaseOS
In console of node1 (we need to do this in the console because there is no ip or hostname assigned to take
remote connectivity)
#vi /etc/yum.repos.d/local.repo
[App]
name=AppStream
baseurl=http://classroom.example.com/rhel8.0/x86_64/dvd/AppStream
enabled=1
gpgcheck=0
[Base]
name=BaseOS
baseurl=http://classrom.example.com/rhel8.0/x86_64/dvd/AppStream
enabled=1
gpgcheck=0
#yum list
#yum repolist all (it lists the repositories)
#yum install httpd -y (if it won’t install, the issue may be in the repo file, or ip address setting, or dns, or gateway)
3. Configure SELinux
Your webcontent has been configured at port 82 in the /var/www/html directory
(Don't alter or remove any files in this directory)
Make the content accessable.
#yum install httpd -y // These first 3 steps are to set up the question
#vi /var/www/html/index.html // Hello World!
#vi /etc/httpd/conf/httpd.conf // Listen 82
#systemctl status httpd
#semanage port -l | grep http (check whether port 82 is enabled or if not, use the command below to add it)
#semanage port -a -t http_port_t -p tcp 82 (-a=add, -t= type, -p=protocol)
#semanage port -l | grep http (verify port 82 if it is added or not)
#systemctl enable httpd
#systemctl restart httpd
#firewall-cmd --permanent --add-port=82/tcp
#firewall-cmd --reload
#firewall-cmd --list-all (check port 82 is added or not)
#curl http://servera.lab.example.com:82
6. Configure autofs to automount the home directories of netuserX user. Note theFollowing:
netuserX home directory is exported via NFS, which is available on classroom.example.com(192.168.1.43)
and your NFS-exports directory is /netdir/netuserX for netuserX (use netuser5 for this)
netuserX's home directory is classroom.example.com:/home/guests/netuserX
netuserX's home directory should be automounted using autofs service.
home directories must be writable by their users
on server : change IP address in /etc/exports. Also “systemctl restart nfs-server”
# sudo yum install nfs-utils autofs -y
# showmount -e 192.168.1.43
# vim /etc/auto.master // /netdir /etc/auto.misc
# vim /etc/auto.misc // * -fstype=nfs,rw,sync 192.168.1.43:/home/guests/&
# systemctl enable autofs --now
# systemctl restart autofs
# su – netuser5
# cd /netdir
# cd netuser5
7. Set a Cron job for harry on 12.30 at noon print /bin/echo on "hello".
#crontab -e -u harry // 30 12 * * * /bin/echo “hello”
#crontab -l -u harry (-l=list, -u=user, -e=edit)
#cat /var/log/cron (it shows list of cronjobs)
#cat /etc/crontab (it shows how cronjob works)
10. Find the files owned by harry and copy them to /root/find.user
#mkdir -p /root/find.user
#find / -user harry -exec cp -rf {} /root/find.user \;
#ls -a /root/find.user
11. Create a new user with UID 1326 and user name as alies
#useradd -u 1326 alies
14. Create a container using an image that you created somewhere in the exam:
-Create a container with the user named harry, the container name should be ‘containerweb’
-Container should run as a systemd service, so configure it as a service named ‘container-web.service’
-Container should run at boot time.
-Container name should be ‘containerweb’
-Map ~/web directory to /usr/local/apache2/htdocs in the container
-Map port 8080 to port 80 in the container
-When you curl localhost:8080 it should read “This is my web page!”
# ssh harry@localhost
# mkdir ~/web
# vi ~/web/index.html // This is my web page!
# podman run -d --name containerweb -p 8080:80 -v ~/web:/usr/local/apache2/htdocs:Z localhost/web:v1
# podman ps -a
# loginctl show-user harry
# loginctl enable-linger harry
# mkdir -p ~/.config/systemd/user
# podman generate systemd containerweb > ~/.config/systemd/user/container-web.service
# podman stop containerweb
# systemctl --user daemon-reload
# systemctl --user enable container-web.service
# systemctl --user start container-web.service
# systemctl --user status container-web.service
# curl localhost:8080
# exit
# reboot
# curl localhost:8080 (to check if the container-web.service is running)
15.3 Assign the sudo privilege for users or groups to administrate without a password
#vim /etc/sudoers.d/admin // %admin ALL=(ALL) NOPASSWD: ALL A(A) N:A
#vim /etc/sudoers.d/harry // harry ALL=(ALL) NOPASSWD: ALL
NODE2 QUESTIONS
1. Set the root user password to break into the system
rd.break console=tty0 Press e on line with “linux”, add this at the end, and then do CTRL+X
#mount -o remount,rw /sysroot
#chroot /sysroot
#passwd root
#touch /.autorelabel
#exit
#exit
5. Create a vdo named VDO1 of logical size 50GB (actual size 5GB) on sdd, under volume
group VG1 and mount it at /vdo_m
# yum install lvm2 kmod-kvdo vdo // LKV
# lsblk // find disk to use
# su // elevate permissions
# pvcreate /dev/sdd // create physical volume
# vgcreate VG1 /dev/sdd // create volume group
# vgs // to verify
# lvcreate --type vdo --name VDO1 --size 5GB --virtualsize 50GB VG1
# lsblk // to verify
# mkfs.xfs -K /dev/VG1/VDO1
# mkdir /vdo_m
# vi /etc/fstab /dev/VG1/VDO1 /vdo_m xfs defaults 0 0
# mount -a // to verify
6. Configure Volumes
Create one logical volume engineering from a datastore volume group of size 30 Extents.
logical volume engineering from the datastore volume group extent should be 8MiB.
Format with ext3 file system and mount it permanently under /mnt/database (on /dev/sdb)
# lsblk
# fdisk -c /dev/sdb // p n p 2 Default +240m p t l 8e p w (240m = 240MiB)
# partprobe
# fdisk -l
# pvcreate /dev/sdb2
# pvs
# vgcreate -s 8MiB datastore /dev/sdb2
# vgs
# vgdisplay datastore
# lvcreate -l 30 -n engineering datastore
# lvs
# mkdir -p /mnt/database
# mkfs.ext3 /dev/datastore/engineering
# vim /etc/fstab // /dev/datastore/engineering /mnt/database ext3 defaults 0 0
# mount -a
# lsblk
BONUS QUESTION
1. Build an application called “rhcsa” that prints the message "Welcome to user ablerate"
when you’re logged in as the user "ablerate".
# useradd ablerate
# passwd ablerate
# vim /usr/local/bin/rhcsa
#!/bin/bash
echo "Welcome to user $LOGNAME"
# chmod 755 /usr/local/bin/rhcsa
# vim /home/ablerate/.bashrc
/usr/local/bin/rhcsa // add this somewhere in the file
# ssh ablerate@localhost