zoukankan      html  css  js  c++  java
  • Show The Groups a User Is In

    /etc/group is a text file which defines the groups on the system. You can use the groups command to display group memberships for any user using the following syntax.

     
    groups
    groups userName-Here
     

    Example

    pen a command-line terminal (select Applications > Accessories > Terminal), and then type:
    $ groups
    Sample outputs:

    vivek cdrom floppy audio dip video plugdev netdev bluetooth scanner

    You are part of all of the above groups. To find group memebership for root user, enter:
    $ groups root
    Sample outputs:

    root : root

    Please note that (from the groups man page):

    Primary and supplementary groups for a process are normally inherited from its parent and are usually unchanged since login. This means that if you change the group database after logging in, groups will not reflect your changes within your existing login session. Running `groups' with a list of users causes the user and group database to be consulted afresh, and so will give a different result.

    You can also use the id command as follows to get the same information:
    $ id -Gn
    $ id -Gn userName
    $ id -Gn vivek

    How Do I Find Out My Primary Group Membership?

    Type the following command:
    $ getent group userName
    $ getent group vivek

    Sample outputs:

    vivek:x:1000:

    In this example, user vivek has group id # 1000 and has group name vivek for primary group membership.

  • 相关阅读:
    给定一个排序数组,你需要在原地删除重复出现的元素
    OSPF-外部路由
    虚链路
    OSPF域间路由计算,防环
    转 C# 只允许运行一个实例
    转 点击关闭时最小化到任务栏
    C#,int转成string,string转成int
    SQL 查找表名 字段名
    C# *= 运算顺序
    SQL 批量删除表
  • 原文地址:https://www.cnblogs.com/smartvessel/p/2957282.html
Copyright © 2011-2022 走看看