RHCSA Exam Dump Paper

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

 This rhcsa dump paper contains 25 questions, that are divided as per nodes.

o Node-1 Contains -19 Questions


o Node-2 Contains - 6 Questions
-----------------------------------------------------------------------------------------------------------------------------------
❖ NODE-1 QUESTIONS

Question-1:
setup an IP address for the Primary virtual machine. IP address172.25.1.11 subnet mask 255.255.255.0 Default
gateway 172.25.1.254 nameserver172.25.254.254 and hostname as primary.net1.example.com

Answer-1:
# hostnamectl set-hostname “primary.net1.example.com”
# exec bash
-----------------------------------------------------------------------------------------------------------------------------------------
Question -2:
Yum repository configuration on both machines Node1 :
✓ AppStream : " https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/",
✓ BaseOS: “ https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/”

Answer-2:
# vim /etc/yum.repos.d/onlne.repo
[AppStream]
name=”AppStream repo”
gpgcheck=0
enabled=1
baseurl= https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/

[BaseOS]
name=”BaseOS repo”
gpgcheck=0
enabled=1
baseurl= https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/

# yum repoinfo
# yum repolist all
-----------------------------------------------------------------------------------------------------------------------------------------
Question -3:
HTTP service serve as a non-standard 82 port for your machine, the system is not able to connect to httpd service
at port 82, fix the debug issue, to store the HTML files under /var/www/html directory don’t have change to it. it
should be accessible at port 82 and should start at boot time.

Answer-3:
# rpm -q httpd
# yum install -y httpd
# firewall-cmd --permanent --add-port=82/tcp
# firewall-cmd --reload
# man semanage port
# semanage port -a -t http_port_t -p tcp 82
# cat /etc/httpd/conf/httpd.conf | grep “Listen ”
# systemctl enable --now httpd
# curl http://localhost:82
-----------------------------------------------------------------------------------------------------------------------------------------

Question -4 :
Configure a cron job on Primary machine. (a.) The user natasha must configure a cron job that runs daily at 14:23
local time and executes /bin/echo hiya.

Answer-4 :
# id natasha
# useradd natasha
# crontab -eu natasha
23 14 * * * /bin/echo “hiya”

# systemctl restart crond.service


# systemctl enable crond.service
# crontab -lu natasha
-----------------------------------------------------------------------------------------------------------------------------------------
Question -4.1 :
Configure a cron job on Primary machine. The user natasha must configure a cron job that runs every 3 minutes
and executes /usr/bin/logger “EX200 in progress.

Answer-4.1 :
# id natasha
# useradd natasha
# crontab -eu natasha
*/3 * * * * /usr/bin/logger “EX200 in progress”

# systemctl restart crond.service


# systemctl enable crond.service
# crontab -lu natasha
# tail -f /var/log/messages

-------------------------------------------------------------------------------------------------------------------------------------------
Question -5:
Create the following users, groups, and group memberships: - A group named sysadmin. A user natasha who
belongs to sysadmin as a secondary group. A user sarah who also belongs to sysadmin as a secondary group. A user
harry who does not have access to an interactive shell on the system, and who is not a member of sysadmin.
Natasha, Sarah and Harry should all have the password of thuctive.

Answer-5:
# groupadd sysadmin
# useradd natasha
# usermod -aG sysadmin natasha
# id natasha
# useradd sarah
# usermod -aG sysadmin sarah
# id sarah
# useradd -s /sbin/nologin harry
# passwd natasha
# passwd sarah
# passwd harry
# tail /etc/passwd | grep harry
# tail /etc/group | grep “sysadmin”
-----------------------------------------------------------------------------------------------------------------------------------------
Question -6:
Create a collaborative directory “/common/admin” with the following characteristics: Group ownership of
/common/admin is sysadmin. The directory should be readable, writable, and accessible to members of sysadmin,
but not to another user. (It is understood that root has access to all files and directories on the system.) Files created
in /common/admin automatically have group ownership set to the sysadmin group.

Answer-6 :
# mkdir -p /common/admin
# chgrp sysadmin /common/admin
# chown 2770 /common/admin
# touch /common/admin/sample_file
# ls -al /common/admin/
-----------------------------------------------------------------------------------------------------------------------------------------
Question -7:
Configure NTP in your system so that it is an NTP client of node1. your new NTP server is running on
"utility.domain0.example.com"

Answer-7:
# vim /etc/chrony.conf
#Comment the line no. 3 of starting with the pool.
#pool 2.rhel.pool.ntp.org iburst
server utility.domain0.example.com iburst

# systemctl restart chronyd.service


# systemctl enable chronyd.service
# timedatectl
# chronyc sources -v
-----------------------------------------------------------------------------------------------------------------------------------------
Question -8:
Find the files in your system which is owned by simone user & copy all the files on /root/found directory.

Answer-8:
# id simone
# mkdir -p /root/found
# find / -user simone -exec cp -arvf {} /root/found \;
# ls -al /root/found/
-----------------------------------------------------------------------------------------------------------------------------------------
Question -9:
Find the string strato from /usr/share/dict/words file and save the result in /searchfile.
Answer-9:
# grep “strato” /usr/share/dict/words > /searchfile
# cat /searchfile
-----------------------------------------------------------------------------------------------------------------------------------------
Question -10:
Using automounter service mount RemoteuserX onto the provided folder /home/RemoteuserX. (nfs server ip &
Domain name will provide you)

Answer-10:
# rpm -q autofs
# yum install -y autofs
# vim /etc/auto.master.d/abc.autofs

/- /etc/auto.misc

# vim /etc/auto.misc

/home/Remoteuserx -rw,soft,intr nfs-server-dns-or-ip:/home/Remoteuserx

# systemctl enable --now autofs


# su - Remoteuserx
-----------------------------------------------------------------------------------------------------------------------------------------

Question-11:
Write a script mysearch to list the contents of /usr that are below 10Mib,and sgid permission on it. The script should
be present in /usr/local/bin. After execution, the script should automatically write all the lines and save It to
/root/lines.

Answer-11:
# vim /usr/local/bin/mysearch

#!/bin/bash
find /usr -size -10M -perm /g=s > /root/lines

# chmod a+x /usr/local/bin/mysearch


# mysearch
# cat /root/lines
-----------------------------------------------------------------------------------------------------------------------------------------
Question-12:
Write a script mysearch to list the contents of /usr that are below 10Mib but more then 2Mib ,and suid permission
on it. The script should be present in /usr/local/bin. After execution, the script should automatically write all the
lines and save It to /root/lines.
Answer-12:
# vim /usr/local/bin/mysearch

#!/bin/bash
find /usr -size +2M -size -10M -perm /u=s > /root/lines

# chmod a+x /usr/local/bin/mysearch


# mysearch
# cat /root/lines
-----------------------------------------------------------------------------------------------------------------------------------------
Question -13:
Create a user barry User ID of this user should be 2112 and set password Atenorth.

Answer-13:
# useradd -u 2112 barry
# id barry
# password barry
-----------------------------------------------------------------------------------------------------------------------------------------
Question -14:
Set sudo privilege: a group name is 'elite', they have to give administrative permission without the password
"Atenorth".

Answer-14:
# cat /etc/group | grep “elite”
# visudo
%elite ALL=(ALL) NOPASSWD:ALL
-----------------------------------------------------------------------------------------------------------------------------------------
Question -15:
Set Permissions:
set default permissions for user Alex for all newly created files and folders
set permissions to the all newly created files r--r--r–
set permissions to all newly created directories r-xr-xr-x
Answer - 15
# id alex
# su - alex
$ echo "umask 222" >> ~/.bashrc
$ cat ~/.bashrc
$ exec bash
$ touch file
$ touch folder
$ ls -al
-----------------------------------------------------------------------------------------------------------------------------------------
Question-16:
Create a backup.tar.(bz2 or gz or xz) of /etc directory in /home location.
Answer-16:
# man tar
# tar -cJvf /home/backup.tar.xz /etc

# tar -cjvf /home/backup.tar.bz2 /etc

# tar -czvf /home/backup.tar.gz /etc

# ls -al /home
-----------------------------------------------------------------------------------------------------------------------------------------
Question-16.1:
Create a backup.tar.(bz2 or gz or xz) of /etc directory in /home location. Note: (Don’t use special compression
methods with tar -cvf)

Answer-16.1:
# man tar
# tar -cvf /home/backup.tar /etc
# xz /home/backup.tar
# bzip2 /home/backup.tar
# gzip /home/backup.tar
# yum whatprovides xz
# yum install -y xz
# ls -al /home

-----------------------------------------------------------------------------------------------------------------------------------------
Question-17:
Build an application ex200 that prints the message when user “aslan” logged in “Ntseeg Vajtswv hauv lub neej
txheej”.

Answer-17:
# id aslan
# man ex200
# vim .ex200/ex200.conf
Ntseeg Vajtswv hauv lub neej txheej
# su - aslan
aslan: ~$ ex200
-----------------------------------------------------------------------------------------------------------------------------------------
Question - 18:
Create a container on node1 as andrew user:-
Containerfile: https://raw.githubusercontent.com/sameer09694/Text-To-PDF/master/SingleContainerFile/Containerfile” .
And Build the container image name is watcher. Don't change the Containerfile content.
Answer-18:
# id andrew
# ssh andrew@localhost
$ hostname
$ whoami
$ wget https://raw.githubusercontent.com/sameer09694/Text-To-PDF/master/SingleContainerFile/Containerfile
$ ls -al
$ podman image build . -t watcher
$ podman image ls
-----------------------------------------------------------------------------------------------------------------------------------------
Question - 19:
Create a container using an image which you created somewhere in exam:
• create a container using andrew user and container name should be “merger”.
• container should run as a systemd service, so configure as a service name container-merger.service.
• container should run at boot time.
• container name should be merger.
• mount /opt/files directory to /opt/incoming in container and /opt/processes to /opt/outgoing in container
this container will convert ascii test file into pdf format, so when you create simple file in /opt/files then container
will automatically convert that file into pdf and save /opt/processed.

Answer-19:
# mkdir -p /opt/processes
# mkdir -p /opt/files
# chown andrew:andrew /opt/processes
# chown andrew:andrew /opt/files
# ssh andrew@localhost

$ podman container run -d --name=merger -v /opt/files:/opt/incoming:Z -v /opt/processes:/opt/outgoing:Z


watcher
$ podman ps
$ mkdir -p ~/.config/systemd/user/
$ cd ~/.config/systemd/user/
$ podman generate systemd --name merger --new --files
$ systemctl --user daemon-reload
$ systemctl --user start container-merger.service
$ systemctl --user enable container-merger.service
$ loginctl enable-linger
$ podman ps

-----------------------------------------------------------------------------------------------------------------------------------------
❖ NODE-2 QUESTIONS

Question -1:
First step is to crack password of Secondary Machine. Set password "Ventyol". (Note: Use Rescue kernel Mode )
Answer-1:
Stop booting process by "e" and then Find "linux16" line.
❖ Method-1 ❖ Method-2
At last of the line type "rd.break" and then press "Ctrl At last of the line type "rw init=/bin/bash" and then press "Ctrl
-x" -x"
mount -o remount,rw /sysroot passwd root
chroot /sysroot touch /.autorelabel
passwd root /sbin/reboot -f
touch /.autorelabel
exit
exit

-----------------------------------------------------------------------------------------------------------------------------------------
Question -2:
Yum repository configuration on machines Node 2 :
✓ AppStream : " https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/",
✓ BaseOS: “ https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/”

Answer-2:
# vim /etc/yum.repos.d/online.repo
[AppStream]
name=”AppStream repo”
gpgcheck=0
enabled=1
baseurl= https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/

[BaseOS]
name=”BaseOS repo”
gpgcheck=0
enabled=1
baseurl= https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/

# yum repoinfo
# yum repolist all
-------------------------------------------------------------------------------------------------------------------------------------------
Question -3:
Set a recommended tuning profile for your system. (Profile already available)

Answer-3:
# yum install tuned
# systemctl is-enabled tuned enabled
# tuned-adm list
# tuned-adm recommend
# tuned-adm profile <profile-name>
# tuned-adm active

-----------------------------------------------------------------------------------------------------------------------------------------
Question -4:
Create a SWAP partition of 250 megabytes and make it available at the next reboot. Partition already available.
(Note: Remember All partitions relation questions will be using single drive ex: /dev/sdb)
Answer- 4:
# lsblk
# fdisk /dev/sda
Press: “n”
Give Size of the volume with last sector: +250M
Press: “t”
Press “L”-------q → Swap=19
Press: “w”
# lsblk
# mkswap /dev/sda1
# vim /etc/fstab
/dev/sda1 none swap defaults 0 0
# mount -a
# free -h
# swapon -a
# free -h
-----------------------------------------------------------------------------------------------------------------------------------------
Question -5:
Create the volume group with name myvol with 8 MiB P.E. and create the lvm name mydatabase with the 100 P.E.
and format this lvm with vfat and create a directory /database and mount this lvm permanently on /database.

Answer- 5:
# lsblk
# fdisk /dev/sdb
Press: “n”
Give Size of the volume with last sector: +850M
Press: “t”
Press “L”---------q→ Linux lvm = 30
Press: “w”
# lsblk
# pvcreate /dev/sdb1
# pvdisplay
# vgcreate -s 8M myvol /dev/sdb1
# vgdisplay
# lvcreate -l 100 -n mydatabase myvol
# mkfs.vfat /dev/myvol/mydatabase
# mkdir /database

# vim /etc/fstab
/dev/myvol/mydatabase /database vfat defaults 0 0

# mount /database
# lsblk
# df -h
-----------------------------------------------------------------------------------------------------------------------------------------
Question -6:
Resize the lvm partition "home" to 150MiB. (A lvm partition named “home” given to you in the exam with vol
100MiB)

Answer-6:
# lsblk
# lvextend -r -L 150M home
# lsblk

You might also like