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