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

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

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.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?