test 1 Flashcards

1
Q

Task1
change root password

A

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

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

Task2 New net work connection

A

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

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

Task 3
Edit hostname manually

A

edit /etc/hostname
systemctl restart systemd-hostnamed

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

Task 4
Set the default boot target to multi-user.

A

sudo systemctl set-default multi-user

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

Task 5
Set SELinux to permissive mode

A

sudo set-enforce permissive

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

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

A

grep -ev ^$ -e ^essential /usr/share/dict/linux.words > /var/tmp/pattern.txt

grep -e ^10 /etc/hosts | grep -ve ^$ > /var/tmp/pattern.txt

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

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.

A

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

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

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

A

useradd user10
passwd user10
usermod -e 2022-31-2021

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

Task 9
Create a group called group10 and add user20 and user30
as secondary members

A

groupadd group10
usermod -aG group10 user1

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

task 10
Create a user account called user40 with UID 2929. Set
the password to user1234

A

useradd -u 2929
passwd

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

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

A

mkdir /var/tmp/dir1
chown root:root /var/tmp/dir1
getfacl -c dir1
setfacl -dm u:user10:rwx dir1/

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

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

A

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

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

task 13
Create a logical volume called lvol1 of size 280MB in vgtest
volume group. Mount the ext4 file system persistently to /mnt/mnt1

A

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

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

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

A

chown :group10 /mnt/mnt1
chmod g=rwx,o= /mnt/mnt1

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

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

A

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

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

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

A

tar -cjf /var/tmp/usr.tar.bz2 /usr/lib

17
Q

Task 17: Create a directory hierarchy /dir1/dir2/dir3/dir4 and apply
SELinux contexts of /etc on it recursively

A

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

18
Q

Task 18: Enable access to the atd service for user20 and deny for
user30

A

edit at.allow
user20
edit at.deny
user30

19
Q

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

A

sudo logger -i “This is RHCSA sample exam on $(date) by $LOGNAME”
sudo grep $xdburton /var/log/messages

20
Q

Task 20: Allow user20 to use sudo without being prompted for their
password.

A

visudo
user20 ALL=(ALL) NOPASSWD:ALL

21
Q

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

A

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

22
Q

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

A

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

23
Q

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

A

podman run -it -e HISTSIZE -e HOSTNAME –name rhel8-env-vars ubi8
*In the container echo $HISTSIZE $HOSTNAME