Red Hat 8RHCSA exam real questions, 300 points have passed today (2022 latest version)

1. Configure network settings

Configure mars to have the following network configuration:
insert image description here
IP address: 172.25.250.100
Subnet mask: 255.255.255.0
Gateway: 172.25.250.254

Solution A:

[root@mars ~]# vim /etc/hostname
mars.domain250.example.com
[root@mars ~]# nmtui
[root@mars ~]# nmcli connection up 'Wired connection 1'

Solution B:

[root@mars ~]# vim /etc/hostname
mars.domain250.example.com
[root@mars ~]# nmcli connection modify 'Wired connection 1' ipv4.method manual ipv4.addresses '172.25.250.100/24' ipv4.gateway '172.25.250.254' ipv4.dns 172.25.250.254 connection.autoconnect yes
[root@mars ~]# nmcli connection up 'Wired connection 1'

2. Configure your system to use the default repository

insert image description here

Solution method:

3. Debug SELinux

A web server running on a non-standard port 82 is having trouble serving content. Debug and fix the problem as needed so that
the web server on the system is able to serve all existing HTML files in /var/www/html (note: do not delete or otherwise alter existing file content)
Web The server serves this content on port 82
The web server starts automatically at system startup

Solution method:

[root@mars ~]# semanage port -a -t http_port_t -p tcp 82
[root@mars ~]# ls -ldZ /var/www/html/
[root@mars ~]# semanage fcontext -m -t httpd_sys_content_t "/var/www/html/file1"
[root@mars ~]# restorecon -Rv /var/www/html/
[root@mars ~]# systemctl restart httpd
[root@mars ~]# systemctl enable httpd

4. Create user account

Create the following users, groups, and group memberships:

A group named sysmgrs
User natasha, subordinate to sysmgrs
user harry as a secondary group, also subordinate to sysmgrs user sarah as a secondary group
, has no access to the interactive shell on the system and is not a member of sysmgrs
passwords for natasha, harry, and sarah Should be flectrag

Solution method:

[root@mars ~]# groupadd sysmgrs
[root@mars ~]# useradd -G sysmgrs natasha
[root@mars ~]# useradd -G sysmgrs harry
[root@mars ~]# useradd -s /bin/false sarah
[root@mars ~]# passwd natasha
[root@mars ~]# passwd harry
[root@mars ~]# passwd sarah

5. Configure cron jobs

Configure a cron job that runs every 2 minutes and executes the following command:
logger "EX200 in progress", run as user natasha

Solution method:

[root@mars ~]# crontab -e -u natasha
*/2 * * * * logger "EX200 in progress"

6. Create a collaboration directory

Create a collaborative directory /home/managers with the following characteristics:
The group permissions for /home/managers are that the sysmgrs
directory should be readable, writable, and accessible by members of sysmgrs, but not by any other user. (Of course, the root user has access to all files and directories on the system)
Files created in /home/managers automatically set group ownership to the sysmgrs group

Solution method:

[root@mars ~]# mkdir /home/managers
[root@mars ~]# chown -R root:sysmgrs /home/managers
[root@mars ~]# chmod -R 2770 /home/managers

7. Configure NTP

Configure your system to be an NTP client for materials.example.com. (Note: materials.example.com is a DNS alias for classroom.example.com)

Solution method:

[root@mars ~]# vim /etc/chrony.conf
#将第7行,修改为:
server materials.example.com iburst
[root@mars ~]# systemctl restart chronyd
[root@mars ~]# systemctl enable chronyd

8. Configure autofs

Configure autofs to automatically mount remote users' home directories as follows:
materials.example.com ( 172.25.254.254 ) NFS export /rhome to your system. This filesystem contains a pre-configured home directory for user remoteuser1 remoteuser1
's home directory is materials.example.com:/rhome/remoteuser1
remoteuser1's home directory should be automatically mounted to the local /rhome under /rhome/remoteuser1's
home directory must be available The password written by its user
remoteuser1 is flectrag

Solution method:

[root@mars ~]# yum install autofs
[root@mars ~]# vim /etc/auto.master
#添加一行
/rhome /etc/rhcsa.misc
[root@mars ~]# vim /etc/rhcsa.misc
#添加一行
remoteuser1 -fstype=nfs,rw materials.example.com:/rhome/remoteuser1
[root@mars ~]# systemctl restart autofs
[root@mars ~]# systemctl enable autofs

9. Configure /var/tmp/fstab permissions

Copy the file /etc/fstab to /var/tmp/fstab. Configure the permissions of /var/tmp/fstab to meet the following conditions:
The file /var/tmp/fstab is owned by the root user The
file /var/tmp/fstab belongs to the group root
The file /var/tmp/fstab should not be executed by anyone
User natasha Can read and write /var/tmp/fstab
User harry cannot write or read /var/tmp/fstab
All other users (current or future) can read /var/tmp/fstab

Solution method:

[root@mars ~]# cp /etc/fstab /var/tmp/fstab
[root@mars ~]# setfacl -m u:natasha:rw /var/tmp/fstab
[root@mars ~]# setfacl -m u:harry:- /var/tmp/fstab

10. Configure user accounts

Configure the user manalo, whose user ID is 3533. The password for this user should be flectrag.

Solution method:

[root@mars ~]# useradd -u 3533 manalo
[root@mars ~]# passwd manalo

11. Find files

Find all files owned by jacques and place a copy of them in the /root/findfiles directory

Solution method:

[root@mars ~]# mkdir /root/findfiles
[root@mars ~]# find / -user jacques -exec cp -a {} /root/findfiles \;

12. Find String

Finds all lines in the file /usr/share/xml/iso-codes/iso_639_3.xml that contain the string ng. Put a copy of all these lines in the file /root/list in their original order. /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 method:

[root@mars ~]# grep ng /usr/share/xml/iso-codes/iso_639_3.xml > /root/list

13. Create archive

Create a tar archive named /root/backup.tar.gz, which should contain the tar archive of /usr/local, which should contain the contents of /usr/local. The tar archive must be compressed with gzip.

Solution method:

[root@mars ~]# tar czvf /root/backup.tar.gz /usr/local

Additional questions

14. Add sudo password-free operation

No password required when allowing sudo for members of the sysmgrs group

Solution method:

[root@mars ~]# visudo
#
#在大约100行的位置添加下面内容:
#
%sysmgrs ALL=(ALL) NOPASSWD: ALL

15. Configure the password policy for creating new users

When creating a new user, the default password policy is 20 days before the password expires.

Solution method:

[root@mars ~]# vim /etc/login.defs
#
#修改第25行,将参数后面的99999改成20.
#
PASS_MAX_DAYS 20

16. Create a shell script

Create a script named myresearch.
The script is placed under /usr/local/bin.
The script is used to find all files under /usr that are less than 10m and have permission to modify the group ID, and place these files under /root/myfiles

Solution method:

[root@mars ~]# mkdir -p /root/myfiles
[root@mars ~]# vim /usr/local/bin/myresearch
#!/bin/bash
find /usr -type f -and -size -10M -and -perm -2000 -exec cp -a {
    
    } /root/myfiles \;
[root@mars ~]# chmod 755 /usr/local/bin/myresearch

Execute on venus.domain250.example.com

1. Set root password

Set the root password for venus to flectrag. You need system access to do this.

Solution method:

Restart the host and enter the boot menu, move the cursor to the first option and press the e key on the keyboard, as shown in the figure below,
insert image description here
then on the kernel editing page, add rd.break console=tty0 at the end of the line at the beginning of Linux, and then press Press the keyboard ctrl+x key to enter the single-user mode (password cracking)

switch_root:/# mount -o remount,rw /sysroot
switch_root:/# chroot /sysroot
sh-4.4# echo flectrag | passwd --stdin root
sh-4.4# touch /.autorelabel
sh-4.4# sync
sh-4.4# 按ctrl+d键
switch_root:/# 按ctrl+d键

Note: This question may be unsuccessful due to the influence of the virtual machine, and it will be stuck on the boot interface, but this will not happen in the real machine and the test environment

2. Configure your system to use the default repository

YUM repositories are already available from http://content/rhel8.0/x86_64/dvd/BaseOS and http://content/rhel8.0/x86_64/dvd/AppStream Configure your system to use these locations as default repository.

Solution method:

insert image description here

3. Adjust the logical volume size

Resize the logical volume vo and its file system to 230 MiB. Make sure the filesystem contents remain unchanged.
Note: The partition size is rarely exactly the requested size, so sizes ranging from 217 MiB to 243 MiB are acceptable.

Solution method:

[root@venus ~]# df -h
/dev/mapper/myvol-vo 175M 1.6M 160M 1% /reports
#考试时大小为175M,扩展至230M即可
[root@venus ~]# lvextend -L 230M /dev/myvol/vo
[root@venus ~]# resize2fs /dev/myvol/vo

4. Add swap partition

Add an additional swap partition 756MiB to your system. The swap partition should be automatically mounted on system boot. Do not delete or in any way alter any existing swap partitions on the system.

Solution method:

[root@venus ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xcad347a4.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 敲回车即可
First sector (2048-41943039, default 2048): 敲回车即可
Last sector, +sectors or +size{
    
    K,M,G,T,P} (2048-41943039, default 41943039): +756M
Created a new partition 1 of type 'Linux' and of size 756 MiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@venus ~]# mkswap /dev/vdb1
Setting up swapspace version 1, size = 756 MiB (792719360 bytes)
no label, UUID=5b0302b3-2a08-45a0-ada3-7e6461e2689e
[root@venus ~]# swapon /dev/vdb1
[root@venus ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Jul 21 05:03:40 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=2db66eb4-d9c1-4522-8fab-ac074cd3ea0b /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/cdrom /media/cdrom iso9660 defaults 0 0 
/dev/vdb1 swap swap defaults 0 0

5. Create a logical volume

Create a new logical volume according to the following requirements:
the logical volume is named qa, belongs to the qagroup volume group, and has a size of 60 extended blocks. The
extended block size of the logical volume in the qagroup volume group should be 16 MiB.
Use the ext3 file system to format the new logic roll. This logical volume should be automatically mounted under /mnt/qa at system startup

Solution method:

[root@venus ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 敲回车即可
First sector (1550336-41943039, default 1550336): 敲回车即可
Last sector, +sectors or +size{
    
    K,M,G,T,P} (1550336-41943039, default 41943039): 敲回车即可
Created a new partition 2 of type 'Linux' and of size 19.3 GiB.
Command (m for help): w
The partition table has been altered.
Syncing disks.
[root@venus ~]# pvcreate /dev/vdb2
[root@venus ~]# vgcreate -s 16M qagroup /dev/vdb2
[root@venus ~]# lvcreate -l 60 -n qa qagroup
[root@venus ~]# mkfs.ext3 /dev/qagroup/qa
[root@venus ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Jul 21 05:03:40 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=2db66eb4-d9c1-4522-8fab-ac074cd3ea0b /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/cdrom /media/cdrom iso9660 defaults 0 0 
/dev/vdb1 swap swap defaults 0 0
/dev/qagroup/qa /mnt/qa ext3 defaults 0 0 
[root@venus ~]# mount -a

6. Create a VDO volume

Create a new VDO volume according to the following requirements:
Use an unpartitioned disk.
The name of the volume is vdough.
The logical size of the volume is 50G.
The volume is formatted with the xfs file system.
The volume (at system startup) is mounted under /vbread

Solution method:

[root@venus ~]# yum install vdo
[root@venus ~]# man vdo | grep vdo.*create
[root@venus ~]# vdo create --name=vdough --device=/dev/vdc --vdoLogicalSize=50G
[root@venus ~]# mkfs.xfs /dev/mapper/vdough
[root@venus ~]# udevadm settle
[root@venus ~]# mkdir /vbread
[root@venus ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Jul 21 05:03:40 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=2db66eb4-d9c1-4522-8fab-ac074cd3ea0b /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/cdrom /media/cdrom iso9660 defaults 0 0 
/dev/vdb1 swap swap defaults 0 0
/dev/vdb2 /mnt/qa ext3 defaults 0 0 
/dev/mapper/vdough /vbread xfs defaults,_netdev 0 0 
[root@venus ~]# mount -a

7. Configure system tuning

Select the recommended tuned profile for your system and make it the default.

Solution method:

[root@venus ~]# tuned-adm recommend
virtual-guest
[root@venus ~]# tuned-adm profile virtual-guest

Guess you like

Origin blog.csdn.net/qq_51235445/article/details/127828431