What is the command to change the primary group of a user in Linux?

Prepare for the LPIC3 300 Mixed Environment Exam with quiz questions and detailed explanations. Sharpen your skills and ensure success!

The command to change the primary group of a user in Linux is indeed usermod -g newgroup username. This command is specifically designed for modifying user attributes, including changing the primary group associated with a user.

When the usermod command is used with the -g option, it sets the specified group as the user's primary group. The primary group is important because it establishes a default group for file creation and permissions. Thus, the user becomes a member of the newgroup, and this group will be the default group for new files created by that user.

The other options do not correctly apply to changing a user's primary group. Group modification tasks can involve different commands, but only usermod is functionally intended for user attributes, including the primary group. The usage of commands like groupmod, changegroup, or setgroup is not applicable in this context for altering a user's primary group, making usermod the appropriate choice for this operation.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy