RHCSA’s Prep

At the end of last year, I took a training to prepare for Red Hat Certified System Administrator (RHCSA EX200) exam. Now it’s February and I haven’t taken the exam yet. Even worse, I forgot most of the things I learned during that 3 day training. Well, since I’m being chased to get this exam done ASAP, with a passing grade of course, I think now it’s the best time to start revising the material again. As part as the exam prep, I’m going to post small challenges and solutions.

I found a task of the day posted on CertDepot website, a very good resource to learn about Red Hat exam. So, let’s see if can I even do that. Here is the challenge:

Allowed time: 5 minutes.
Create a new user account called “bob” with password “redhat” and set expiration in one week.

My solution:

# man useradd
# useradd -e 2017-02-26 bob
# passwd bob

Time taken: 2 minutes 26 seconds.

I must admit the solution is not the most elegant, as I had to manually calculate 7th day’s date from today (2017-02-19).

Here’s another alternative solution according to this:

# useradd -e `date -d "7 days" +"%Y-%m-%d"` bob
# passwd bob
    Update:

Another way to set the account expiry date is using chage.

# chage -E `date -d "7 days" +"%Y-%m-%d` bob
# chage -l bob
Last password change					: Feb 19, 2017
Password expires					: May 20, 2017
Password inactive					: never
Account expires						: Feb 26, 2017
Minimum number of days between password change		: 0
Maximum number of days between password change		: 90
Number of days of warning before password expires	: 7

Leave a Reply

Your email address will not be published. Required fields are marked *