bash 从 Mac Os X (El Capitan) 组中删除用户

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35573402/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 14:17:17  来源:igfitidea点击:

remove user from group Mac Os X (El Capitan)

macosbashshell

提问by Marinos K

I'm trying to remove myself from the groups _developer and procmod where I accidentally added it with the following commands:

我正在尝试将自己从 _developer 和 procmod 组中删除,在那里我不小心使用以下命令添加了它:

sudo dseditgroup -o edit -a marinos -t user _developer
sudo dseditgroup -o edit -a marinos -t user procmod

when I idI get this:

id我得到这个时:

uid=501(marinos) gid=20(staff) groups=20(staff),401(com.apple.sharepoint.group.1),9(procmod),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),204(_developer),502(access_bpf),33(_appstore),100(_lpoperator),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh)

to remove I've tried

删除我试过

sudo dscl . -delete /Groups/_developer GroupMembership marinos

and I get this error

我收到这个错误

<main> attribute status: eDSAttributeNotFound
<dscl_cmd> DS Error: -14134 (eDSAttributeNotFound)

and this sudo dscl . -delete /Groups/procmod GroupMembership marinos which results in no error but does not remove me from the group - idreturns the very same groups as before.

和这个 sudo dscl 。-delete /Groups/procmod GroupMembership marinos 这不会导致错误但不会将我从组中删除 -id返回与以前完全相同的组。

I've also tried:

我也试过:

sudo dseditgroup -o edit -u marinos -d procomod user procmod

and I get

我得到

Group not found.

and this:

和这个:

sudo dseditgroup -o edit -u marinos -d procmod user procmod

which results in no errors but has no effect either.. idstill shows that I'm a member in all these groups..

这不会导致任何错误,但也没有任何影响..id仍然表明我是所有这些组的成员..

please help... I'm desperate

请帮助...我很绝望

回答by Istvan

The correct way of removing a user from a group is using the GUID instead of the username:

从组中删除用户的正确方法是使用 GUID 而不是用户名:

dscl . -delete /Groups/<group> GroupMembers <GUID>