RHCSA Version 9.
0 (Question&Answer)
Node 1
1.Network Configuration :
a) Assign Hostname and IP address for your virtual machine.
Hostname node1.lab.example.com
IP Address 172.25.250.10
Netmask 255.255.255.0
Gateway 172.25.250.254
Nameserver 172.25.250.254
Answer :
# nmcli connection show
# nmcli connection modify "Wired connection 1" ipv4.addresses 172.25.250.10/24
ipv4.gateway 172.25.250.254 ipv4.dns
172.25.254.254 ipv4.method manual
# nmcli connection up "Wired connection 1"
# nmcli connection show "Wired connection 1" |grep ipv4.
Hostname :
# hostnamectl set-hostname node1.lab.example.com
# hostname
2.Create repository :
http://content.example.com/rhel9.0/x86_64/dvd/BaseOS
http://content.example.com/rhel9.0/x86_64/dvd/AppStream Answer :
# cd /etc/yum.repos.d/
# vim one.repo
[BaseOS] name=BaseOS
baseurl=http://content.example.com/rhel9.0/x86_64/dvd/BaseOS
enabled=1
gpgcheck=0
[AppStream] name=AppStream
baseurl=http://content.example.com/rhel9.0/x86_64/dvd/AppStream
enabled=1
gpgcheck=0
Esc:wq
# yum clean all
# yum repolist
# yum install vim
3.Configure the Selinux in the node1,Apache running in the port number 82 ,
apache server not working properly check the logs and journal-ctl to resolve
a) /var/www/html can server the index files to the
apache server
b) Apache service should run when the server boot
Answer :
# yum install httpd
# systemctl status httpd
# systemctl enable httpd
# journalctl -xe
# man semanage-port
# semanage port -a -t http_port_t -p tcp 82
# systemctl restart httpd
# systemctl status httpd
# cd /var/www/html
# vi index.html
(welcome to apache!!)
#curl localhost:82
4.Create the following users, groups and group memberships:
a) A group named sysmgrp.
b) A user harry who belongs to sysmgrp as a secondary group.
c) A user natasha who belongs to sysmgrp as a secondary group.
d) A user sarah who does not have access to an interactive shell on the system
and who is not member of sysmgrp.
e) The users harry, natasha, sarah should all have password of belhacks Answer :
# groupadd sysmgrp
# useradd -G sysmgrp harry
# useradd -G sysmgrp natasha
# useradd -s /sbin/nologin sarah
# passwd --stdin harry
# passwd --stdin natasha
# passwd --stdin sarah
5. Create a collaborative directory /common/sysmgrp with the following
characterstics:
a) Group ownership of /common/sysmgrp is sysmgrp.
b) The directory should be readable,writable and accessible to members of sysmgrp,
but not to any other user :
(It is understood that root has access to all files and directories on the system.)
c) Files created in /common/sysmgrp automatically have group ownership set to
the sysmgrp group.
Answer :
# mkdir -p /common/sysmgrp
# chgrp sysmgrp /common/sysmgrp
# chmod 2770 /common/sysmgrp
# ls -ld /common/sysmgrp/
6.Configure autofs to auto mount the home directories of remote users Note
the following :
i) classroom.example.com (172.25.254.254) NFS - exports /rhome to yoursystem,
ii) remote user’s home directory should be auto mounted locally beneath /home as
/rhome
Example: remoteuser2 would configure the auto mount such that the home directory
/rhome/remoteuser2 gets mounted automatically upon login.
Answer :
# yum install autofs
# systemctl start autofs
# systemctl enable autofs
# vim /etc/auto.master
/rhome /etc/auto.misc
# vim /etc/auto.misc
remoteuser2 –rw classroom.example.com:/rhome/remoteuser2
# systemctl restart autofs
# mount -a
(only for exam)*
# su – remoteuser2
# pwd
6. Set a Cron job for harry on 12.30 at noon print /bin/echo on "HELLO HOW ARE
YOU".
Answer :
# crontab -eu harry
30 12 * * * /bin/echo "HELLO HOW ARE YOU"
Esc:wq
8. Configure the NTP
a) Configure your system so that it is an NTP client of classroom.example.com
Answer :
# chronyc sources
# vim /etc/chrony.conf
server classroom.example.com iburst
# systemctl restart chronyd
# chronyc sources -v
9. Locate the Files
a) Find the owner of the file sarah and copy the file to given path of /root/find.user
Answer :
# find / -user sarah -type f
# mkdir /root/find.user
# cp /var/spool/mail/sarah /root/find.user/
# cp /home/sarah/.bash_logout /root/find.user/
# cp /home/sarah/.bash-profile /root/find.user/
# cp /home/sarah/.bashrc /root/find.user/
# ls -la /root/find.user/
10. Find the string [Grep]
i) Find the string "ng" from /usr/share/dict/words copy all lines to file /root/files ii)
Find the sting “ich”from /usr/share/mime/packages/freedestop.ore.xml copy all lines
to file /root/files Answer :
# grep ng /usr/share/dict/words > /root/files
# grep ich /usr/share/mime/packages/freedesktop.ore.xml > /root/lines
# cat files
11. Create a user account [UID]
Create a new user with UID 1326 and user name as alies.
And set password as belhacks
Answer :
# useradd -u 1326 alies
# cat /etc/passwd (or) id alies
# passwd --stdin alies
12. Create an archive file
a) Create backup of /etc as /root/etc.tar.gz (or)
b) Create backup of /etc as /root/etc.tar.bz2 Answer
a) # tar -czvf /root/etc.tar.gz /etc
b) # yum install bzip2 -y
# tar -cjvf /root/etc.tar.bz2 /etc
13. Umask
a) All new creating files for user Natasha as –r-------- as default permission
b) All new creating Directories for user Natasha as dr-x------ as default permission
Answer:
# su – natasha
# ls –la
# vi .bash_profile
umask 277
:wq!
# logout
13. Assign Sudo Privilege
Assign the Sudo Privilege for Group "sysmgrp" and Group members can administrate
without any password
Answer :
# vim /etc/sudoers
%sysmgrp ALL=(ALL) NOPASSWD: ALL
13. Build a container as user student
* Build a container image using
http://content.example.com/mock/Con
tainerfile as a student user. Container
image name should be monitor.
* Do not modify the Containerfile
Answer :
# wget http://content.example.com/mock/Containerfile #
podman build -t monitor .
14. Configure the container as a system start-up service and mount volumes
persistently
a) Create the container name as ascii2pdf as student user
b) Run the container by using image monitor which one was already done in previous
c) Create the container as a system start-up service,while reboot it will automatically
start the service without any human intervention
d) The system service name should be container-ascii2pdf.
e) The local directory /opt/files should be persistently mount on container’s
/opt/incoming directory.
f) The local directory /opt/processed should be persistently mount on container’s
/opt/outgoing directory.
* Also ensure that container is running on the node1 even after system
reboot.
Answer :
(As root user)
#mkdir /opt/files
#mkdir /opt/processed
#chown student:student /opt/files
#chown student:student /opt/processed As
student user(take ssh):
# podman run -d --name ascii2pdf -v /opt/files:/opt/incoming:Z -v
/opt/processed:/opt/outgoing:Z monitor
# podman ps
# mkdir -p ~/.config/systemd/user
# cd ~/.config/systemd/user
# podman generate systemd --name ascii2pdf --files --new
# systemctl --user enable container-ascii2pdf
# loginctl enable-linger
# loginctl show-user student
Node 2
1. Assign root user password as belhacks.
Answer :
* open vm console node1 or node 2
* send key Ctrl+Alt+Del
* press 'e' to edit .......end of the line
* rd.break console=tty1
* press ctrl+x
# mount -o remount,rw /sysroot
# chroot /sysroot
# passwd --stdin root *
belhacks
# touch /.autorelabel
# exit
# exit
2.Create repository :
http://content/rhel9.0/x86_64/dvd/BaseOS
http://content/rhel9.0/x86_64/dvd/AppStream Answer :
# cd /etc/yum.repos.d/
# vim two.repo
[BaseOS] name=BaseOS
baseurl=http://content.example.com/rhel9.0/x86_64/dvd/BaseOS
enabled=1
gpgcheck=0
[AppStream]
name=AppStream
baseurl=http://content.example.com/rhel9.0/x86_64/dvd/AppStream
enabled=1
gpgcheck=0
# yum clean all
# yum repolist
3.Create a swap partition with 756MiB
Answer :
# fdisk -l
# fdisk /dev/vdb n (new) p
(primary) / e (extended) 2
(partition number)
First sector press ‘ Enter ’
Last sector press +756M t
(change type 19) p
(show) w (save)
# partprobe (for sync)
# mkswap /dev/vdb2
# blkid
Copy UUID
# vim /etc/fstab
<UUID> swap swap defaults 0 0 wq!
# mount -a
# swapon -a
# swapon -s
4.Create a Logical volume with following Criteria
Volume group name=qa
Logical volume name=qagroup
Note: The physical extends should be 16mib And the logical volume should be
50 extends
And mount the volume group to /lvmsample Directory. It should be a vfat
filesystem.
Answer :
# fdisk -l
# fdisk /dev/vdb n (new) p
(primary) / e (extended) 3
(partition number)
First sector press "Enter"
Last sector press +1G t
(change type 30) p
(show) w (save)
# udevadm settle
# pvcreate /dev/vdb3
# pvdisplay
# vgcreate -s 16M qa /dev/vdb3
# vgdisplay
# lvcreate -l 50 -n qagroup qa
# lvdisplay
# mkfs.vfat /dev/qa/qagroup
# blkid /dev/qa/qagroup
copy UUID
# vim /etc/fstab
<UUID> /lvmsample vfat defaults 0 0
# mkdir /lvmsample
# mount -a
# df –hT or lsblk
5. Resize your logical volume lv-ose to 230MiB
Answer :
# lvdisplay
# df -h
# lvextend -r -L 230M /dev/vg0/lv-ose
6. Set the recommend tuned profile for
your system.
Answer :
# yum install tuned
# systemctl start tuned
# systemctl enable tuned
# tuned-adm recommened
# tuned-adm profile virtual-guest
# tuned-adm active
# systemctl restart tuned
>> ALL THE BEST <<
1.Maximum days of password Expiry (minimum,warning age)
# vi /etc/login.defs
Max days:… Additional Questions:
Min days:…
Warn age:…
2. Configure a application name is “rhcsa”, when rhcsa run, at the time Pandora user
should have message as “borough satrato”
Ans:
(As root user)
#yum install podman *
# ssh Pandora@node1
# podman login registry.net1.example.com (as per exam registry)
Username:
Password:
#podman search registry .net1.example.com/
#podman run registry.net1.example.com/rhel.8/httpd-24
# mkdir rhcsa
#podman save –-format docker-dir registry.net1.example.com/rhel.8/httpd-24
-o rhcsa
# podman run dir:rhcsa echo “borough starato”
3. Create a script file as “newsearch” and the source of the file is /usr directory the file
size is +20K to -70K and copy the files in /root/output directory
Note: A script file should be placed in /usr/local/bin
Ans:
# vi /usr/local/bin/newsearch
[!/bin/bash
Find /usr –type f –size +20K –size -70K –exec cp {} /root/output \;]
#chmod +x /usr/local/bin/newsearch
#mkdir /root/output
# /. /usr/local/bin/newsearch
#cd /root/output
# ll –lh