如何获取不在特定组中的用户列表-UNIX AIX [英] How to get list of users not in a particular group - unix aix

查看:145
本文介绍了如何获取不在特定组中的用户列表-UNIX AIX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检索特定组中不存在的用户列表.

I am trying to retrieve the list of users who are not present in a particular group.

我们正在尝试通过UNIX AIX服务器使用用户凭证来验证应用程序,并且该用户应存在于特定的组中.现在,我们需要获取不在该组中的用户列表(用于在各种测试场景下进行测试).

We are trying to validate an application with the user credentials through unix AIX server and the user should be present in a particular group. For now, we need to get the list of users who are not in the group (for our testing with various test scenarios).

我尝试了以下命令来列出组中的用户.

I tried the below command to list users in a group.

" lsgroup -a用户组名"

请帮助我如何使用NOT!上面命令的运算符,或者让我知道是否还有其他方法可以使用户不在组中.

Please help me how to use NOT ! operator for the above command or let me know if there is any other way to get users not in a group.

-Suriya

推荐答案

我希望这可以帮助您...简单的方法:

I hope this helps you ... easy way:

cat /etc/passwd | grep groupID GID

您可以使用带有特定组GID的grep进行过滤. 例如,您可以使用root用户组ID来root用户:

You can filter using grep with specific group GID. For example you can root users using root group ID:

cat /etc/passwd | grep 0 

,或者如果要列出所有用户及其组名,则可以使用此

or if you want to list all the users with their group name you can use this

awk -F':' 'NR==FNR{ a[$3]=$1; next }{ print $1", "a[$4] }' /etc/group /etc/passwd

这篇关于如何获取不在特定组中的用户列表-UNIX AIX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆