RedHat Red Hat Certified System Administrator - RHCSARHEL 10 - EX200 模擬練習

Enable periodic TRIM operations for supported file systems.
正解:
See the solution below in Explanation.
Explanation:
Solution:
systemctl enable --now fstrim.timer
systemctl status fstrim.timer
Detailed Explanation:
* fstrim.timer schedules discard of unused blocks.
* This is useful on SSD-backed storage and thin-provisioned environments.
* RHEL 10 storage documentation explicitly documents enabling fstrim.timer. ( Red Hat Documentation )
Create a Container Image
As the user "wallah," download the Containerfile from http://classroom/Containerfile.
Do not modify the content of this file. Build an image named "pdf."
正解:
Solution:
# Install container management tools
[root@node1 ~]# dnf -y install container-tools
# Execute operations as the user wallah
[root@node1 ~]# ssh wallah@localhost
# Download the container build file
[wallah@node1 ~]# wget http://classroom/Containerfile
# Log in to the image registry
[wallah@node1 ~]# podman login -u admin -p redhat321 registry.lab.example.com
# Build the container image using the Containerfile in the current directory, with the image name "pdf"
[wallah@node1 ~]# podman build -t pdf .
# View the images
[wallah@node1 ~]$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/pdf latest 1d6e7ea71460 31 seconds ago 300 MB
registry.lab.example.com/ubi9-beta/ubi latest 28b0a4b69d9b 2 years ago 229 MB
Create a script to search for files
* Create a script named myresearch
* Place the script under /usr/local/bin
* The script is used to search for all files under /usr that are smaller than 10 MB and have group write permission, and place these files into /root/myfiles
正解:
Solution:
mkdir /root/myfiles
vim /usr/local/bin/myresearch
#!/bin/bash
find /usr -type f -and -size -10M -and -perm -2000 -exec cp -a {} /root/myfiles \;
:wq
chmod +x /usr/local/bin/myresearch
bash /usr/local/bin/myresearch
ll -h /root/myfiles
Script explanation:
(#!/bin/bash): #! is a conventional marker that tells the system which interpreter should be used to execute the script.
/bin/bash means the script is executed using the default Bash shell.
Here, a for loop is needed to iterate over the found GIDs (group IDs) for processing.
(awk -F':' '{print $3}' /etc/group):
awk is used to split and process text.
-F specifies the field separator.
":" indicates that the colon is used as the delimiter.
{print $3} prints the third field (the group ID).
Deny cron access for user john.
正解:
See the solution below in Explanation.
Explanation:
Solution:
echo "john" > > /etc/cron.deny
Detailed Explanation:
* cron.deny blocks listed users from using cron.
* This is the simplest way to deny scheduled-job access for one user.
Find String
Find all lines containing the string "ng" in the file /usr/share/xml/iso-codes/iso_639_3.xml.
Save copies of all these lines to /root/list in the root directory.
/root/list must not contain empty lines, and all lines must be exact copies of the original lines in /usr/share/xml/iso-codes/iso_639_3.xml.
正解:
Solution:
[root@node1 ~]# grep ng /usr/share/xml/iso-codes/iso_639_3.xml
[root@node1 ~]# grep ng /usr/share/xml/iso-codes/iso_639_3.xml > /root/list
# Verification
[root@node1 ~]# cat /root/list
Create a volume group with a physical extent size of 16 MB and create a logical volume using 30 extents.
正解:
See the solution below in Explanation.
Explanation:
Solution:
pvcreate /dev/sdb3
vgcreate -s 16M VG1 /dev/sdb3
lvcreate -l 30 -n LV1 VG1
mkfs.ext4 /dev/VG1/LV1
Detailed Explanation:
* vgcreate -s 16M sets PE size to 16 MB.
* lvcreate -l 30 allocates 30 extents.
* 30 x 16 MB = 480 MB total LV size.
* mkfs.ext4 creates the filesystem.
Create a Stratis pool named pool1 on /dev/sdc and create a file system named fs1.
正解:
See the solution below in Explanation.
Explanation:
Solution:
dnf install -y stratisd stratis-cli
systemctl enable --now stratisd
stratis pool create pool1 /dev/sdc
stratis filesystem create pool1 fs1
stratis filesystem list
Detailed Explanation:
* stratisd is the daemon and stratis-cli provides the command-line interface.
* A Stratis pool is created from a block device.
* The Stratis file system is then created inside that pool.
* RHEL 10 documents Stratis as an available volume-managing file-system layer. ( Red Hat
Documentation )