RedHat Red Hat Certified System Administrator - RHCSA - EX200 Exam Practice Test

Set the default password policy
Set a password policy for newly created users so that, when a user is created, the password expires by default after 25 days.
Correct Answer:
Solution:
[root@node1 ~]# vim /etc/login.defs +25
Type / and search for PASS_MAX_DAYS.
Modify it to:
PASS_MAX_DAYS 25
Verify:
[root@node1 ~]# useradd user1
[root@node1 ~]# chage -l user1
Create a user harry, set the password to expire every 30 days, and force a password change on first login.
Correct Answer:
See the solution below in Explanation.
Explanation:
Solution:
useradd harry
passwd harry
chage -M 30 -d 0 harry
chage -l harry
Detailed Explanation:
* useradd harry creates the local user.
* passwd harry sets the initial password.
* chage -M 30 sets the maximum password age to 30 days.
* chage -d 0 forces the user to change the password at next login.
* chage -l harry verifies the policy.
Create Archive
Create a tar archive named /root/backup.tar.bz2, which should contain the contents of /usr/local. The tar archive must be compressed using bzip2.
Correct Answer:
Solution:
[root@node1 ~]# yum -y install bzip2
[root@node1 ~]# tar -jcvPf /root/backup.tar.bz2 /usr/local
# Verification
[root@node1 ~]# file /root/backup.tar.bz
Create a shared directory
Create a shared directory with the following characteristics:
* The group owner of /home/test is admins.
* Members of the admins group can read, write, and access this directory. Other users (except root) do not have these permissions.
* Files created inside this directory automatically have their group ownership set to the admins group.
Correct Answer:
Solution:
Create the group:
[root@node1 ~]# groupadd admins
Create the directory:
[root@node1 ~]# mkdir /home/test
Set the group ownership:
[root@node1 ~]# chgrp admins /home/test
Set the permissions:
[root@node1 ~]# chmod 2770 /home/test
Verify:
[root@node1 ~]# ls -ld /home/test
drwxrws--- root admins /home/test
Create /share/projects, make alex the owner, and configure the sticky bit so users cannot delete each other's files.
Correct Answer:
See the solution below in Explanation.
Explanation:
Solution:
mkdir -p /share/projects
chown alex /share/projects/
chmod a+rwx,+t /share/projects/
ls -ld /share/projects/
Detailed Explanation:
* chmod a+rwx gives read, write, and execute to everyone.
* +t sets the sticky bit.
* Sticky bit on a shared directory means users can create files, but only the file owner, directory owner, or
root can delete them.
* This is the same model used on /tmp.
Find String
Find all lines containing the string "ng" in the file /usr/share/xml/iso-codes/iso_639_3.xml.
Save copies of all these lines to /root/list in the root directory.
/root/list must not contain empty lines, and all lines must be exact copies of the original lines in /usr/share/xml/iso-codes/iso_639_3.xml.
Correct Answer:
Solution:
[root@node1 ~]# grep ng /usr/share/xml/iso-codes/iso_639_3.xml
[root@node1 ~]# grep ng /usr/share/xml/iso-codes/iso_639_3.xml > /root/list
# Verification
[root@node1 ~]# cat /root/list
Deny cron access for user john.
Correct Answer:
See the solution below in Explanation.
Explanation:
Solution:
echo "john" > > /etc/cron.deny
Detailed Explanation:
* cron.deny blocks listed users from using cron.
* This is the simplest way to deny scheduled-job access for one user.