There are two type of group concept in linux :primary vs secondary groups,it is simple to create a new group:
sudo groupadd gname
Now i want to know the new created group
gname belongs to which type of group?Is there a way to inter-convert between them?
Create two new group which contain no user
sudo groupadd writers sudo groupadd editers
Add new user.
sudo useradd -m mywriter -p yourpassword sudo useradd -m myediter -p yourpassword
Add new user into group.
sudo usermod -a -G writers mywriter sudo usermod -g editers myediter
Now we get 4 groups.
cat /etc/group | tail -4 writers:x:1007:mywriter editers:x:1008: mywriter:x:1009: myediter:x:1010:
Enter into mywriter
$ touch /tmp/mywriter.txt $ ls -al /tmp/mywriter.txt -rw-r--r-- 1 mywriter mywriter 0 Aug 23 21:24 /tmp/mywriter.txt
Enter into myediter
$ touch /tmp/myedier.txt $ ls -al /tmp/myediter.txt -rw-r--r-- 1 myediter editers 0 Aug 23 21:27 /tmp/myediter.txt
id mywriter uid=1009(mywriter) gid=1009(mywriter) groups=1009(mywriter),1007(writers)
It is a primary group
mywriter since uid=gid=1009.
id myediter uid=1010(myediter) gid=1008(editers) groups=1008(editers)
It is a secondary group?
How to classify group