0% found this document useful (0 votes)
57 views

User Creation With Specific Properties

The document discusses creating two users, john and davis, with specific UID, GID, and passwords. It recommends using the useradd command to create the users, and the passwd command to set their passwords. It also shows how to use the chage and passwd commands to set davis' account to expire in one month.

Uploaded by

Maher Mechi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

User Creation With Specific Properties

The document discusses creating two users, john and davis, with specific UID, GID, and passwords. It recommends using the useradd command to create the users, and the passwd command to set their passwords. It also shows how to use the chage and passwd commands to set davis' account to expire in one month.

Uploaded by

Maher Mechi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

User creation with specific properties

Question:
Create two users: john with uid/gid equal to 2000, password 12345678 and davis with uid/gid
equal to 3000, password 87654321. Make davis' account validity stopping in one month.

(scroll down for an answer)


Answer:
The best command for user creation and editing are these starting with user -
so useradd and usermod.

useradd -u 2000 john


passwd john
# here provide password for john

useradd -u 3000 davis


passwd davis
# here provide password for davis

Right now is the time to change validity of davis account. On my system (CentOS) I've run:

[root@centos1 ~]# chage -l davis


Last password change : Sep 14, 2019
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7

Given that we know the current date we can set expiry date manually:

passwd -e 2019-10-14 davis

Additional comment:
Remember there is a difference between password expiration and account validation. It is usually
better to expire password and make user not being able to log into the system or disable the user,
rather than deleting it.

usermod command is also used for adding/removing users to the group (groupmodcommand


does not do that)

Trying to create user with already taken UID will result in an error.

During user's creation with useradd command the structure of home direcotry is taken


from /etc/skel folder.

You might also like