RHEL9 Last Version
RHEL9 Last Version
- Node1.example.com
Q1: Configure TCP/IP and “Hostname” as following.
Hostname: node1.domain.example.com
IP Address: 192.168.71.240
Netmask: 255.255.255.0
Gateway: 192.168.71.2
DNS: 192.168.71.2
Answer:
[[email protected]]# hostnamectl set-hostname node1.domain.example.com
[[email protected]]# nmcli con show >> (ens160)
[[email protected]]# nmcli con mod ens160 ipv4 192.168.71.240/24 ipv4.gateway
192.168.71.2 ipv4.dns 192.168.71.2
Answer:
[[email protected]]# vi /etc/yum.repos.d/yum.repo
[Server-1]
name=baseos
baseurl=http://content.example.com/rhel9/x86_64/dvd/BaseOS
enabled=1
gpgcheck=0
[Server-2]
name=appstream
baseurl=http://content.example.com/rhel9/x86_64/dvd/AppStream
enabled=1
gpgcheck=0
:wq!
Verification:
[[email protected]]# yum clean all
[[email protected]]# yum update
[[email protected]]# yum repolist
Q3: Debug SELinux:
Web server running on non-standard port “82” is having issues serving content,
Debug and fix the issues.
- The web server can serve all the existing HTML files from ‘/var/www/html’,
Don’t make any changes to these files.
- Web service should automatically start at boot time.
Answer:
Check if SELinux is enforced.
[[email protected]]# getenforce
Enforcing
httpd should be installed by default but you can check using ( #rpm -qa | grep httpd )
Check firewalld
[[email protected]]# firewall-cmd --list-all
Ports: 82/tcp
If 82/tcp is not shown at port field, then you will need to add manually
[[email protected]]# firewall-cmd --permanent --add-service=http
[[email protected]]# firewall-cmd --permanent --add-port=82/tcp
[[email protected]]# firewall-cmd --reload
Check SELinux:
[[email protected]]# semanage port -l | grep “http”
http_port_t tcp 80,81,443,488,8008,8009,8443,9000
Verification:
o Open on Firefox browser, on the address-bar and type:
hostname:82 >> node1.domain.example.com:82
On this page you should see: This is my web server.
Verification:
[[email protected]]# cat /etc/passwd
harry:x:1001:1002::/home/harry:/bin/bash
natasha:x:1002:1003::/home/natasha:/bin/bash
sarah:x:1003:1004::/home/sarah:/sbin/nologin
Answer:
[[email protected]]# crontab -e -u natasha
23 14 * * * echo “Ex200 is processing.”
*/1 * * * * echo “Ex200 is processing.”
Verification
[[email protected]]# tail -f /var/log/cron
Answer:
[[email protected]]# mkdir /home/admin
[[email protected]]# chgrp adminuser /home/admin
[[email protected]]# chmod 2770 /home/admin
Verification
[[email protected]]# cd /home/admin
[[email protected]]# touch file1
[[email protected]]# mkdir dir1
Q7: Create user ‘alex’ with 3456 uid and set password to “centtered”.
Answer:
[[email protected]]# useradd -u 3456 alex
[[email protected]]# passwd alex
Q8: Locate all the files owned by user “natasha” and copy them under
/root/locatedfiles.
Answer:
[[email protected]]# mkdir /root/locatedfiles
[[email protected]]# find / -user natasha -type f -exec cp -rvp {} /root/locatedfiles \;
Q9: Find a string ‘strato’ from /usr/share/dict/words and put it into /root/lines
file.
Answer:
[[email protected]]# cat /usr/share/dict/words | grep strato > /root/lines
Answer:
[[email protected]]# tar -cvf /root/backup.tar /usr/local
[[email protected]]# bzip2 /root/backup.tar
Verification:
[[email protected]]# ls -l
Verification:
[[email protected]]# ls -l
Q12: Create a container for alth user
• Use this link: http://domain.exam.com/rhel9/Containerfile build image named monitor.
• Don’t change anything in Container file.
Answer:
[[email protected]]# ssh alth@localhost
[[email protected]]# wget http://domain.exam.com/rhel9/Containerfile
[[email protected]]# podman build -t monitor -f Containerfile
Answer:
[root@node1~]# mkdir /opt/files /opt/processed
[root@node1~]# chown alth:alth /opt/files /opt/processed
[root@node1~]# ssh alth@localhost
[alth@node1~]# loginctl enable-linger
[alth @node1~]# podman run -d --name ascii2pdf -v /opt/files:/opt/incoming:z -v
/opt/processed:/opt/outgoing:z monitor
[alth @node1~]# podman ps (verification step)
[alth @node1~]# mkdir -p .config/systemd/user
[alth @node1~]# cd .config/systemd/user
[alth @node1]# podman generate systemd --name ascii2pdf --files --new
[alth @node1]# systemctl --user daemon-reload
[alth @node1]# systemctl --user start container-ascii2pdf.services
[alth @node1]# systemctl --user enable container-ascii2pdf.services
[alth @node1]# exit
[root@node1~]# touch /opt/files/testfile (it should appear as pdf in /opt/processed)
Answer:
[[email protected]]# vi /usr/local/bin/myscript.sh
#!/bin/bash
find /usr -size -10M -type f -perm -2000 -exec ls -ltr {} \; > /root/script
Verification:
[[email protected]]# chronyc sources -v
Verification:
[[email protected]]# su - natsha
[[email protected]]# umask
277
[[email protected]]# cd /home/natasha
[[email protected]]# mkdir dir1
[[email protected]]# touch file1
[[email protected]]# ls -l
- Q: C:
[[email protected]]# vi /etc/login.defs
PASS_MAX_DAYS 20
:wq!
- Q: D:
[[email protected]]# visudo
Under this line: # %wheel ALL=(ALL) NOPASSWD: ALL
Put the following line: %adminuser ALL=(ALL) NOPASSWD: ALL
- Node2.example.com
Q17: Reset root password and make it “centtered”. <You should take care to
enter the GRUB mode of the Rescue part and not from the default part>
Answer:
1. Reboot the system.
2. Interrupt the boot-loader countdown by pressing any key, except Enter.
3. Move the cursor to the rescue kernel entry to boot (the one with the
word rescue in its name).
4. Press e to edit the selected entry.
5. Move the cursor to the kernel command line (the line that starts with
Linux).
6. Move with the right arrow from there until you find “ro” and replace it
with “rw init=/sysroot/bin/sh”
7. Hit ctrl + x
8. Hit enter when it asks for a password without typing any passwords
(exam environment only)
9. Chroot /sysroot
10.Passwd root
11.Touch /.autorelabel
12.Exit
13.Reboot
Q18: Configure your Red hat VM repository installed the packages distribution is
available via YUM:
1. BaseOS url= http://domain10.example.com/rhel9/x86_64/dvd/BaseOS
2. AppStream url=
http://domain10.example.com/rhel9/x86_64/dvd/AppStream
Answer:
[[email protected]]# cd /etc/yum.repos.d
[[email protected]]# vi yum.repo
[Server-1]
name=baseos
baseurl=http://domain10.example.com/rhel9/x86_64/dvd/BaseOS
enabled=1
gpgcheck=0
[Server-2]
name=appstream
baseurl=http://domain10.example.com/rhel9/x86_64/dvd/AppStream
enabled=1
gpgcheck=0
:wq!
Verification:
[[email protected]]# yum repolist
[[email protected]]# yum clean all
[[email protected]]# yum update
Q19: Resize the logical volume name lv to 300 MB. Make sure in lv volume have
some data, data should not be affected by resizing. Do not remove or modify
/etc/fstab
Answer:
[[email protected]]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv vg -wi-ao---- 76.00m
[[email protected]]# vgs
VG #PV #LV #SN Attr VSize VFree
vg 1 1 0 wz--n- 1020.00m 944.00m
[[email protected]]# lvdisplay
--- Logical volume ---
LV Path /dev/vg/lv
[[email protected]]# blkid
/dev/mapper/vg-lv: UUID="aee30843-e09c-4035-8214-a1be08be4b87" TYPE="ext4"
Verification:
[[email protected]]# df -h
[[email protected]]# lvs
[[email protected]]# lvdisplay
Q20: Add a swap partition of 715MB and mount it permanently.
Answer:
[[email protected]]# fdisk -l
[[email protected]]# fdisk /dev/vdb
p
m
n
enter
enter
enter
+715M
t
2
l
82
p
w
[[email protected]]# free -m
[[email protected]]# swapon -s
[[email protected]]# mkswap /dev/vdb2
[[email protected]]# vi /etc/fstab
/dev/vdb2 swap swap defaults 0 0
:wq!
[[email protected]]# mount -a
[[email protected]]# swapon -a
Verification:
[[email protected]]# free -m
[[email protected]]# swapon -s
[[email protected]]# init 6
[[email protected]]# free -m
[[email protected]]# swapon -s
Q21: Create a Logical Volume
- Create a logical volume “database” by using 50 PEs from the volume group
“datastore”.
- Consider that each PE size of volume group as “16MB”.
- Format with ext3 filesystem and mount permanently under /mnt/database
Answer:
Volume group size should be greater than 50 * 16 (800 MBs)
[[email protected]]# fdisk -l
[[email protected]]# fdisk /dev/vdb
m
n
enter
enter
enter
+1024M
p
t
3
l
8E
w
[[email protected]]# pvcreate /dev/sda3
[[email protected]]# vgcreate -s 16M datastore /dev/sda3
[[email protected]]# lvcreate -l 50 -n database datastore
[[email protected]]# mkdir /mnt/database2
[[email protected]]# mkfs.ext3 /dev/datastore/database
[[email protected]]# vi /etc/fstab
/dev/datastore/database /mnt/database ext3 defaults 00
:wq
[[email protected]]# mount -a
Verification:
[[email protected]]# df -h
[[email protected]]# init 6
[[email protected]]# df -h