sg | usermod -g primarygroup username | newgrp | groupmod | gpasswd | chown
The primary group is the group applied to you when you log in using the usual methods (TTYs, GUI, SSH, etc.).
Since processes usually inherit the group of the parent, and your initial process or shell would have your primary group as the group, anything you do usually has the effect of the primary group on it (creating files, for example).
The secondary groups are the groups you can start processes as without using a group password, either via
sg
or to log in to via the newgrp
command.ubuntu@ubuntu:~/Documents/testadmin$ groups
ubuntu adm cdrom sudo dip www-data plugdev lpadmin sambashare
ubuntu@ubuntu:~/Documents/testadmin$ sg dip 'touch file2'
ubuntu@ubuntu:~/Documents/testadmin$ ll
total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Dec 11 05:58 ./
drwxr-xr-x 5 ubuntu ubuntu 4096 Dec 11 05:57 ../
-rw-rw-r-- 1 ubuntu ubuntu 0 Dec 11 05:57 file1
-rw-rw-r-- 1 ubuntu dip 0 Dec 11 05:58 file2
ubuntu@ubuntu:~/Documents/testadmin$ sudo usermod -g dip ubuntu
ubuntu@ubuntu:~/Documents/testadmin$ touch file3
ubuntu@ubuntu:~/Documents/testadmin$ ll
total 8
drwxrwxr-x 2 ubuntu dip 4096 Dec 11 06:07 ./
drwxr-xr-x 5 ubuntu dip 4096 Dec 11 05:57 ../
-rw-rw-r-- 1 ubuntu dip 0 Dec 11 05:57 file1
-rw-rw-r-- 1 ubuntu dip 0 Dec 11 05:58 file2
-rw-rw-r-- 1 ubuntu ubuntu 0 Dec 11 06:07 file3
ubuntu@ubuntu:~/Documents/testadmin$ sudo usermod -g ubuntu ubuntu
ubuntu@ubuntu:~/Documents/testadmin$ touch file4
ubuntu@ubuntu:~/Documents/testadmin$ ll
total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Dec 11 06:07 ./
drwxr-xr-x 5 ubuntu ubuntu 4096 Dec 11 05:57 ../
-rw-rw-r-- 1 ubuntu ubuntu 0 Dec 11 05:57 file1
-rw-rw-r-- 1 ubuntu ubuntu 0 Dec 11 05:58 file2
-rw-rw-r-- 1 ubuntu ubuntu 0 Dec 11 06:07 file3
-rw-rw-r-- 1 ubuntu ubuntu 0 Dec 11 06:07 file4
ubuntu@ubuntu:~/Documents/testadmin$
- newgrp: log into a new group
- sg: execute a command as a different group ID
- groupmod: modify a group definition (e.g., the group ID, group name, or password)
- gpasswd: administer /etc/group and /etc/gshadow files (every group can have administrators, members, and a password)
- chown or chgrp: change individual or group ownership of a file or directory
Comments
Post a Comment