test 1 Flashcards
Task1
change root password
rd.bread at the end of the linux line - ctrl x to boot to special shell
chroot /sysroot
mount -o remount,rw /
passwd
touch .autorelabel
exit
Task2 New net work connection
Create a file called ifcfg-enp0s8 in the /etc/sysconfig/network-scripts directory and enter the following information to establish a connection profile:
sudo cat /etc/sysconfig/network-scripts/ifcfg-enp0s8
TYPE=ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME=enp0s8
DEVICE=enp0s8
ONBOOT=yes
IPADDR=172.10.10.10
PREFIX=24
GATEWAY=172.10.10.1
Task 3
Edit hostname manually
edit /etc/hostname
systemctl restart systemd-hostnamed
Task 4
Set the default boot target to multi-user.
sudo systemctl set-default multi-user
Task 5
Set SELinux to permissive mode
sudo set-enforce permissive
Task 6
Perform a case-insensitive search for all lines in the
/usr/share/dict/linux.words file that begin with the pattern “essential”.
Redirect the output to /var/tmp/pattern.txt file. Make sure that empty
lines are omitted
grep -ev ^$ -e ^essential /usr/share/dict/linux.words > /var/tmp/pattern.txt
grep -e ^10 /etc/hosts | grep -ve ^$ > /var/tmp/pattern.txt
Task 7
Change the primary command prompt for the root user to
display the hostname, username, and current working directory
information in that order. Update the per-user initialization file for
permanence.
export PS1=”< $LOGNAME on (hostname) in $PWD >”
Edit the .bash_profile file for user1 and define the value exactly as it was
run in Step 1
task 8
Create user accounts called user10, user20, and user30.
Set their passwords to Temp1234. Make user10 and user30
accounts to expire on December 31, 2021
useradd user10
passwd user10
usermod -e 2022-31-2021
Task 9
Create a group called group10 and add user20 and user30
as secondary members
groupadd group10
usermod -aG group10 user1
task 10
Create a user account called user40 with UID 2929. Set
the password to user1234
useradd -u 2929
passwd
task 11
Create a directory called dir1 under /var/tmp with
ownership and owning group set to root. Configure default ACLs on
the directory and give user10 read, write, and execute permissions
mkdir /var/tmp/dir1
chown root:root /var/tmp/dir1
getfacl -c dir1
setfacl -dm u:user10:rwx dir1/
task 12
Attach the RHEL 8 ISO image to the VM and mount it persistently to /mnt/cdrom. Define access to both repositories and confirm
attach RHEL iso image to vitual box
edit fstab: /dev/sr0 /mnt iso9660 ro 0 0
sudo mount -a
Create a definition file called local.repo in the /etc/yum.repos.d directory
using the vim editor and define the following data for both repositories in
it:
[BaseOS]
name=BaseOS
baseurl=file://mnt/BaseOS
gpgcheck=0
[AppStream]
name=AppStream
baseurl=file;//mnt/AppStream
gpgcheck=0
sudo dnf repolist
task 13
Create a logical volume called lvol1 of size 280MB in vgtest
volume group. Mount the ext4 file system persistently to /mnt/mnt1
sudo parted /dev/sdd mklabel msdos
sudo parted /dev/sdd mkpart primary 1 280m
sudo parted /dev/sdd set 1 lvm on
sudo pvcreate /dev/sd1
sudo vgcreate -vs 16 vgtest /dev/sdd
sudo lvcreate –n lvol1 -L 280 vgtest
sudo mkfs.ext4 /dev/vgtest/lvol1
fstab:
/dev/vgtest/lvol1 /mnt ext4 defaults 0 0
sudo mount -a
task 14
Change group membership on /mnt/mnt1 to group10. Set
read/write/execute permissions on /mnt/mnt1 for group members,
and revoke all permissions for public
chown :group10 /mnt/mnt1
chmod g=rwx,o= /mnt/mnt1
task 15
Create a logical volume called lvswap of size 280MB in
vgtest volume group. Initialize the logical volume for swap use. Use
the UUID and place an entry for persistence
sudo parted /dev/sdb mkpart primary 0 280m
sudo lvcreate -L 280 -n lvswap vgtest
sudo mkswap /dev/vgtest/lvswap
lsblk -f /dev/vgfs/swapvol
fstab: UUID=”A;LSDKF” swap swap pri=1 0 0
sudo swapon -a
Task 16: Use the combination of tar and bzip2 commands to create
a compressed archive of the /usr/lib directory. Store the archive
under /var/tmp as usr.tar.bz2
tar -cjf /var/tmp/usr.tar.bz2 /usr/lib
Task 17: Create a directory hierarchy /dir1/dir2/dir3/dir4 and apply
SELinux contexts of /etc on it recursively
sudo semanage fcontext -a -s user_u -t public_content_t ‘/dir1/dir2/dir3/dir4(/.*)?’
sudo chcon -vu staff_u -t etc_t /dir1/dir2/dir3/dir4 -R
Task 18: Enable access to the atd service for user20 and deny for
user30
edit at.allow
user20
edit at.deny
user30
Task 19: Add a custom message “This is RHCSA sample exam on
$(date) by $LOGNAME” to the /var/log/messages file as the root
user. Use regular expression to confirm the message entry to the log
file
sudo logger -i “This is RHCSA sample exam on $(date) by $LOGNAME”
sudo grep $xdburton /var/log/messages
Task 20: Allow user20 to use sudo without being prompted for their
password.
visudo
user20 ALL=(ALL) NOPASSWD:ALL
Task 21: Write a bash shell script to create three user accounts—
user555, user666, and user777—with no login shell and passwords
matching their usernames. The script should also extract the three
usernames from the /etc/passwd file and redirect them into
/var/tmp/newusers
for USER in user{10..12}
do
echo “creating $USER”
/usr/sbin/useradd -s /usr/sbin/nologin $USER
if [ $? = 0 ]
then
echo $USER | /usr/binpaswd –stdin $USER
done
Task 22: Launch a simple container as user20 using the latest
version of ubi7 image. Configure the container to auto-start at system reboots without the need for user 20 to log in
podman run -dt –name rootless-containger ubi8
podman ps
podman generate systemd –new –name rootless-container > ~/.config/systemd/user/rootless-container.service
podman stop rootless-container
podman rm rootless-container
systemctl –user daemon-reload
systemctl –user enable –now rootless-container.service
Task 23: Launch another container as user20 using the latest
version of ubi8 image with two environment variables SHELL and
HOSTNAME. Configure the container to auto-start via systemd
without the need for user20 to log in. Connect to the container and
verify variable setting
podman run -it -e HISTSIZE -e HOSTNAME –name rhel8-env-vars ubi8
*In the container echo $HISTSIZE $HOSTNAME