Because users group membership is defined in two different locations, it can be difficult to find out which groups exactly a user is a member of. A convenient command to check this is  groupmems . Use, for example, the command  groupmems -g sales -l  to see which users are a member of the group sales. This shows users who are a member of this group as a secondary group assignment, but also users who are a member of this group as the primary group assignment.

[root@rhel7 ~]# groupmems --help
Usage: groupmems [options] [action] Options:
-g, --group groupname change groupname instead of the user's group
(root only)
-R, --root CHROOT_DIR directory to chroot into Actions:
-a, --add username add username to the members of the group
-d, --delete username remove username from the members of the group
-h, --help display this help message and exit
-p, --purge purge all members from the group
-l, --list list the members of the group

例:

查看有哪些用户属于sales组

[root@rhel7 ~]# groupmems -g sales -l
linda lisa

从sales组中删除lisa

[root@rhel7 ~]# groupmems -d lisa -g sales
[root@rhel7 ~]# groupmems -g sales -l
linda

添加用户到组里

[root@rhel7 ~]# id lxj2
uid=(lxj2) gid=(root) groups=(root)
[root@rhel7 ~]# groupmems -a lxj2 -g sales
[root@rhel7 ~]# id lxj2
uid=(lxj2) gid=(root) groups=(root),(sales)

也可以使用usermod命令将用户添加到组里 

usermod -aG  will add users to new groups that will be used as their secondary group.

Use  usermod  to add users linda and lisa to the group sales, and lori and bob to the group account:

usermod -aG sales linda
usermod -aG sales lisa
usermod -aG account lori
usermod -aG account bob

linux groupmems命令的更多相关文章

  1. linux grep命令

    linux grep命令1.作用Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expressio ...

  2. Linux常用命令(一)

    Linux常用命令 1. pwd查看当前路径(Print Working Directory)    [root@CentOS ~]# pwd/root 2. cd .. 返回上一级 .. 表示上一级 ...

  3. Linux下命令行安装weblogic10.3.6

    Linux下命令行安装weblogic10.3.6 一.安装前准备工作: 1.创建用户useradd weblogic;创建用户成功linux系统会自动创建一个和用户名相同的分组,并将该用户分到改组中 ...

  4. Linux paste命令

    Linux paste命令用于合并文件的列. paste指令会把每个文件以列对列的方式,一列列地加以合并. 语法 paste [-s][-d <间隔字符>][--help][--versi ...

  5. 20145222《信息安全系统设计基础》Linux常用命令汇总

    学习Linux时常用命令汇总 通过Ctrl+f键可在该网页搜索到你想要的命令. Linux中命令格式为:command [options] [arguments] //中括号代表是可选的,即有些命令不 ...

  6. Linux sudo 命令的应用

    .note-content { font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", STHeit ...

  7. linux 基础命令与文件管理

      Linux终端介绍 Shell提示符 Bash Shell基本语法 基本命令的使用:ls.pwd.cd 查看系统和BIOS硬件时间 Linux如何获得帮助 Linux关机命令:shutdow.in ...

  8. linux awk命令详解

    linux awk命令详解 简介 awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大.简单来说awk就是把文件逐行的读入,以空格为默认分 ...

  9. linux常用命令的介绍

    本文主要介绍Linux常用命令工具,比如用户创建,删除,文件管理,常见的网络命令等 如何创建账号: 1. 创建用户 useradd -m username -m 表示会在/home 路径下添加创建用户 ...

随机推荐

  1. TCP/IP-IP

    A contented mind is a perpetual feast. "知足长乐" 参考资料:TCP/IP入门经典 (第五版) TCP/IP详解 卷一:协议 一.简介 IP ...

  2. jquery选择器专题

    $(“p”).addClass(css中定义的样式类型); 给某个元素添加样式$(“img”).attr({src:”test.jpg”,alt:”test Image”}); 给某个元素添加属性/值 ...

  3. centos git 升级应用

    在阿里云服务器上部署Git 升级centos 自带的Git yum库自带版本为git1.7.1-3.el6_4.1. -------------------升级-------------------- ...

  4. 看源码之Adapter和AdapterView之间的关系

    总述 Android中"列表"的实现其实一个典型的MVC模式,其实中AdapterView相当于是View,负责视图的绘制以及视图的事件响应,Adapter相当于是Controll ...

  5. 教你怎样在ppt2010抠图的小技巧|用ppt2010抠图的方法

    我们经常在ppt2010里做幻灯片时会碰到插入的图片并不是我们想要的情况,有的图片只是想要其中的一个部分.我们用“裁剪”功能也是达不到自己想要的效果.有的人会说PS抠图啊,但是比较繁琐,不易懂,不好上 ...

  6. PHP之路——MySql查询语句

    1,select查询的基本结构 select 字段 from 表 where 过滤条件 group by 分组条件 having 过滤的第二条件 order by 排序条件 limit 限定结果条件; ...

  7. Node.js stream 流学习

    由于node.js 创建http 是这样的 http.createServer(function(request,response){}).listen(2000); 里面的request 就是rea ...

  8. javascript language

    function class(function, this, prototype) closure与function expression没有任何关系. closure必然与function联系在一起 ...

  9. JAVA抽象类,接口,多态,抽象方法,一次列举

    HEAD FIRST这系列的书,真的让人产生阅读的快感~~:) 和那套明日科技的一样,.. interface Nose { public int iMethod(); } abstract clas ...

  10. java四种创建对象的方法

    1.用new语句创建对象,这是最常见的创建对象的方法.   2.运用反射手段,调用java.lang.Class或者java.lang.reflect.Constructor类的newInstance ...