UNIX MCQs – User Accounts (Part – 1)

UNIX Question and Answer – User Account Management

UNIX MCQ – Multiple Choice Questions for exam, interview, and Entrance Test

1. What command is used to create a new user account in UNIX?

a) adduser

b) createuser

c) useradd

d) newuser

Answer: c) useradd

Explanation: The useradd command is used to create a new user account in UNIX.


2. Which option is used with the useradd command to specify the home directory for a new user?

a) -d

b) -h

c) -home

d) -dir

Answer: a) -d

Explanation: The -d option with the useradd command is used to specify the home directory for a new user.


3. What command is used to modify the properties of an existing user account in UNIX?

a) edituser

b) modifyuser

c) usermod

d) changepass

Answer: c) usermod

Explanation: The usermod command is used to modify the properties of an existing user account in UNIX.


4. Which option is used with the usermod command to change the username of an existing user?

a) -u

b) -n

c) -name

d) -rename

Answer: b) -n

Explanation: The -n option with the usermod command is used to change the username of an existing user.


5. What command is used to delete a user account in UNIX?

a) deleteuser

b) removeuser

c) userdel

d) deleteaccount

Answer: c) userdel

Explanation: The userdel command is used to delete a user account in UNIX.


6. Which option is used with the userdel command to remove the user’s home directory?

a) -r

b) -d

c) -remove

d) -h

Answer: a) -r

Explanation: The -r option with the userdel command is used to remove the user’s home directory along with the user account.


7. What command is used to change the password for a user account in UNIX?

a) passwd

b) changepass

c) setpass

d) modpass

Answer: a) passwd

Explanation: The passwd command is used to change the password for a user account in UNIX.


8. Which option is used with the passwd command to force a password change at the next login?

a) -f

b) -force

c) -n

d) -next

Answer: a) -f

Explanation: The -f option with the passwd command is used to force a password change at the next login.


9. What command is used to lock a user account in UNIX?

a) lockuser

b) userlock

c) passwd -l

d) usermod -l

Answer: c) passwd -l

Explanation: The passwd -l command is used to lock a user account in UNIX.


10. Which command is used to unlock a previously locked user account in UNIX?

a) unlockuser

b) userunlock

c) passwd -u

d) usermod -u

Answer: c) passwd -u

Explanation: The passwd -u command is used to unlock a previously locked user account in UNIX.


11. What command is used to display information about user accounts in UNIX?

a) users

b) who

c) finger

d) userinfo

Answer: c) finger

Explanation: The finger command is used to display information about user accounts in UNIX.


12. Which option is used with the finger command to display detailed information about a specific user?

a) -u

b) -d

c) -l

d) -user

Answer: c) -l

Explanation: The -l option with the finger command is used to display detailed information about a specific user.


13. What command is used to change the default shell for a user account in UNIX?

a) shell

b) changeshell

c) chsh

d) setshell

Answer: c) chsh

Explanation: The chsh command is used to change the default shell for a user account in UNIX.


14. Which option is used with the chsh command to specify the new shell for a user?

a) -s

b) -shell

c) -new

d) -change

Answer: a) -s

Explanation: The -s option with the chsh command is used to specify the new shell for a user.


15. What command is used to assign additional group memberships to a user account in UNIX?

a) addgroup

b) usergroup

c) usermod -G

d) chgrp

Answer: c) usermod -G

Explanation: The usermod -G command is used to assign additional group memberships to a user account in UNIX.


16. Which option is used with the usermod command to add a user to a supplementary group?

a) -a

b) -add

c) -g

d) -group

Answer: a) -a

Explanation: The -a option with the usermod command is used to add a user to a supplementary group.


17. What command is used to set an expiration date for a user account in UNIX?

a) expdate

b) userexpire

c) passwd -e

d) usermod -e

Answer: d) usermod -e

Explanation: The usermod -e command is used to set an expiration date for a user account in UNIX.


18. Which option is used with the usermod command to specify the expiration date for a user account?

a) -e

b) -expire

c) -d

d) -date

Answer: a) -e

Explanation: The -e option with the usermod command is used to specify the expiration date for a user account.


19. What command is used to set a maximum number of days before a user must change their password in UNIX?

a) passwd -maxdays

b) usermod -maxdays

c) chage -M

d) setmaxpass

Answer: c) chage -M

Explanation: The chage -M command is used to set a maximum number of days before a user must change their password in UNIX.


20. Which option is used with the chage command to set the maximum number of days before password expiration?

a) -m

b) -maxdays

c) -d

d) -days

Answer: b) -maxdays

Explanation: The -maxdays option with the chage command is used to set the maximum number of days before password expiration.


21. What command is used to display the password aging information for a user account in UNIX?

a) age

b) passwd -aging

c) chage

d) aginginfo

Answer: c) chage

Explanation: The chage command is used to display the password aging information for a user account in UNIX.


22. Which option is used with the chage command to display the last password change date for a user?

a) -l

b) -last

c) -d

d) -lastchange

Answer: a) -l

Explanation: The -l option with the chage command is used to display the last password change date for a user.


23. What command is used to set the minimum number of days required before a user can change their password in UNIX?

a) passwd -mindays

b) usermod -mindays

c) chage -m

d) setmindays

Answer: c) chage -m

Explanation: The chage -m command is used to set the minimum number of days required before a user can change their password in UNIX.


24. Which option is used with the chage command to set the minimum number of days before password change?

a) -min

b) -mindays

c) -d

d) -days

Answer: b) -mindays

Explanation: The -mindays option with the chage command is used to set the minimum number of days before password change.


25. What command is used to disable a user account in UNIX?

a) disableuser

b) userdisable

c) usermod -L

d) passwd -disable

Answer: c) usermod -L

Explanation: The usermod -L command is used to disable a user account in UNIX.


26. What command is used to display the list of all users in UNIX?

a) showusers

b) listusers

c) users

d) cat /etc/passwd

Answer: d) cat /etc/passwd

Explanation: The /etc/passwd file contains information about all user accounts in UNIX, and using the cat command on this file displays the list of users.


27. Which option is used with the useradd command to specify the login shell for a new user?

a) -s

b) -shell

c) -login

d) -sh

Answer: a) -s

Explanation: The -s option with the useradd command is used to specify the login shell for a new user.


28. What command is used to display detailed information about a specific user, including their login shell and home directory?

a) userinfo

b) getent passwd

c) id

d) finger

Answer: c) id

Explanation: The id command is used to display detailed information about a specific user, including their user and group IDs, login shell, and home directory.


29. Which option is used with the userdel command to remove a user’s home directory and mail spool?

a) -h

b) -r

c) -delete

d) -purge

Answer: b) -r

Explanation: The -r option with the userdel command is used to remove a user’s home directory and mail spool along with the user account.


30. What command is used to change the group ownership of a file or directory in UNIX?

a) chgrp

b) groupmod

c) chmod

d) chown

Answer: a) chgrp

Explanation: The chgrp command is used to change the group ownership of a file or directory in UNIX.


31. Which option is used with the usermod command to set the expiration date for a user account?

a) -e

b) -expire

c) -expiration

d) -expires

Answer: a) -e

Explanation: The -e option with the usermod command is used to set the expiration date for a user account.


32. What command is used to display the login history of users in UNIX?

a) last

b) history

c) who

d) log

Answer: a) last

Explanation: The last command is used to display the login history of users in UNIX, showing when they last logged in and from where.


33. Which option is used with the chsh command to change the login shell for a user?

a) -l

b) -login

c) -shell

d) -s

Answer: d) -s

Explanation: The -s option with the chsh command is used to change the login shell for a user.


34. What command is used to display information about the groups a user belongs to in UNIX?

a) showgroups

b) groups

c) getent group

d) id

Answer: d) id

Explanation: The id command, when used with a username, displays information about the groups a user belongs to in UNIX.


35. Which option is used with the passwd command to set the password for a user account?

a) -p

b) -password

c) -pass

d) (No option needed)

Answer: (No option needed)

Explanation: When used without options, the passwd command prompts the user to enter a new password for their account.


36. What command is used to change the primary group of a user in UNIX?

a) usermod -g

b) chgrp

c) chown

d) groupmod

Answer: a) usermod -g

Explanation: The usermod -g command is used to change the primary group of a user in UNIX.


37. Which option is used with the useradd command to specify the user ID (UID) for a new user?

a) -i

b) -id

c) -u

d) -uid

Answer: c) -u

Explanation: The -u option with the useradd command is used to specify the user ID (UID) for a new user.


38. What command is used to assign a password to a user account in UNIX?

a) passwd

b) setpass

c) addpass

d) modpass

Answer: a) passwd

Explanation: The passwd command is used to assign a password to a user account in UNIX.


39. Which option is used with the chage command to set the date of the last password change for a user?

a) -l

b) -last

c) -d

d) -lastchange

Answer: d) -lastchange

Explanation: The -lastchange option with the chage command is used to set the date of the last password change for a user.


40. What command is used to display the group ID (GID) associated with a user in UNIX?

a) getent group

b) id

c) groups

d) grep

Answer: b) id

Explanation: The id command displays the user and group IDs associated with a user in UNIX.


41. Which option is used with the chage command to set the minimum number of days required between password changes?

a) -m

b) -mindays

c) -min

d) -minpass

Answer: b) -mindays

Explanation: The -mindays option with the chage command is used to set the minimum number of days required between password changes.


42. What command is used to display the user ID (UID) associated with a username in UNIX?

a) getent passwd

b) id

c) whoami

d) user

Answer: a) getent passwd

Explanation: The getent passwd command is used to display information about user accounts, including the user ID (UID) associated with a username.


43. Which option is used with the usermod command to add a user to a supplementary group?

a) -G

b) -group

c) -add

d) -supp

Answer: a) -G

Explanation: The -G option with the usermod command is used to add a user to a supplementary group.


44. What command is used to set the maximum number of days a password is valid in UNIX?

a) passwd -maxdays

b) usermod -maxdays

c) chage -M

d) setmaxpass

Answer: c) chage -M

Explanation: The chage -M command is used to set the maximum number of days a password is valid in UNIX.


45. Which option is used with the chage command to set the maximum number of days a password is valid?

a) -max

b) -maxdays

c) -m

d) -days

Answer: b) -maxdays

Explanation: The -maxdays option with the chage command is used to set the maximum number of days a password is valid.


46. What command is used to set the expiration date for a user account in UNIX?

a) expire

b) userexpire

c) passwd -e

d) usermod -e

Answer: d) usermod -e

Explanation: The usermod -e command is used to set the expiration date for a user account in UNIX.


47. Which option is used with the usermod command to specify the expiration date for a user account?

a) -e

b) -expire

c) -d

d) -date

Answer: a) -e

Explanation: The -e option with the usermod command is used to specify the expiration date for a user account.


48. What command is used to display information about system groups in UNIX?

a) groups

b) getent group

c) id

d) cat /etc/group

Answer: b) getent group

Explanation: The getent group command is used to display information about system groups in UNIX.


49. Which option is used with the usermod command to set the user’s login shell?

a) -l

b) -login

c) -s

d) -shell

Answer: c) -s

Explanation: The -s option with the usermod command is used to set the user’s login shell.


50. What command is used to display the details of a specific group, including its members?

a) groupinfo

b) getent group

c) id

d) cat /etc/group

Answer: b) getent group

Explanation: The getent group command is used to display the details of a specific group, including its members.

Related Articles

Linux MCQ

Welcome to Linux Multiple Choice Questions (MCQ) Section Embark on a journey through the world of...