Modifying Existing User Account

Key Notes:

You can alter user account information by editing /etc/passwd file. But it is recommended that you use one of the following utilities to avoid any syntax errors:

usermod : Utility to modify existing user accounts.

# usermod -d /usr/people/joe joe
(Changes joe's home directory to /usr/people/joe)

passwd : Change password for an account. You can also use passwd to temporarily lock and unlock an account (without changing a password)

# passwd -l user_name
(Temporarily lock the user from logging in)

# passwd -u user_name
(Unlock the account)

chsh : Change default shell for a user. As a root user you can change default shell for any user. A non-root user can change their own default shell using chsh.

chfn : The finger information can be changed with this command - like the name, phone number, etc.


 
 

Quick test:

Q. While changing UID of an existing user, what should a system administrator take care of ?

a) The new UID should not conflict with another user on the system.
b) Ownership of files owned by the user may need to be manually changed to reflect new UID.
c) This user should not be currently running a process on the system.
d) All of above.

 

Answer:

d) As in case of adding a new user, the system administrator needs to make sure that there is no conflict of User IDs of multiple users. While changing the UID, usermod does change the UID of the files (owned by this user) located in user's home directory. But files outside of the user's home directory need to have their UID updated manually. When using usermod to change UID, administrator also needs to make sure that the corresponding user is not running a process at that time.

 

Q. What will happen if an user called user1 executes this command

     $ passwd user2


     a) The user will be asked user2's password and then new password for user2 with confirmation and user2's password is changed
     b) even if user1 gives the option user2, user1's password is changed instead of user2. This is a known bug.
     c) The passwd command will terminate saying only root can specify the command line parameter of username
     d) user1's password will be set to "user2"
 

Answer

c) A user can only change one's own password and CANNOT change other's password. Root can change anyone's password by giving the userid in the command line.
 

Q. How can you lock an account of a user

    i) lock <userid>
    ii) disable <userid>
    iii) passwd -l <userid>
    iv ) the password is changed and the old password is lost
 

   a) all are correct
   b) only i is correct
   c) i, ii, and iii are correct
   d) iii and iv are correct
 

Answer:

d) passwd -l is used to lock and account and the account remains locked. Once unlocked the user can login to the account with the same old password and need not choose a new password

 

Q. As root I have complete control over system. Which means

 i) I can see users's password
 ii) I can at my wish change user's password

 a) both i and ii are true
 b) only ii is true

 Answer:

b) Even root cannot see the unencrypted password. But root may change anyone's password.
 
 
 
 
Q. An user executes chsh and then wants to change shell to other than the standard shells ( like /bin/ls )  - is this allowed ?

Answer: No. The shell must be listed in /etc/shells. Otherwise the shell is not accepted as usable for users!