• About Us
  • Privacy & Policy
HowTo's
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
HowTo's
No Result
View All Result
Home Commands

Adding Supplementary Groups to User Accounts in Linux

June 21, 2024
in Commands, Linux, Linux Command Tutorial, Linux Commands
A A
0
12
SHARES
106
VIEWS
Share on FacebookShare on Twitter

The useradd command in Linux is used to create a new user account. One of its options, -G or --groups, allows adding supplementary groups to a user account. This option is particularly useful when you want to grant additional group permissions to a user beyond their primary group.

Here are several examples illustrating the usage of useradd with the -G option:

Example 1: Adding a user ‘john’ and assigning supplementary groups ‘admin’ and ‘sudo’.

    $ sudo useradd -G admin,sudo john
    

This command creates a new user ‘john’ and adds him to the ‘admin’ and ‘sudo’ groups.

Example 2: Creating a user ‘alice’ and adding her to the ‘staff’ group.

    $ sudo useradd -G staff alice
    

Here, the user ‘alice’ is created with membership in the ‘staff’ group.

Example 3: Adding a user ‘sam’ to multiple groups ‘developers’ and ‘docker’.

    $ sudo useradd -G developers,docker sam
    

This command sets up the user ‘sam’ with both ‘developers’ and ‘docker’ group memberships.

Example 4: Creating a user ‘jane’ and adding her to ‘ftp’ group for file transfer permissions.

    $ sudo useradd -G ftp jane
    

Here, ‘jane’ is added to the ‘ftp’ group, typically used for FTP file transfers.

Example 5: Adding a user ‘bob’ to ‘audio’ group for sound device access.

    $ sudo useradd -G audio bob
    

This command grants ‘bob’ access to audio devices by adding him to the ‘audio’ group.

Example 6: Creating a user ‘tom’ and assigning him to ‘video’ group.

    $ sudo useradd -G video tom
    

Here, ‘tom’ is included in the ‘video’ group, useful for video device permissions.

Example 7: Adding a user ‘max’ to ‘games’ group for gaming-related access.

    $ sudo useradd -G games max
    

This command allows ‘max’ to access gaming-related resources through the ‘games’ group.

Example 8: Creating a user ‘sarah’ and assigning her to ‘docker’ and ‘wheel’ groups.

    $ sudo useradd -G docker,wheel sarah
    

Here, ‘sarah’ gains membership in both ‘docker’ and ‘wheel’ groups, enabling Docker and administrative privileges.

Example 9: Adding a user ‘tim’ to ‘mail’ group for email server access.

    $ sudo useradd -G mail tim
    

This command configures ‘tim’ with access to mail services through the ‘mail’ group.

Example 10: Creating a user ‘anna’ and assigning her to ‘finance’ group for financial data access.

    $ sudo useradd -G finance anna
    

Here, ‘anna’ is given access to financial data by joining the ‘finance’ group.

Verification Steps: To verify whether the user has been successfully added to the specified groups, you can use the id command followed by the username:

    $ id john
    uid=1001(john) gid=1001(john) groups=1001(john),27(sudo),5(admin)
    

In this output, the supplementary groups ‘sudo’ and ‘admin’ are listed under the groups section for user ‘john’, confirming the addition.

Tags: CommandsLinuxLinux Command TutorialLinux Commands
Previous Post

Assigning Primary Group for New User Accounts in Linux

Next Post

Using Custom Skeleton Directories for User Accounts in Linux

Related You may like!

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024

Find Files by Group Name with -group in find Command

August 21, 2024

Locate Files by Group ID Using -gid in find Command

August 21, 2024

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Use -false to Test Conditional Expressions in find Command

August 21, 2024
Next Post
howto

Using Custom Skeleton Directories for User Accounts in Linux

howto

Overriding Default Settings with Useradd Key-Value Pairs in Linux

howto

Managing User Database Entries with Useradd Command

Discussion about this post

Latest Updated

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024
howto

Find Files by Group Name with -group in find Command

August 21, 2024
howto

Locate Files by Group ID Using -gid in find Command

August 21, 2024
howto

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Trending in Week

  • howto

    Using BTRFS Subvolume for User Home Directory in Linux

    22 shares
    Share 9 Tweet 6
  • Downloading Docker Images from a Registry

    13 shares
    Share 5 Tweet 3
  • Configuring SSL Connection Mode in mysqldump

    17 shares
    Share 7 Tweet 4
  • Omit Tablespace Information in mysqldump Output

    13 shares
    Share 5 Tweet 3
  • Setting MySQL Dump Compatibility Mode

    18 shares
    Share 7 Tweet 5
  • Setting Network Buffer Length in mysqldump

    13 shares
    Share 5 Tweet 3
  • Logging out from Docker Registries

    13 shares
    Share 5 Tweet 3
  • Scheduling Nodes in Kubernetes with kubectl uncordon

    12 shares
    Share 5 Tweet 3
  • Managing Default User Creation Settings in Linux

    15 shares
    Share 6 Tweet 4
  • Using Extended INSERT Syntax in mysqldump

    12 shares
    Share 5 Tweet 3
  • About Us
  • Privacy & Policy

© 2024 All Rights Reserved. Howto.swebtools.com.

No Result
View All Result

© 2024 All Rights Reserved. Howto.swebtools.com.