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.6 "delgroup" Command – Delete User Group
You will need to delete user groups that are not needed on your system. When deleting a user group, be careful about the user accounts belonging to that group.
When deleting a user group, you can use "delgroup" and "groupdel" commands. The "delgroup" command makes it easy to create user groups. On the other hand, the "groupdel" command can handle relatively detailed processing with very low-level commands, but it is not used for general purposes because it is complex to use.
A user group can be deleted separately, but there is also a method of deleting a users group while deleting a user account. To do this, you can use "deluser" command. For more details, refer to the description of [12.5 "deluser" Command - Delete User ].
The "delgroup" command is used to delete a user group. If you use various options, the system may be secured by checking beforehand whether there is a problem about deleting a user group
[Command Format]
delgroup [options] [--only-if-empty] <group id> |
[Command Overview]
■ This deletes existing user group.
■ User privilege -- Super user.
[Detail Description]
■ The "delgroup" command deletes a user group from the system according to the settings specified in the Shell option and "/etc/deluser.conf" file. Depending on the option, you can delete the home directory, delete all files owned by the user group being deleted, and run the necessary scripts.
■ You can not delete the primary group of a specific user that exists at present. You must first delete the user before deleting the primary group.
■ After the user group has been deleted, you should manually check if all user filesystems that were previously owned by the deleted user group have been deleted.
[Main Option]
-h, --help | Display brief instructions. |
--only-if-empty
| If the option --only-if-empty is given, the group won't be removed if it has any members left. |
--system | Only delete if user/group is a system user/group. This avoids accidentally deleting non-system users/groups. Additionally, if the user does not exist, no error value is returned. This option is mainly for use in Debian package maintainer scripts. |
[Files]
/etc/group | Group account information. |
/etc/gshadow | Secure group account information. |
[Used Example]
We want to delete the existing group "ggroup002". If you look in the "/etc/group" file before doing the delete operation, you can see that "ggroup002" exists.
pi@raspberrypi ~ $ sudo cat /etc/group |
root:x:0: daemon:x:1: ~~~~~ ggroup001:x:1004: ggroup002:x:1005: |
To delete the existing group "ggroup002", do the following task.
pi@raspberrypi ~ $ sudo delgroup ggroup002 |
|
When the operation is complete, check the data in the "/etc/group" file to see the results of the operation. You can see that the group has been deleted.
pi@raspberrypi ~ $ sudo cat /etc/group |
root:x:0: daemon:x:1: ~~~~~ ggroup001:x:1004: |