test 2 Flashcards

1
Q

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.

A

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”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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.

A

sudo hostnamectl set-hostname server20

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A

useradd -u 7000 -f 30 -c “I am user 70” user70

also for inactive
passwd -i 30 user70
chage -I 30 user70

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Task 04: Create a user account called user50 with a non-interactive shell.

A

useradd -s /sbin/nologinn user50

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

touch /vat/tmp/testfile1
chown root:toot testfile1
setfacl -m u:user10:rw

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

groupadd group20
chown :group20 /mnt/lvfs1
chmod 777 /mnt/lvfs1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

tar -czf /var/tmp/tarbal.tar.gzip /etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Task 13: Create a directory /direct01 and apply SELinux contexts for
/root to it

A

ls -Z / (see context of /root)
semanage fcontext -a -t admin_home_t “/direct01(/.*)?”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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.

A

crontab -eu user70
20 1 * * 2 find /var -name core -type f -exec cp {} /var/tmp/coredir1 \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

A

find /var/tmp -mtime -30 > /var/tmp/modfiles.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Task 16: Modify the bootloader program and set the default autoboot timer value to 2 seconds.

A

Edit the /etc/default/grub file:
GRUB_TIMEOUT=3

sudo grub2-mkconfig -o /boot/grub2/grub.cfg
reboot

17
Q

Task 17: Determine the recommended tuning profile for the system
and apply it

A

install tuned
systemctl enable tuned
sudo tuned-adm list
sudo tuned-adm recommend
sudo tuned-adm profile virtual-guest

18
Q

Task 18: Configure Chrony to synchronize system time with the
hardware clock. Remove all other NTP sources.

A

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

19
Q

Task 19: Install package group called “Development Tools” and
capture its information in /var/tmp/systemtools.out file

A

dnf group install ‘development tools’
dnf group info ‘development tools’ > /var/tmp/systemtools.out

20
Q

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.

A

sudo passwd -l user70
sudo grep user70 /etc/shadow > /var/tmp/user70.lock

21
Q

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

A

!/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

22
Q

Task 22: Launch a root container and configure it to auto-start via
systemd

A

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

23
Q

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

A

sudo mkdir /data01
sudo chmod 777 /data01
sudo podman run –name container-data -v /data01:/data01:Z -it ubi7