0%

mac查询当前用户和用户组命令

以下是macOS用户查询当前用户及用户组信息的命令

查询当前用户所属用户组信息

1
2
3
$ groups
staff everyone localaccounts _appserverusr admin _appserveradm _lpadmin _appstore _lpoperator _developer _analyticsusers
com.apple.access_ftp com.apple.access_screensharing com.apple.access_ssh com.apple.sharepoint.group.1

查询指定用户所属用户组信息

groups <username>

1
2
3
$ groups simon
staff everyone localaccounts _appserverusr admin _appserveradm _lpadmin _appstore _lpoperator _developer _analyticsusers
com.apple.access_ftp com.apple.access_screensharing com.apple.access_ssh com.apple.sharepoint.group.1

查询指定用户的信息

id -a <username>

1
2
3
$ id -a simon
uid=501(simon) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),
98(_lpadmin),33(_appstore),100(_lpoperator),204(_developer),250(_analyticsusers),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh),701(com.apple.sharepoint.group.1)

查询当前用户

1
2
$ whoami
simon

查询所有用户

1
$ cat /etc/passwd