Raspberry Pi_Eng_12.7.4 Managing Relationship between User and User Group


Published Book on Amazon


All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


12.7.4  Managing Relationship between User and User Group

                                                                                         

Raspberry Pi uses several ways to manage the relationship between user groups and users.

 

If the user account is not assigned to a separate group, but is assigned only to its own self group, the primary group, the relationship is defined using "/etc/passwd" file.

 

The following data is to confirm the "/etc/passwd" file and "/etc/group" file after the user accounts "guser001" and "guser002" is created in the system. If you check the user group "guser001", you can see that an id of "1004" is assigned, and the same id is specified in the user "guser001" in "/etc/passwd" file.

 

pi@raspberrypi ~ $ sudo cat /etc/group

root:x:0:

daemon:x:1:

~~~~~

guser001:x:1004:

guser002:x:1005:

ggroup001:x:1006:

ggroup002:x:1007:

 

pi@raspberrypi ~ $ sudo cat /etc/passwd

root:x:0:0:root:/root:/bin/bash

daemon:x:1:1:daemon:/usr/sbin:/bin/sh

~~~~~

guser001:x:1001:1004:General User 001,,,:/home/guser001:/bin/bash

guser002:x:1002:1005:General User 002,,,:/home/guser002:/bin/bash

 

If multiple user accounts are specified for a particular user group, the "/etc/group" file is used to manage that information. If a particular group contains multiple user accounts, the list is assigned and managed in the group.

 

The next is to check the data in "/etc/group" file after assigning group "ggroup001" to user account "guser001". It can be confirmed that the contents of the corresponding user are changed as follows. It is possible to confirm that the user account "guser001" is specified for the user group "ggroup001".

 

pi@raspberrypi ~ $ sudo cat /etc/group

root:x:0:

daemon:x:1:

~~~~~

guser001:x:1004:

guser002:x:1005:

ggroup001:x:1006:guser001

ggroup002:x:1007: