Task: As part of the temporary assignment to the Nautilus
project, a developer named jim
requires access for a limited duration. To ensure smooth access management, a temporary user account with an expiry date is needed.
ssh banner@172.16.238.12
sudo useradd -e 2024-03-28 jim
sudo chage -l jim
sudo useradd -e 2024-03-28 jim
<- The -e
allows for the setting of the date upon which the account will automatically expire.sudo chage -l jim
<- Verify the expiration for the user we just add 'jim' has the correct expiration date.
What happens after the expiry date?
- The user will not be able to login after the date has passed
- The account will be disabled, but it is not deleted
- The account can be re-enabled by extending the expiry date, use the same command as above with a date in the future
Optional Flags:-s /sbin/nologin
<- prevent shell access-m
<- create a home directory-d /custom/path
<- specify a home directory path
Final Command if using optional flags would be:sudo adduser -e 2024-03-28 -m -s /sbin/nologin jim