-g: Specify the primary group for the user. Linux Commands – Overview with Examples and FAQs

Introduction

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.

Examples

Syntax: useradd -g

Example: useradd -g developers john


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

Syntax:

usermod -g [group] [username]

Example:

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.

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet and extranet products.

Resources

Blog

Developer Center

Exchange

FAQ

Contact

[email protected]

+919878044183