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

AI Thread Summary
The discussion clarifies the difference between the "usermod -aG" and "usermod -G" commands in Linux. The "usermod -aG" option appends a user to additional groups without removing existing ones, while "usermod -G" replaces all secondary groups with the specified group. An example illustrates that using "usermod -aG project-a" adds the user to the project-a group, while "usermod -G project-c" deletes all other secondary groups and only adds project-c. This distinction is crucial for managing user permissions effectively. Understanding these commands helps prevent unintended group removals in Linux user management.
Technology news on Phys.org
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)
 
thanks for the example.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
hi; i purchased 3 of these, AZDelivery 3 x AZ-MEGA2560-Board Bundle with Prototype Shield and each is reporting the error message below. I have triple checked every aspect of the set up and all seems in order, cable devices port, board reburn bootloader et al . I have substituted an arduino uno and it works fine; could you help please Thanks Martyn 'avrdude: ser_open(): can't set com-state for "\\.\COM3"avrdude: ser_drain(): read error: The handle is invalid.avrdude: ser_send(): write...
Back
Top