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 group in UNIX?
a) addgroup
b) groupadd
c) newgroup
d) creategroup
Answer: b) groupadd
Explanation: The groupadd command is used to create a new user group in UNIX.
2. 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.
3. 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.
4. 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.
5. 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.
6. Which option is used with the usermod command to change the user’s login name?
a) -ln
b) -login
c) -rename
d) -name
Answer: b) -login
Explanation: The -login option with the usermod command is used to change the user’s login name in UNIX.
7. What command is used to delete a user group in UNIX?
a) delgroup
b) removegroup
c) groupdel
d) groupdeluser
Answer: c) groupdel
Explanation: The groupdel command is used to delete a user group in UNIX.
8. 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.
9. 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.
10. Which option is used with the chage command to set the maximum number of days before a password must be changed?
a) -M
b) -maxdays
c) -max
d) -expiry
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.
11. 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.
12. Which option is used with the usermod command to set the user’s login shell?
a) -login
b) -shell
c) -s
d) -change
Answer: c) -s
Explanation: The -s option with the usermod command is used to set the user’s login shell in UNIX.
13. 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.
14. 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) -d
d) -min
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.
15. 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.
16. 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.
17. 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.
18. 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.
19. 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.
20. 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.
21. 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.
22. 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.
23. 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.
24. Which option is used with the usermod command to change the user’s login name?
a) -ln
b) -login
c) -rename
d) -name
Answer: b) -login
Explanation: The -login option with the usermod command is used to change the user’s login name in UNIX.
25. What command is used to delete a user group in UNIX?
a) delgroup
b) removegroup
c) groupdel
d) groupdeluser
Answer: c) groupdel
Explanation: The groupdel command is used to delete a user group in UNIX.
26. What command is used to change the expiration date of a user account in UNIX?
a) userexpire
b) chage -E
c) passwd -expire
d) usermod -E
Answer: d) usermod -E
Explanation: The usermod -E command is used to change the expiration date of a user account in UNIX.
27. Which option is used with the useradd command to specify the default home directory for a new user?
a) -h
b) -home
c) -dir
d) -homedir
Answer: b) -home
Explanation: The -home option with the useradd command is used to specify the default home directory for a new user.
28. What command is used to list all users currently logged in to the system in UNIX?
a) who
b) users
c) loggedin
d) listusers
Answer: a) who
Explanation: The who command is used to list all users currently logged in to the system in UNIX.
29. 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.
30. What command is used to change the group ownership of a file or directory in UNIX?
a) chgrp
b) chown
c) grpchg
d) groupmod
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 specify the expiration date for a user account?
a) -expire
b) -expires
c) -expiry
d) -e
Answer: d) -e
Explanation: The -e option with the usermod command is used to specify the expiration date for a user account.
32. What command is used to delete a user from the system in UNIX?
a) userdelete
b) deluser
c) userdel
d) removeuser
Answer: c) userdel
Explanation: The userdel command is used to delete a user from the system in UNIX.
33. Which option is used with the chage command to set the number of days of inactivity after which the account will be disabled?
a) -i
b) -inactive
c) -disable
d) -lock
Answer: b) -inactive
Explanation: The -inactive option with the chage command is used to set the number of days of inactivity after which the account will be disabled.
34. What command is used to add a user to an existing group in UNIX?
a) adduser
b) usermod -G
c) usergroup
d) addtogroup
Answer: b) usermod -G
Explanation: The usermod -G command is used to add a user to an existing group in UNIX.
35. Which option is used with the useradd command to specify the default shell for a new user?
a) -sh
b) -shell
c) -s
d) -defaultshell
Answer: c) -s
Explanation: The -s option with the useradd command is used to specify the default shell for a new user.
36. What command is used to display the details of a specific user in UNIX?
a) userinfo
b) getent passwd
c) id
d) cat /etc/passwd
Answer: b) getent passwd
Explanation: The getent passwd command is used to display the details of a specific user in UNIX.
37. 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.
38. What command is used to display the list of users who have logged in at least once in UNIX?
a) last
b) lastlog
c) logins
d) who
Answer: b) lastlog
Explanation: The lastlog command is used to display the list of users who have logged in at least once in UNIX.
39. Which option is used with the usermod command to add a user to a secondary group?
a) -G
b) -g
c) -S
d) -secondary
Answer: a) -G
Explanation: The -G option with the usermod command is used to add a user to a secondary group in UNIX.
40. What command is used to change the group ownership of a file or directory in UNIX?
a) chgrp
b) chown
c) grpchg
d) groupmod
Answer: a) chgrp
Explanation: The chgrp command is used to change the group ownership of a file or directory in UNIX.
41. Which option is used with the useradd command to specify the default home directory for a new user?
a) -h
b) -home
c) -dir
d) -homedir
Answer: b) -home
Explanation: The -home option with the useradd command is used to specify the default home directory for a new user.
42. What command is used to list all users currently logged in to the system in UNIX?
a) who
b) users
c) loggedin
d) listusers
Answer: a) who
Explanation: The who command is used to list all users currently logged in to the system in UNIX.
43. 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.
44. What command is used to change the expiration date of a user account in UNIX?
a) userexpire
b) chage -E
c) passwd -expire
d) usermod -E
Answer: d) usermod -E
Explanation: The usermod -E command is used to change the expiration date of a user account in UNIX.
45. 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.
46. What command is used to list all users currently logged in to the system in UNIX?
a) who
b) users
c) loggedin
d) listusers
Answer: a) who
Explanation: The who command is used to list all users currently logged in to the system in UNIX.
47. 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.
48. What command is used to change the expiration date of a user account in UNIX?
a) userexpire
b) chage -E
c) passwd -expire
d) usermod -E
Answer: d) usermod -E
Explanation: The usermod -E command is used to change the expiration date of a user account in UNIX.
49. 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.
50. What command is used to list all users currently logged in to the system in UNIX?
a) who
b) users
c) loggedin
d) listusers
Answer: a) who
Explanation: The who command is used to list all users currently logged in to the system in UNIX.