The Linux command -g is used to specify the primary group for a user. This command is used to assign a user to a specific group, which will give them access to certain files and directories. The group can be specified by either the group name or the group ID. This command is useful for setting up user permissions and ensuring that users have access to the resources they need.
Syntax: useradd -g
Example: useradd -g developers john
usermod command in Linux allows you to specify the primary group for a user. This command is used to modify a user’s account information, including the user’s primary group.
usermod -g [group] [username]
usermod -g staff john
This command will set the primary group of the user “john” to “staff”.
Note: You must be logged in as root or a user with sudo privileges to run this command.