Difference between "usermod -aG" and "usermod -G" options in linux?

In summary, the conversation discusses the differences between the "usermod -aG" and "usermod -G" options on CentOS 7, with the former adding a user to a secondary group and the latter replacing all secondary groups with a new one. An example scenario is provided to demonstrate the effects of each option.
Technology news on Phys.org
  • #2
Code:
$ id pbuk
uid=1001(pbuk) gid=1002(pbuk) groups=1002(pbuk)
$ # Adds project-a as a secondary group
$ usermod -aG project-a pbuk
$ id pbuk
uid=1001(pbuk) gid=1002(pbuk) groups=1002(pbuk),1003(project-a)
$ # Adds project-b as a secondary group
$ usermod -aG project-b pbuk
$ id pbuk
uid=1001(pbuk) gid=1002(pbuk) groups=1002(pbuk),1003(project-a),1004(project-b)
$ # Deletes all secondary groups then adds project-c as a secondary group
$ # (this is not often what you want to do)
$ usermod -G project-c pbuk
$ id pbuk
uid=1001(pbuk) gid=1002(pbuk) groups=1002(pbuk),1005(project-c)
 
  • #3
thanks for the example.
 

Similar threads

  • Computing and Technology
Replies
24
Views
3K
  • Computing and Technology
Replies
1
Views
2K
  • Programming and Computer Science
Replies
1
Views
652
  • Computing and Technology
Replies
18
Views
1K
Replies
2
Views
1K
Replies
6
Views
1K
  • Programming and Computer Science
Replies
8
Views
5K
  • Programming and Computer Science
Replies
21
Views
1K
Replies
10
Views
2K
  • Programming and Computer Science
Replies
19
Views
1K
Back
Top