-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
[ad_1]

[ad_2]

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.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00