RHCSA Prep 1 Flashcards
Configure YUM repos with the given link (2 repos: 1st is Base and 2nd is AppStream )
Base_url= http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
AppStream_url= http://content.example.com/rhel8.0/x86_64/dvd/AppStream
- vim /etc/yum.repos.d/local.repo
[BaseOS]
name=yum repository local
baseurl=http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
gpgcheck=0
enabled=1
[AppStream]
name=yum repository local
baseurl=http://content.example.com/rhel8.0/x86_64/dvd/AppStream
gpgcheck=0
enabled=1
#yum update
yum repolist enabled
Debug SELinux:
* A web server running on non standard port 82 is having issues serving content. Debug and fix the issues.
* The web server on your system can server all the existing HTML files from
/var/www/html ( NOTE: Do not make any changes to these files )
* Web service should automatically start at boot time.
semanage fcontext -a -t httpd_sys_content_t “/var/www/html(/.*)?”
# restorecon -Rv /var/www/html
# semanage port -l | grep http
# semanage port -a -t http_port_t -p tcp 82
#firewall-cmd –permanent –add-port=82/tcp
#firewall-cmd –reload
Create User accounts with supplementary group.
* Create the group a named “sysadms”.
* Create users as named “natasha” and “harry”, will be the supplementary group “sysadms”.
* Create a user as named “sarah”, should have non-interactive shell and it should be not the member of “sysadms”.
* Password for all users should be “trootent”
groupadd sysadms
#groups sysadms
#useradd -G sysadms harry
#useradd -G sysadms natasha
#id harry
#id nathasa
#useradd -s /sbin/nologin sarah
#id sarah
#passwd sarah
#passwd harry
#passwd natasha
#cat /etc/passwd
Configure a cron job that runs every 1 minutes and executes:
logger “EX200 in progress” as the user natasha.
Su – natasha
Crontab -e
*/2 * * * * logger “Ex200 in progress”
Create a collaborative Directory.
* Create the Directory "/home/manager" with the following characteristics. * Group ownership of "/home/manager" should go to "sysadms" group. * The directory should have full permission for all members of "sysadms" group but not to the other users except "root". * Files created in future under "/home/manager" should get the same group ownership .
mkdir /home/manager
#chown :sysadms /home/manager
#chmod 2770 /home/manager
#ls -ld /home/manager
Configure NTP
* Synchronize time of your system with the server classroom.example.com.
Answers
# yum install -y chrony
# vi /etc/chrony.conf : server classroom.example.com iburst
# timedatectl set-ntp true
# systemctl restart chronyd
#chronyc sources -v
Configure AutoFS
* All Ldapuser2 home directory is exported via NFS, which is available on classroom.example.com (172.25.254.254) and your NFS-exports directory is /home/guests for Ldapuser2, * Ldapuser2's home directory is classroom.example.com:/home/guests/ldapuse2 * Ldapuser2's home directory should be automount autofs service. * Home directories must be writable by their users. * while you are able to log in as any of the user ldapuser1 through ldapuser20, the only home directory that is accessible from your system is ldapsuser2
yum install -y autofs
# vi /etc/auto.master.d/home.autofs : (/home/guests /etc/auto.home)
# vi /etc/auto.home (* -rw,sync,fstype=nfs4 classroom.example.com:/home/guests/&)
# systemctl enable autofs.service
# systemctl start autofs.service
#ssh ldapuser5@localhost
#cd
#pwd # it should be /home/guests/ldapuser2
ACL.
* Copy the file /etc/fstab to /var/tmp/fstab and configure the “ACL” as mentioned following.
* The file /var/tmp/fstab should be owned by the “root”.
* The file /var/tmp/fstab should belong to the group “root”.
* The file /var/tmp/fstab should not be executable by any one.
* The user “sarah” should be able to read and write to the file.
* The user “harry” can neither read nor write to the file.
* Other users (future and current) should be able to read /var/tmp/fstab.
cp /etc/fstab /var/tmp/fstab
#ls -al /var/tmp/fstab
#setfacl -m u:sarah:rw- /var/tmp/fstab
#setfacl -m u:harry:— /var/tmp/fstab
#setfacl -m o:r– /var/tmp/fstab
# in order to check if everything is ok
getfacl /var/tmp/fstab
Create user ‘bob’ with 2112 uid and set the password ‘trootent’
useradd -u 2112 bob
# passwd bob (trootent)
# id bob
Locate all files owned by user “harry” and copy it under /root/harry-files
find / -user harry -exec cp -rfp {} /root/harry-files/ \; 2/dev/null
Find a string ‘ich’ from “/usr/share/dict/words” and put it into /root/lines file.
grep “ich” /usr/share/dict/words > /root/line_file
create an archive ‘/root/backup.tar.bz2’ of /usr/local directory and compress it with bzip2.
tar cfv /root/backup.tar.bz2 /usr/local
Reset root user password and make it ‘trootent’
press e for starting system
* put in last last of linuz16 : rd.break
* press ctrl + x
# mount -o remount,rw /sysroot
#chroot /sysroot
#passwd root
#touch /.autorelabel
#exit
Configure YUM Repos
*Base_url= “http://content.example.com/rhel8.0/x86_64/dvd/BaseOS”
*AppStrem_url= “http://content.example.com/rhel8.0/x86_64/dvd/AppStream”
scp -r /etc/yum.repos.d/local.repo root@node2:/etc/yum.repos.d/
# cat /etc/yum.repos.d/local.repo
# yum repolist enabled
# yum update
# yum install -y vdo
- Resize the logical volume “mylv” so that after reboot the size should be in between 200MB
to 300MB.
df -h
#vgdisplay
#lvextend -L 300M /dev/myvg/mylv
#lvdisplay /dev/myvg/mylv
#resize2fs /dev/myvg/mylv
Add a swap partition of 512MB and mount it permanently.
fdisk /dev/vdb
n (create new partition:)
p (check Partition table)
Enter
+512M
t
82
w
mkswap /dev/vdb2
Copy UUID
vim /etc/fstab UUID=XXXXX swap swap defaults 0 0
systemctl daemon-reload
swapon -a
(swapon -s)
- Create the logical volume with the name “wshare” by using 60PE’s from the volume group “wgroup”.
- Consider each PE size of the volume group as “16 MB”.
- Mount it on /mnt/wshare with file system ext3S
fdisk /dev/vdb
n (create new partition:)
p (check Partition table)
3
Enter
+960M
w
partprobe
pvcreate /dev/vdb3
vgcreate -s 16MB wgroup /dev/vdb3
lvcreate -n wshare -l 60 wgroup
mkfs.ext3 /dev/wgroup/wshare
mkdir /mnt/wshare
vi /etc/fstab (/dev/wgroup/wshare /mnt/wshare ext3 defaults 0 0)
mount -a
Create a new VDO partition using to following requirements:
* Use the unpartitioned disk
* Vdo name “Vdo1” and logical size should be 50GB
* Mount it on /vdomount permanently with file system xfs.
yum -y install vdo kmod-kvdo
* #systemctl enable vdo.service * #systemctl start vdo.service * #lsblk #vdo create –name=Vdo1 --device=/dev/vdd --vdoLogicalSize=50G #mkfs.xfs -K /dev/mapper/Vdo1 #lsblk ---output=UUID /dev/mapper/Vdo1 #mkdir /vdomount #vi /etc/fstab (UUID=………………….. /vdomount xfs defaults, x-systemd.requires=vdo.service 0 0) #systemctl daemon-reload
Choose the recommended ‘tuned’ profile for your system and set it as the default.
tuned-adm active
#tuned-adm recommend (virtual-guest)
#tuned-adm profile virtual-guest
Create a container logserver from an image rsyslog in node1 From
registry.lab.example.com
* Configure the container with systemd services by an existing user “Walhalla”,
* Service name should be container-logserver, and configure it to start automatically across reboot.
useradd user1 # passwd user1
# yum module install container* -y # ll /var/log/
# vim /etc/systemd/journald.conf [Journal]
Storage=persistent
:wq!
/run/log
# systemctl restart systemd-journald # ll /run/log
# ll /var/log/
# su - user1
# mkdir /home/wallah/container-logserver/
# mkdir /var/log/journal
# exit
# cp -r /var/log/journal/ /home/user1/container-logserver/ # chown -R user1:user1 /home/user1/container-logserver/ # systemctl restart systemd-journald
# reboot
after bootup do ssh to user1 and continue:
# ssh user1@servera.lab.example.com
Configure your host journal to store all journal across reboot
* Copy all *.journal from /var/log/journal and all subdirectories to
/home/Walhalla/container_logserver
* Configure automount /var/log/journal from logserver (container) to
/home/walhalla/container_logserver when container starts. node1:user1 steps
podman login regisrty.redhat.io # username:
# password:
# podman search rsyslog
# podman pull registry.redhat.io/rhel8/rsyslog # podman image list
# podman run -d –name logserver -v /home/user1/container-logserver:/var/log/journal:Z registry.redhat.io/rhel8/rsyslog
# podman container list # podman ps
# mkdir -p ~/.config/systemd/user
# cd .config/systemd/user/ # loginctl enable-linger
# loginctl show-user user1
# podman generate systemd –name logserver -f -n # systemctl –user daemon-reload
‘in this step, we went to host and one time we rebooted it’
# systemctl –user enable –now container-logserver.service # systemctl –user start –now container-logserver.service
# systemctl –user status –now container-logserver.service
# podman exec -it logserver /bin/bash # ls /var/log/
# exit