UNIX MCQs – User Accounts (Part – 4)

UNIX Question and Answer – User Account Management

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

1. Which command is used to display the current user’s login shell in UNIX?

a) shell

b) sh

c) currentshell

d) echo $SHELL

Answer: d) echo $SHELL

Explanation: The command “echo $SHELL” is used to display the current user’s login shell in UNIX.


2. Which option is used with the chsh command to specify the new login 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 login shell for a user.


3. What command is used to change the login shell for a user in UNIX?

a) changeshell

b) shellchange

c) chsh

d) changelogin

Answer: c) chsh

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


4. Which file contains the list of all valid user accounts in UNIX?

a) /etc/users

b) /etc/passwd

c) /etc/accounts

d) /etc/login

Answer: b) /etc/passwd

Explanation: The /etc/passwd file contains the list of all valid user accounts in UNIX.


5. 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.


6. Which option is used with the passwd command to disable password aging for a user account?

a) -n

b) -noage

c) -disable

d) -agingoff

Answer: c) -disable

Explanation: The -disable option with the passwd command is used to disable password aging for a user account.


7. What command is used to display the expiration date of a user account in UNIX?

a) expdate

b) userexpire

c) chage -l

d) usermod -l

Answer: c) chage -l

Explanation: The chage -l command is used to display the expiration date of a user account in UNIX.


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

a) -last

b) -lastchange

c) -lc

d) -pwdchange

Answer: b) -lastchange

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


9. What command is used to change 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 change the expiration date for a user account in UNIX.


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

a) -e

b) -expires

c) -expiry

d) -expire

Answer: a) -e

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


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

a) getent group

b) id

c) groups

d) grep

Answer: a) getent group

Explanation: The getent group command is used to display the group ID (GID) associated with a group name in UNIX.


12. Which option is used with the usermod command to change the user’s primary group?

a) -p

b) -primarygroup

c) -pg

d) -g

Answer: d) -g

Explanation: The -g option with the usermod command is used to change the user’s primary group in UNIX.


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

a) passwd -aging

b) chage

c) aginginfo

d) pwdaging

Answer: b) chage

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


14. Which option is used with the chage command to set the maximum number of days before a password must be changed?

a) -max

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 a password must be changed.


15. 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.


16. Which option is used with the chage command to set the minimum number of days before a password can be changed?

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 before a password can be changed.


17. 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.


18. Which option is used with the usermod command to add a user to multiple groups simultaneously?

a) -G

b) -addGroup

c) -group

d) -add

Answer: a) -G

Explanation: The -G option with the usermod command is used to add a user to multiple groups simultaneously in UNIX.


19. What command is used to remove a user from a group in UNIX?

a) removeuser

b) delgroup

c) groupdel

d) userdel -G

Answer: d) userdel -G

Explanation: The userdel -G command is used to remove a user from a group in UNIX.


20. Which option is used with the chsh command to change the user’s login shell?

a) -s

b) -shell

c) -login

d) -change

Answer: a) -s

Explanation: The -s option with the chsh command is used to change the user’s login shell in UNIX.


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

a) primarygroup

b) usergroup

c) chgrp

d) usermod -g

Answer: d) usermod -g

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


22. Which option is used with the chage command to set the maximum number of weeks before a password must be changed?

a) -W

b) -maxweeks

c) -w

d) -weeks

Answer: a) -W

Explanation: The -W option with the chage command is used to set the maximum number of weeks before a password must be changed.


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

a) userdisable

b) disableuser

c) usermod -L

d) passwd -disable

Answer: c) usermod -L

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


24. Which option is used with the useradd command to specify the default group for a new user?

a) -g

b) -group

c) -default

d) -defgroup

Answer: a) -g

Explanation: The -g option with the useradd command is used to specify the default group for a new user.


25. What command is used to display the list of groups a user belongs to in UNIX?

a) showgroups

b) groups

c) usergroups

d) getent passwd

Answer: b) groups

Explanation: The groups command is used to display the list of groups a user belongs to in UNIX.


26. Which option is used with the chage command to set the number of days of warning before a password expires?

a) -W

b) -warn

c) -warning

d) -expirewarning

Answer: b) -warn

Explanation: The -warn option with the chage command is used to set the number of days of warning before a password expires.


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

a) pwdaging

b) passchange

c) chage

d) agingmodify

Answer: c) chage

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


28. Which option is used with the chsh command to change the user’s login shell?

a) -sh

b) -shell

c) -login

d) -change

Answer: b) -shell

Explanation: The -shell option with the chsh command is used to change the user’s login shell in UNIX.


29. What 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.


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

a) -expires

b) -expiry

c) -expiration

d) -e

Answer: d) -e

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


31. What command is used to remove a user from the system along with their home directory in UNIX?

a) userdel -r

b) deluser -r

c) userremove -r

d) removeuser -r

Answer: a) userdel -r

Explanation: The userdel -r command is used to remove a user from the system along with their home directory in UNIX.


32. Which option is used with the passwd command to unlock a previously locked user account?

a) -u

b) -unlock

c) -unlockuser

d) -l

Answer: a) -u

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


33. What command is used to disable password aging for a user account in UNIX?

a) passwd -agingoff

b) chage -m 0

c) usermod -n

d) agingdisable

Answer: b) chage -m 0

Explanation: The chage -m 0 command is used to disable password aging for a user account in UNIX.


34. Which file contains the encrypted passwords of all user accounts in UNIX?

a) /etc/passwords

b) /etc/shadow

c) /etc/users

d) /etc/passwd

Answer: b) /etc/shadow

Explanation: The /etc/shadow file contains the encrypted passwords of all user accounts in UNIX.


35. What command is used to assign a password to a user account in UNIX without prompting for the old password?

a) passwd -n

b) passwd -stdin

c) passwd -y

d) passwd -w

Answer: c) passwd -y

Explanation: The passwd -y command is used to assign a password to a user account in UNIX without prompting for the old password.


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

a) -expires

b) -expiry

c) -expiration

d) -e

Answer: d) -e

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


37. What command is used to remove a user from the system along with their home directory in UNIX?

a) userdel -r

b) deluser -r

c) userremove -r

d) removeuser -r

Answer: a) userdel -r

Explanation: The userdel -r command is used to remove a user from the system along with their home directory in UNIX.


38. Which option is used with the passwd command to unlock a previously locked user account?

a) -u

b) -unlock

c) -unlockuser

d) -l

Answer: a) -u

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


39. What command is used to disable password aging for a user account in UNIX?

a) passwd -agingoff

b) chage -m 0

c) usermod -n

d) agingdisable

Answer: b) chage -m 0

Explanation: The chage -m 0 command is used to disable password aging for a user account in UNIX.


40. Which file contains the encrypted passwords of all user accounts in UNIX?

a) /etc/passwords

b) /etc/shadow

c) /etc/users

d) /etc/passwd

Answer: b) /etc/shadow

Explanation: The /etc/shadow file contains the encrypted passwords of all user accounts in UNIX.


41. What command is used to assign a password to a user account in UNIX without prompting for the old password?

a) passwd -n

b) passwd -stdin

c) passwd -y

d) passwd -w

Answer: c) passwd -y

Explanation: The passwd -y command is used to assign a password to a user account in UNIX without prompting for the old password.


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

a) -expires

b) -expiry

c) -expiration

d) -e

Answer: d) -e

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


43. What command is used to remove a user from the system along with their home directory in UNIX?

a) userdel -r

b) deluser -r

c) userremove -r

d) removeuser -r

Answer: a) userdel -r

Explanation: The userdel -r command is used to remove a user from the system along with their home directory in UNIX.


44. Which option is used with the passwd command to unlock a previously locked user account?

a) -u

b) -unlock

c) -unlockuser

d) -l

Answer: a) -u

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


45. What command is used to disable password aging for a user account in UNIX?

a) passwd -agingoff

b) chage -m 0

c) usermod -n

d) agingdisable

Answer: b) chage -m 0

Explanation: The chage -m 0 command is used to disable password aging for a user account in UNIX.


46. Which file contains the encrypted passwords of all user accounts in UNIX?

a) /etc/passwords

b) /etc/shadow

c) /etc/users

d) /etc/passwd

Answer: b) /etc/shadow

Explanation: The /etc/shadow file contains the encrypted passwords of all user accounts in UNIX.


47. What command is used to assign a password to a user account in UNIX without prompting for the old password?

a) passwd -n

b) passwd -stdin

c) passwd -y

d) passwd -w

Answer: c) passwd -y

Explanation: The passwd -y command is used to assign a password to a user account in UNIX without prompting for the old password.


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

a) -expires

b) -expiry

c) -expiration

d) -e

Answer: d) -e

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


49. What command is used to remove a user from the system along with their home directory in UNIX?

a) userdel -r

b) deluser -r

c) userremove -r

d) removeuser -r

Answer: a) userdel -r

Explanation: The userdel -r command is used to remove a user from the system along with their home directory in UNIX.


50. Which option is used with the passwd command to unlock a previously locked user account?

a) -u

b) -unlock

c) -unlockuser

d) -l

Answer: a) -u

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

Related Articles

Linux MCQ

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