test 2 Flashcards
Task 01: Using the nmcli command, configure a network connection on the primary network device with IP address 192.168.0.242/24, gateway 192.168.0.1, and nameserver 192.168.0.1. Use different IP assignments based on your lab environment.
sudo nmcli con add type Ethernet ifname enp0s8 con-name enp0s8 ip4 192.168.0.242/24 gw4 192.168.0.1
nmcli con mod “enp0s8” ipv4.dns “8.8.8.8 8.8.4.4”
Task 02: Using the hostnamectl command, set the system hostname to rhcsa2.example.com and alias rhcsa2. Make sure that the new hostname is reflected in the command prompt.
sudo hostnamectl set-hostname server20
Task 03: Create a user account called user70 with UID 7000 and comments “I am user70”. Set the maximum allowable inactivity for this user to 30 days
useradd -u 7000 -f 30 -c “I am user 70” user70
also for inactive
passwd -i 30 user70
chage -I 30 user70
Task 04: Create a user account called user50 with a non-interactive shell.
useradd -s /sbin/nologinn user50
Task 05: Create a file called testfile1 under /var/tmp with ownership and owning group set to root. Configure access ACLs on the file and give user10 read and write access. Test access by logging in as user10 and editing the file
touch /vat/tmp/testfile1
chown root:toot testfile1
setfacl -m u:user10:rw
Task 06: Attach the RHEL 8 ISO image to the VM and mount it persistently to /mnt/dvdrom. Define access to both repositories and confirm.
Attach iso to virtual box
mount it - fstab entry
mount -a
edit /etc/yum.repos.d/local.repo
[BaseOS]
name=BaseOS
baseurl=file://mnt/BaseOS
gpgcheck=0
Task 07: Create a logical volume called lv1 of size equal to 10 LEs in vg1 volume group (create vg1 with PE size 8MB in a partition on the 400MB disk). Initialize the logical volume with XFS type and mount it on /mnt/lvfs1. Create a file called lv1file1 in the mount point. Set the file system to automatically mount at each system reboot.
sudo parted /dev/sdd mklabel msdos
sudo parted /dev/sdd mpart primary 0 400m
sudo parted /dev/sdd set 1 lvm on
sudo pvcreate /dev/sdd1
sudo vgcreate -s 8 vg1 /dev/sdd1
sudo lvcreate -l 10 -n lv1 vg1
sudo mkfs.xfs /dev/vg1/lv1
fstab
/dev/vg1/lv1 /mnt xfs defaults 0 0
mount -a
Task 08: Add a group called group20 and change group
membership on /mnt/lvfs1 to group20. Set read/write/execute
permissions on /mnt/lvfs1 for the owner, group members, and others
groupadd group20
chown :group20 /mnt/lvfs1
chmod 777 /mnt/lvfs1
Task 09: Extend the file system in the logical volume lv1 by 64MB
without unmounting it and without losing any data. Confirm the new
size for the logical volume and the file system.
sudo pvcreate /dev/sde
sudo vgextend vgroup /dev/sde
sudo lvextend -L +40 /dev/vgroup/lv1
sudo lvresize -r -L +40 /dev/vgroup/lv1
sudo lvs
Task 10: Create a swap partition of size 85MB on the 400MB disk.
Use its UUID and ensure it is activated after every system reboot.
sudo parted /dev/sdd mkpart primary 0 85
sudo mkswap /dev/sdd1
lsblk -f /dev/sdd1
fstab:
UUID=”;ALKDSF” swap swap pri=1 0 0
sudo swapon -a
Task 11: Create a disk partition of size 100MB on the 400MB disk
and format it with Ext4 file system structures. Assign label stdlabel to
the file system. Mount the file system on /mnt/stdfs1 persistently
using the label. Create file stdfile1 in the mount point
sudo parted /dev/sdd mkpart primare 0 100
sudo mkfs.ext4 /dev/sdd2
sudo e2label /dev/sdd2 stdlabel (note- “xfs_admin -L stdlabel” for xfs)
fstab:
stdlabel /mnt/stdfs1 ext4 defaults 0 0
Task 12: Use the tar and gzip command combination to create a
compressed archive of the /etc directory. Store the archive under /var/tmp using a filename of your choice
tar -czf /var/tmp/tarbal.tar.gzip /etc
Task 13: Create a directory /direct01 and apply SELinux contexts for
/root to it
ls -Z / (see context of /root)
semanage fcontext -a -t admin_home_t “/direct01(/.*)?”
Task 14: Set up a cron job for user70 to search for files by the name
“core” in the /var directory and copy them to the directory
/var/tmp/coredir1. This job should run every Monday at 1:20 a.m.
crontab -eu user70
20 1 * * 2 find /var -name core -type f -exec cp {} /var/tmp/coredir1 \;
Task 15: Search for all files in the entire directory structure that have
been modified in the past 30 days and save the file listing in the
/var/tmp/modfiles.txt file
find /var/tmp -mtime -30 > /var/tmp/modfiles.txt
Task 16: Modify the bootloader program and set the default autoboot timer value to 2 seconds.
Edit the /etc/default/grub file:
GRUB_TIMEOUT=3
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
Task 17: Determine the recommended tuning profile for the system
and apply it
install tuned
systemctl enable tuned
sudo tuned-adm list
sudo tuned-adm recommend
sudo tuned-adm profile virtual-guest
Task 18: Configure Chrony to synchronize system time with the
hardware clock. Remove all other NTP sources.
Simply comment the default server/pool directive(s) and add a single
directive “server <hostname>” to the file. Replace <hostname> with the NTP
server name or its IP address as provided.</hostname></hostname>
/etc/chrony.conf
Task 19: Install package group called “Development Tools” and
capture its information in /var/tmp/systemtools.out file
dnf group install ‘development tools’
dnf group info ‘development tools’ > /var/tmp/systemtools.out
Task 20: Lock user account user70. Use regular expressions to
capture the line that shows the lock and store the output in file
/var/tmp/user70.lock.
sudo passwd -l user70
sudo grep user70 /etc/shadow > /var/tmp/user70.lock
Task 21: Write a bash shell script so that it prints RHCSA when
RHCE is passed as an argument, and vice versa. If no argument is
provided, the script should print a usage message and quit with exit
value 5
!/bin/bash
echo “Please type RHCSA or RHCE:”
read var
if [ $var = “RHCSA” ]
then
echo “RHCE”
elif [ $var = “RHCE” ]
then
echo “RHCSA”
else
echo “unacceptable”
fi
exit 5
Task 22: Launch a root container and configure it to auto-start via
systemd
sudo podman run -dt –name root-container ubi8
sudo podman ps
sudo podman generate systemd –new –name root-container | sudo tee /etc/systemd/system/root-container.service
sudo podman stop root-container
sudo systemctl daemon-reload
sudo systemctl enable –now root-container
sudo systemctl status root-container
Task 23: Launch a container as user80 with /data01 mapped to
/data01 using the latest version of the ubi8 image. Configure a
systemd service to auto-start the container on system reboots
without the need for user80 to log in. Create files under the shared
mount point and validate data persistence
sudo mkdir /data01
sudo chmod 777 /data01
sudo podman run –name container-data -v /data01:/data01:Z -it ubi7