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


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


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.


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.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman


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.


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