Preparation Set 4


Q1: Question-1:

  • Configure TCP/IP and "hostname" as following:
  • IP ADDRESS = 192.168.208.138
  • NETMASK = 255.255.255.0
  • GATEWAY = 192.168.208.2
  • DNS = 192.168.208.2
  • Hostname = serverX.example.com
[root@node1 ~]# hostnamectl set-hostname serverX.example.com
[root@node1 ~]# exec bash
 
[root@serverX ~]# nmcli conn modify serverAnet2 ifname ens160 type ethernet ipv4.method manual ipv4.address 192.168.208.138/24 ipv4.dns 192.168.208.2  ipv4.gateway 192.168.208.2

Q2:Configure your servera VM repository installed the packages distribution is available via YUM:

[root@serverX yum.repos.d]# pwd
/etc/yum.repos.d
 
[root@serverX yum.repos.d]# cat appstream.repo
[appstream]
name = appstream
baseurl = http://192.168.208.137/softwares/AppStream
enabled = 1
gpgcheck = 0
 
[root@serverX yum.repos.d]# cat baseos.repo
[baseos]
name = baseos
baseurl = http://192.168.208.137/softwares/BaseOS
enabled = 1
gpgcheck = 0
 
[root@serverX yum.repos.d]# yum list all

Q3: SELINUX PORT

  • In your system, httpd service has some files in /var/www/html (do not change or alter files)
  • solve the problem, httpd service of your system having some issues, service is not running on port 82.
[root@serverX ~]# systemctl status httpd
[root@serverX ~]# vim /etc/httpd/conf/httpd.conf
Listen 8200
# Copy the line from /etc/ssh/sshd_config
semanage port -a -t http_port_t -p tcp 8200
 
[root@serverX ~]# semanage port -l | grep 8200
http_port_t                    tcp      8200, 8000, 82, 7788, 5566, 80, 81, 443, 488, 8008, 8009, 8443, 9000
trivnet1_port_t                tcp      8200
trivnet1_port_t                udp      8200
 
[root@serverX ~]# netstat -tnl | grep 82
tcp6       0      0 :::82                   :::*                    LISTEN
 
[root@serverX ~]# firewall-cmd --permanent --add-port=8200/tcp
success
[root@serverX ~]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens160
  sources:
  services: cockpit dhcpv6-client http mountd nfs ntp rpc-bind ssh
  ports: 82/tcp
  protocols:
  forward: yes
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

Q4: Create the following users, groups and group memberships:

  • (a) A group named admin.
  • (b) A user harry who belongs to admin as a secondary group.
  • (c) A user natasha who belongs to admin as a secondary group.
  • (d) A user sarah who doesn’t have access to an interactive shell and who’s not a member of admin.
  • (e) The users harry, natasha, sarah should all have a password of “password”
[root@serverX ~]# groupadd admin
[root@serverX ~]# useradd harry -G admin
[root@serverX ~]# useradd natasha -G admin
[root@serverX ~]# useradd sarah -s /sbin/nologin
[root@serverX ~]# echo "password" | passwd --stdin harry
Changing password for user harry.
passwd: all authentication tokens updated successfully.
[root@serverX ~]# echo "password" | passwd --stdin natasha
Changing password for user natasha.
passwd: all authentication tokens updated successfully.
[root@serverX ~]# echo "password" | passwd --stdin sarah
Changing password for user sarah.
passwd: all authentication tokens updated successfully.

Q5. Create a collaborative directory /common/admin with the following characteristics:

  • (a) Group ownership of /common/admin is admin.
  • (b) The directory should be readable, writable and accessible to members of admin, but not any other user.
  • (It is understood that root has access to all files and directories on the system.)
  • (c) Files created in /common/admin will automatically have group ownership set to the admin group.
[root@serverX common]# chown :admin admin
[root@serverX common]# ls -lh
total 0
drwxr-xr-x. 2 root admin 6 Oct 11 13:07 admin
 
[root@serverX common]# chmod g+rwx admin
[root@serverX common]# ls -lh
total 0
drwxrwxr-x. 2 root admin 6 Oct 11 13:07 admin
 
[root@serverX common]# chmod o-rwx admin
[root@serverX common]# ls -lh
total 0
drwxrwx---. 2 root admin 6 Oct 11 13:07 admin
 
[root@serverX common]# chmod g+s admin
[root@serverX common]# ls -lh
total 0
drwxrws---. 2 root admin 6 Oct 11 13:07 admin

Q6: Configure autofs to automount the home directories of netuserX user. Note theFollowing:

  • netuser1,2,3,4,5 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”
[root@serverX ~]# rpm -q nfs-utils
nfs-utils-2.5.4-27.el9.aarch64
 
[root@serverX /]# vim /etc/auto.master
[root@serverX /]# cat /etc/auto.master
/netdir		/etc/auto.nfs		--timeout=300
 
[root@serverX /]# vim /etc/auto.nfs
[root@serverX /]# cat /etc/auto.nfs
*	-rw,sync	192.168.208.137:/home/guests/&
 
[netuser5@serverX netdir]$ systemctl status autofs
[netuser5@serverX netdir]$ systemctl restart autofs
 
[netuser5@serverX netdir]$ cd netuser5
[netuser5@serverX netuser5]$ ls
u51  u52

Q7: Set a Cron job for harry on 12.30 at noon print /bin/echo on "hello".

[root@serverX ~]# cat /etc/cron.allow
natasha
harry
 
[root@serverX ~]# su - harry
Last login: Fri Oct 11 14:51:21 CST 2024 on pts/1
[harry@serverX ~]$ crontab -e
no crontab for harry - using an empty one
crontab: installing new crontab
[harry@serverX ~]$ crontab -l
30      12      *       *       *       /bin/echo "hello"

Q8: Configure ACL permission copy the file /etc/f1 to /var/tmp. Configure the permission of /var/tmp/f1 so that:

  • (a)The file /var/tmp/f1 is owned by the root user
  • (b)The file /var/tmp/f1 belongs to the group root.
  • (c)The file /var/tmp/f1 should not be executable by anyone.
  • (d)The user harry is able to read and write on /var/tmp/f1.
  • (e)The user natasha can neither read nor write /var/tmp/f1.
  • (f)All other users (current/future) have the ability to read /var/tmp/f1
[root@serverX tmp]# chown root:root fstab
[root@serverX tmp]# ls -lh f1
-rwxrwxrwx. 1 root root 0 Oct 11 14:56 f1
 
[root@serverX tmp]# chmod u-x,g-x,o-x f1
[root@serverX tmp]# ls -lh f1
-rw-rw-rw-. 1 root root 0 Oct 11 14:56 f1
 
[root@serverX tmp]# setfacl -m u:harry:rw f1
[root@serverX tmp]# getfacl f1
# file: f1
# owner: root
# group: root
user::rw-
user:harry:rw-
group::rw-
mask::rw-
other::rw-
 
[root@serverX tmp]# setfacl -m u:natasha:--- f1
[root@serverX tmp]# getfacl f1
# file: f1
# owner: root
# group: root
user::rw-
user:harry:rw-
user:natasha:---
group::rw-
mask::rw-
other::rw-
 
[root@serverX tmp]# setfacl -m o:r-- f1
[root@serverX tmp]# getfacl f1
# file: f1
# owner: root
# group: root
user::rw-
user:harry:rw-
user:natasha:---
group::rw-
mask::rw-
other::r--

Q9: Configure your system so that it is an NTP pool of 2.centos.pool.ntp.org

[root@serverX ~]# rpm -q chrony
[root@serverX ~]# systemctl status chronyd.service
 
[root@serverX ~]# vim /etc/chrony.conf
server us.pool.ntp.org iburst
 
[root@serverX ~]# systemctl restart chronyd.service
[root@serverX ~]# timedatectl set-ntp true
 
[root@serverX ~]# timedatectl
               Local time: Fri 2024-10-11 15:09:00 CST
           Universal time: Fri 2024-10-11 07:09:00 UTC
                 RTC time: Fri 2024-10-11 07:09:00
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
[root@serverX ~]# chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* 155.248.196.28                2   6    17    25  -2353us[+2998us] +/-  175ms

Q10: Find the files owned by harry and copy them to /root/find.user

[root@serverX ~]# find / -type f -user harry -exec cp -rf {} /root/find.user \;

Q11: Create a new user with UID 1326 and user name as alies

[root@serverX ~]# useradd alies -u 1326
[root@serverX ~]# cat /etc/passwd | grep alies
alies:x:1326:1326::/home/alies:/bin/bash

Q12: Create an archive file - Backup the /var/tmp directory as /root/test.tar.gz

[root@serverX ~]# tar -zcvf /root/test.tar.gz /var/tmp

Q13: Build a container as harry

  • Use the URL docker.io/library/httpd to build the container image with the name “web”
  • Build it in ~/mycontainer. Do not modify the container file
[harry@serverX ~]$ rpm -q container-tools
container-tools-1-14.el9.noarch
 
[harry@serverX ~]$ vim .config/containers/registries.conf
[harry@serverX ~]$ cat .config/containers/registries.conf
unqualified-search-registries = ["docker.io"]
[[registry]]
insecure = false
blocked = false
location = "docker.io"
 
[root@serverX ~]# loginctl enable-linger harry
 
[harry@serverX ~]$ mkdir mycontainer
[harry@serverX mycontainer]$ pwd
/home/harry/mycontainer
 
# Download the Containerfile from this link 
[harry@serverX mycontainer]$ wget http://classroom.example.com/Containerfile
# Check the Containerfile 
[harry@serverX mycontainer]$ cat Containerfile
FROM docker.io/library/httpd
 
[harry@serverX mycontainer]$ podman build -t web .
 
[harry@serverX mycontainer]$ podman images
REPOSITORY               TAG         IMAGE ID      CREATED       SIZE
localhost/web            latest      a3e79aafef7f  2 months ago  182 MB
docker.io/library/httpd  latest      a3e79aafef7f  2 months ago  182 MB

Q14: 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’
  • 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!”
  • Container should run as a systemd service, so configure it as a service named ‘container-web.service’
  • Container should run at boot time.
[harry@serverX web]$ pwd
/home/harry/web
[harry@serverX web]$ cat index.html
<h1>This is a website !!</h1>
 
[harry@serverX mycontainer]$ podman run -d -v ~/web:/usr/local/apache2/htdocs:Z -p 8080:80 --name containerweb localhost/web:latest
d4a33b06973c4cf8d467f0c9cc36af0ad6f00661ab37f8a931995919334b7118
[harry@serverX mycontainer]$ podman ps -a
CONTAINER ID  IMAGE                 COMMAND           CREATED        STATUS        PORTS                         NAMES
d4a33b06973c  localhost/web:latest  httpd-foreground  5 seconds ago  Up 6 seconds  0.0.0.0:8080->80/tcp, 80/tcp  containerweb
 
# From root 
[root@serverX ~]# vim /etc/httpd/conf/httpd.conf
[root@serverX ~]# semanage port -a -t http_port_t -p tcp 8080
[root@serverX ~]# semanage port -l  | grep 8080
http_cache_port_t              tcp      8080, 8118, 8123, 10001-10010
http_port_t                    tcp      8080, 8200, 8000, 82, 7788, 5566, 80, 81, 443, 488, 8008, 8009, 8443, 9000
 
[harry@serverX user]$ pwd
/home/harry/.config/systemd/user
 
[harry@serverX user]$ podman generate systemd --name containerweb --files --new
[harry@serverX user]$ ls
container-containerweb.service
 
[harry@serverX user]$ podman stop containerweb
containerweb
 
[root@serverX ~]# ssh harry@192.168.208.138
 
[harry@serverX user]$ systemctl --user enable container-containerweb.service
Created symlink /home/harry/.config/systemd/user/default.target.wants/container-containerweb.service /home/harry/.config/systemd/user/container-containerweb.service.
[harry@serverX user]$ systemctl --user start container-containerweb.service
[harry@serverX user]$ podman ps -a
CONTAINER ID  IMAGE                 COMMAND           CREATED        STATUS        PORTS                         NAMES
bef34e67be4b  localhost/web:latest  httpd-foreground  3 seconds ago  Up 3 seconds  0.0.0.0:8080->80/tcp, 80/tcp  containerweb
 
 
[harry@serverX user]$ curl localhost:8080
<h1>This is a website !!</h1>
 
 
[harry@serverX ~]$ sudo firewall-cmd --permanent --add-service=http
success
[harry@serverX ~]$ sudo firewall-cmd --permanent --add-port=8080/tcp
success
[harry@serverX ~]$ sudo firewall-cmd --reload
 
# test from another server
[root@serverB guests]# curl 192.168.208.138:8080
<h1>This is a website !!</h1>

Q15: Set the permissions automatically for a user

  • All newly created files for user natasha should have -r-------- as the default permission.
  • All newly created directories for user natasha should have dr-x------ as the default permission.
[root@serverX natasha]# vim .bashrc
 
#~~~~~~~ Calculative Way ~~~~~~~~~
# DIr - 777 - 277 = 500 // 500 -> d r-x --- --- //
# Fil - 666 - 266 = 400 // 266 -> - r-- --- --- //
# Which to use : umask 277 or umask 266
# If umask 277 : dir ( - r-x --- ---  ) / file ( - r-- --- ---  ) :: Matched for both
# If umask 266 : dir ( - r-x --x --x  ) / file ( - r-- --- ---  ) :: Matched for both
 
#~~~~~~~ Simpler Way ~~~~~~~~~
# 666 - 400 = 266 files
# 777 - 500 = 277 folder
# Look at the higher value
 
umask 277

Q16: The password for all new users should expire after 20 days.

[root@serverX ~]# vim /etc/login.defs
PASS_MAX_DAYS   20

Q17: Assign the sudo privilege for users or groups to administrate without a password

[root@serverX ~]# visudo
harry   ALL=(ALL)       NOPASSWD: ALL
%sales  ALL=(ALL)       NOPASSWD: ALL

Q18: Create a script file: -if the paramater is “GM” it outputs “good morning” -- if it is “GN”, it outputs “good night”

[root@serverX script]# ./script1.sh GM
Good Morning
[root@serverX script]# ./script1.sh GN
Good Night
[root@serverX script]# ./script1.sh GD
No result
[root@serverX script]# cat ./script1.sh
 
if [ $1 == "GM" ]
then
	echo "Good Morning"
elif [ $1 == "GN" ]
then
	echo "Good Night"
else
	echo "No result"
fi

Q19: Set the root user password to break into the system

# Click e in rescue mode 
# add rd.break after quiet then press ctrl+x 
mount -o remount,rw /sysroot
chroot /sysroot 
passwd root 
touch /.autorelabel
exit
remount

Q20: Create a repository file

[root@serverX yum.repos.d]# cat appstream.repo
[appstream]
name = appstream
baseurl = http://192.168.208.137/softwares/AppStream
enabled = 1
gpgcheck = 0
[root@serverX yum.repos.d]# cat baseos.repo
[baseos]
name = baseos
baseurl = http://192.168.208.137/softwares/BaseOS
enabled = 1
gpgcheck = 0
[root@serverX yum.repos.d]# yum list all | less
# yum clean all
# yum makecache
[root@serverX yum.repos.d]# yum repolist all
Updating Subscription Management repositories.
Unable to read consumer identity
 
This system is not registered with an entitlement server. You can use subscription-manager to register.
 
repo id                                               repo name                                             status
appstream                                             appstream                                             enabled
baseos                                                baseos                                                enabled

Q21: Create a swap partition of 512MB at /dev/sdb

[root@serverX ~]# gdisk /dev/nvme0n3
 
Command (? for help): n
Partition number (3-128, default 3):
First sector (34-12582878, default = 7342080) or {+-}size{KMGTP}:
Last sector (7342080-12582878, default = 12582878) or {+-}size{KMGTP}: +512M
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): L
Type search string, or <Enter> to show all codes: swap
8200 Linux swap                          a502 FreeBSD swap
a582 Midnight BSD swap                   a901 NetBSD swap
bf02 Solaris swap
Hex code or GUID (L to show codes, Enter = 8300): 8200
Changed type of partition to 'Linux swap'
 
Command (? for help): p
Disk /dev/nvme0n3: 12582912 sectors, 6.0 GiB
Model: VMware Virtual NVMe Disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 84E0270F-9D78-4CBA-9023-AB303101E681
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 12582878
Partitions will be aligned on 2048-sector boundaries
Total free space is 4194237 sectors (2.0 GiB)
 
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   8200  Linux swap
   2         1050624         7342079   3.0 GiB     8E00  Linux LVM
   3         7342080         8390655   512.0 MiB   8200  Linux swap
 
Command (? for help): w
Do you want to proceed? (Y/N): y
The operation has completed successfully.
 
[root@serverX ~]# mkswap /dev/nvme0n3p3
[root@serverX ~]# vim /etc/fstab
[root@serverX ~]# tail -1 /etc/fstab
/dev/nvme0n3p3		swap		swap		defaults	0	0
 
[root@serverX ~]# systemctl daemon-reload
[root@serverX ~]# swapon -a
 
[root@serverX ~]# lsblk
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
...
nvme0n3           259:5    0    6G  0 disk
└─nvme0n3p3       259:11   0  512M  0 part [SWAP]
 
[root@serverX ~]# free -h
               total        used        free      shared  buff/cache   available
Mem:           3.5Gi       1.1Gi       1.9Gi        25Mi       764Mi       2.4Gi
Swap:          3.0Gi          0B       3.0Gi

Q22: Resize the logical volume "datastore-engineering" size to 20 extents.

[root@serverX ~]# gdisk /dev/nvme0n3
Command (? for help): n
Partition number (4-128, default 4):
First sector (34-12582878, default = 8390656) or {+-}size{KMGTP}:
Last sector (8390656-12582878, default = 12582878) or {+-}size{KMGTP}:
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): L
Type search string, or <Enter> to show all codes: lv
8e00 Linux LVM
Hex code or GUID (L to show codes, Enter = 8300): 8e00
Changed type of partition to 'Linux LVM'
 
Command (? for help): p
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   8200  Linux swap
   2         1050624         7342079   3.0 GiB     8E00  Linux LVM
   3         7342080         8390655   512.0 MiB   8200  Linux swap
   4         8390656        12582878   2.0 GiB     8E00  Linux LVM
 
Command (? for help): w
Do you want to proceed? (Y/N): y
The operation has completed successfully.
 
[root@serverX ~]# partprobe /dev/nvme0n3
 
[root@serverX ~]# pvcreate /dev/nvme0n3p4
  Physical volume "/dev/nvme0n3p4" successfully created.
[root@serverX ~]# pvs
  PV             VG     Fmt  Attr PSize  PFree
  /dev/nvme0n1p3 cs     lvm2 a--  18.41g     0
  /dev/nvme0n2   myvg   lvm2 a--  <5.00g <4.00g
  /dev/nvme0n3p2 wgroup lvm2 a--   2.98g  2.20g
  /dev/nvme0n3p4        lvm2 ---  <2.00g <2.00g
 
[root@serverX ~]# vgcreate -s 10 datastore /dev/nvme0n3p4
  Volume group "datastore" successfully created
[root@serverX ~]# vgs
  VG        #PV #LV #SN Attr   VSize  VFree
  cs          1   2   0 wz--n- 18.41g     0
  datastore   1   0   0 wz--n-  1.99g  1.99g
  myvg        1   1   0 wz--n- <5.00g <4.00g
  wgroup      1   1   0 wz--n-  2.98g  2.20g
 
[root@serverX ~]# lvcreate --name engineering -l 20 datastore
  Logical volume "engineering" created.
[root@serverX ~]# lvs
  LV          VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root        cs        -wi-ao----  16.41g
  swap        cs        -wi-ao----   2.00g
  engineering datastore -wi-a----- 200.00m
  mylv        myvg      -wi-a-----   1.00g
  wshare      wgroup    -wi-ao---- 800.00m
[root@serverX ~]# lvdisplay /dev/datastore/engineering
  --- Logical volume ---
  LV Path                /dev/datastore/engineering
  LV Name                engineering
  VG Name                datastore
  LV UUID                5ApWGI-aN0B-301A-2mNG-yos0-vF9a-zsJWBp
  LV Write Access        read/write
  LV Creation host, time serverX.example.com, 2024-10-12 09:25:33 +0800
  LV Status              available
  # open                 0
  LV Size                200.00 MiB
  Current LE             20
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4
 
[root@serverX ~]# lvextend -L +100M /dev/datastore/engineering
  Size of logical volume datastore/engineering changed from 200.00 MiB (20 extents) to 300.00 MiB (30 extents).
  Logical volume datastore/engineering successfully resized.
 
# Now we can perform the question's answer
[root@serverX ~]# lvs
  LV          VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root        cs        -wi-ao----  16.41g
  swap        cs        -wi-ao----   2.00g
  engineering datastore -wi-a----- 300.00m
  mylv        myvg      -wi-a-----   1.00g
  wshare      wgroup    -wi-ao---- 800.00m
 
[root@serverX ~]# lvreduce -l -10 /dev/datastore/engineering
  No file system found on /dev/datastore/engineering.
  Size of logical volume datastore/engineering changed from 300.00 MiB (30 extents) to 200.00 MiB (20 extents).
  Logical volume datastore/engineering successfully resized.
[root@serverX ~]#
[root@serverX ~]# lvs
  LV          VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root        cs        -wi-ao----  16.41g
  swap        cs        -wi-ao----   2.00g
  engineering datastore -wi-a----- 200.00m
  mylv        myvg      -wi-a-----   1.00g
  wshare      wgroup    -wi-ao---- 800.00m

Q23: Create a vdo named VDO1 of logical size 50GB (actual size 5GB) on sdd, under volume group VG1 and mount it at /vdo_m

[root@serverX ~]# vgs
  VG        #PV #LV #SN Attr   VSize  VFree
  VG1         3   2   0 wz--n- <5.48g 488.00m
  cs          1   2   0 wz--n- 18.41g      0
  datastore   1   1   0 wz--n-  1.99g  <1.70g
  myvg        1   1   0 wz--n- <5.00g  <4.00g
  wgroup      1   1   0 wz--n-  2.98g   2.20g
[root@serverX ~]# lvs
  LV          VG        Attr       LSize   Pool   Origin Data%  Meta%  Move Log Cpy%Sync Convert
  VDO1        VG1       vwi-a-v---  50.00g vpool0        0.00
  vpool0      VG1       dwi-------   5.00g               60.03
  root        cs        -wi-ao----  16.41g
  swap        cs        -wi-ao----   2.00g
  engineering datastore -wi-a----- 300.00m
  mylv        myvg      -wi-a-----   1.00g
  wshare      wgroup    -wi-ao---- 800.00m
 
 
[root@serverX ~]# lvcreate --type vdo -L 5G  --virtualsize 50G --name VDO1 VG1
    The VDO volume can address 2 GB in 1 data slab.
    It can grow to address at most 16 TB of physical storage in 8192 slabs.
    If a larger maximum size might be needed, use bigger slabs.
  Logical volume "VDO1" created.
[root@serverX ~]# lvs
  LV          VG        Attr       LSize   Pool   Origin Data%  Meta%  Move Log Cpy%Sync Convert
  VDO1        VG1       vwi-a-v---  50.00g vpool0        0.00
  vpool0      VG1       dwi-------   5.00g               60.03
  root        cs        -wi-ao----  16.41g
  swap        cs        -wi-ao----   2.00g
  engineering datastore -wi-a----- 300.00m
  mylv        myvg      -wi-a-----   1.00g
  wshare      wgroup    -wi-ao---- 800.00m
 
[root@serverX ~]# vim /etc/fstab
[root@serverX ~]# tail -1 /etc/fstab
/dev/VG1/VDO1		/vdo_m		xfs		defaults	0	0
 
[root@serverX ~]# mkfs -t xfs /dev/VG1/VDO1
meta-data=/dev/VG1/VDO1          isize=512    agcount=4, agsize=3276800 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=1 inobtcount=1 nrext64=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=16384, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Discarding blocks...Done.
 
[root@serverX ~]# systemctl daemon-reload
[root@serverX ~]# mount -a
[root@serverX ~]# lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
nvme0n4                   259:8    0    5G  0 disk
├─nvme0n4p1               259:13   0    1G  0 part
 └─VG1-vpool0_vdata      253:5    0    5G  0 lvm
   └─VG1-vpool0-vpool    253:6    0   50G  0 lvm
     └─VG1-VDO1          253:7    0   50G  0 lvm  /vdo_m
└─nvme0n4p2               259:16   0    4G  0 part
  └─VG1-vpool0_vdata      253:5    0    5G  0 lvm
    └─VG1-vpool0-vpool    253:6    0   50G  0 lvm
      └─VG1-VDO1          253:7    0   50G  0 lvm  /vdo_m
nvme0n5                   259:9    0    5G  0 disk
└─nvme0n5p1               259:15   0  500M  0 part
  └─VG1-vpool0_vdata      253:5    0    5G  0 lvm
    └─VG1-vpool0-vpool    253:6    0   50G  0 lvm
      └─VG1-VDO1          253:7    0   50G  0 lvm  /vdo_m

Q24: Set the recommended tuned profile for your system.

[root@serverX ~]# rpm -q tuned
tuned-2.24.0-1.el9.noarch
 
[root@serverX ~]# systemctl status tuned
[root@serverX ~]# systemctl start tuned
[root@serverX ~]# tuned-adm recommend
virtual-guest
 
[root@serverX ~]# tuned-adm profile virtual-guest powersave
 
[root@serverX ~]# tuned-adm active
Current active profile: virtual-guest powersave

Q25: Build an application called “rhcsa” that prints the message "Welcome to user ablerate" when you’re logged in as the user "ablerate".

# Without application 
[root@serverX ~]# useradd ablerate
[root@serverX ~]# passwd
 
[root@serverX ~]# su - ablerate
[ablerate@serverX ~]$ vim .bashrc
[ablerate@serverX ~]$ tail -1 .bashrc
echo "Welcome to user ablerate"
 
[root@serverX ~]# su - ablerate
Last login: Sat Oct 12 10:38:04 CST 2024 on pts/1
Welcome to user ablerate
 
# With application 
[ablerate@serverX ~]$ vim .bashrc
[ablerate@serverX ~]$ tail -1 .bashrc
export PATH=$PATH:/home/ablerate/script
[ablerate@serverX ~]$ source .bashrc
Welcome to user ablerate
 
[ablerate@serverX ~]$ echo $PATH
/home/ablerate/.local/bin:/home/ablerate/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/sanjeeb/Script:/home/ablerate/script
 
[ablerate@serverX script]$ vim rhcsa
[ablerate@serverX script]$ cat rhcsa
echo "Welcome to user ablerate"
 
[ablerate@serverX script]$ chmod 777 rhcsa
[ablerate@serverX script]$ ls -lh
total 4.0K
-rwxrwxrwx. 1 ablerate ablerate 32 Oct 12 10:57 rhcsa
 
[root@serverX ~]# su - ablerate
Last login: Sat Oct 12 10:49:08 CST 2024 on pts/1
Welcome to user ablerate
All systems normal

© 2025 2023 Sanjeeb KC. All rights reserved.