Practice Test 06
Updated Apr 22, 2021 ·
Lab 01 - Cron
Tasks:
set a cronjob for user ben that run every 5 minutes.
Solution
sudo su -
cron -u ben -e
/5 * * * * job.sh
:wq!
crontab -u ben -l
Lab 02 - Hostnames
Tasks:
Set the device hostname to phoenix.anaheim.lab.example.com.
Solution
sudo hostnamectl set-hostname phoenix.anaheim.lab.com
Lab 03 - Repositories
Tasks:
Configure your anaheim.example.com as yum client so that you can download and install package from your yum repository at
- http://anaheim.example.com/rhel8.2/x86_64/dvd/BaseOS
- http://anaheim.example.com/rhel7.0/x86_64/dvd/AppStream
Solution
cd /etc/yum/repos.d
ll
# if there are other repo, delete them.
rm -f *
# create the repo config files
touch BaseOS.repo
touch AppStream.repo
vim BaseOS.repo
[BaseOS]
name=BaseOS
baseurl=http://anaheim.example.com/rhel8.2/x86_64/dvd/BaseOS
gpgcheck=0
enabled=1
vim AppStream.repo
[AppStream]
name=AppStream
baseurl=http://anaheim.example.com/rhel7.0/x86_64/dvd/AppStream
gpgcheck=0
enabled=1
Lab 04 - File Permissions
Tasks:
- Create "form.doc" and give them permission such that root have read, group have full permission and other user have write permission.
- Create "update.doc" and give them permission such that root have full permission, group have read and other user have read & execute permission.
Solution
touch form.doc
chmod 472 form.doc
touch update.doc
chown root: update.doc
chmod 745 update.doc
Lab 05 - ACL
Tasks:
- Copy directory /etc/fstab to /var/tmp/fstab.
- Assign user Michael read,write ACL permission on /var/tmp/fstab.
- Assign user Pete read only permission on /var/tmp/fstab.
- Tony has no permission, while other users have read only permission
Solution
sudo su -
cp /etc/fstab /var/tmp/fstab
setfacl -m u:michael:rw /var/tmp/fstab
setfacl -m u:pete:r /var/tmp/fstab
setfacl -m u:tony:--- /var/tmp/fstab
setfacl -m o:r /var/tmp/fstab
getfacl /var/tmp/fstab
chmod 3770 /var/tmp/fstab
Lab 06 - Users and Groups
Tasks:
- Add user Henry, John, and Will.
- Set "password" as password.
- Create a group uxdevs.
- Henry and John are secondary member of group of uxdevs group.
- Will should not have interactive shell prompt.
- Make a directory /mnt/reports.
- Group uxdevs must belong to the directory.
- All user in the group have read and write each other files.
Solution
sudo su -
groupadd uxdevs
useradd -G uxdevs henry
useradd -G uxdevs john
useradd -s /sbin/nologin will
echo 'password' | passwd --stdin henry
echo 'password' | passwd --stdin john
echo 'password' | passwd --stdin will
mkdir /mnt/reports
cho.
chown uxdevx: /mnt/reports
chmod 2660 /mnt/reports
Lab 07 - Autofs
Tasks:
Install Autofs.
Solution
sudo su -
yum install -y autofs
vim /etc/auto.master.d/direct.autofs
vim /etc/auto.direct
/external -rw,sync,fstpe=url
systemctl enable --now autofs
sustemctl status autofs
Lab 08 - Tar
Tasks:
Create a tar file /tmp/root.tar.gz that compress the /root
Solution
sudo su -
tar -czvf /tmp/root.tar.gz /root
ll /tmp/*gz
Lab 09 - Find
Tasks:
Find all files owned by user Thomas, and copy it to catalog: /tmp/inventory.
Solution
ls -la /tmp/inventory
mkdir -p /tmp/inventory
find / -user 'thomas'
find / -user 'thomas' -exec cp {} /tmp/inventory \;
ll /tmp/inventory
Lab 10 - Grep
Tasks:
Copy all occurence of ‘strato’ from /usr/share/dict/words to the directory /tmp/data.
Solution
grep 'strato' /usr/share/dict/words > /tmp/datbudget.xlxs
cat /tmp/datbudget.xlxs