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. 使用gdb调试(转: http://www.cnblogs.com/luchen927/archive/2012/02/07/2339003.html)

    一般来说GDB主要调试的是C/C++的程序.要调试C/C++的程序,首先在编译时,我们必须要把调试信息加到可执行文件中.使用编译器(cc/gcc/g++)的 -g 参数可以做到这一点.如: > ...

  2. JSON基础知识总结

    JSON基础 一.JSON简介 JSON,全称“JavaScript Object Notation(JavaScript对象表示法)”,起源于JavaScript的对象和数组.JSON,说白了就是J ...

  3. 关于ligerui和其他前端脚本的学习方法(适用于自己)

    特别是看别人的源代码(来源于自己看的那个cms系统),比如ligerui,别人用的juery和ligerui结合的很灵活,比如下面一段代码 var itemiframe = "#framec ...

  4. 清除div浮动的三种方式

    html: <body> <div class="main"> <div class="first"></div> ...

  5. php 使用phpqrcode类生成带有logo的二维码 使logo不失真(透明)

    在开发中 发现phpqrcode类在加入logo时,如果 logo 是 png 图像带有透明区域时,二维码上都无法正常完美的显示出来 解决方法便是:修改phpqrcode文件中的 QRimage类下的 ...

  6. get_magic_quotes_gpc() 内置函数

    get_magic_quotes_gpc()函数 在PHP中是内置的函数,这个函数的作用就是得到php.ini设置中magic_quotes_gpc选项的值. 当magic_quotes_gpc=On ...

  7. Python报错:SyntaxError: Non-ASCII character '\xe5' in file的解决方法

    SyntaxError: Non-ASCII character '\xe5' in file 原因:Python默认是以ASCII作为编码方式的,如果在自己的Python源码中包含了中文(或者其他的 ...

  8. 利用WebApi获取手机号码归属地

    前述: 在WebApi中,涉及到一个重要的类,HttpWebRequest. 学习link:httpwebrequest详解 示例演示: 代码示例: 1.前端代码: @{ ViewBag.Title ...

  9. 实验一:C语言实现DES加解密算法

    计算程序执行10万次需要的时间: 总共需要175秒 加解密一次的时间小于:0.00175秒 纯计算加解密的时间会更短 去除IO操作后的时间 也就是说加解密一次的时间为0.07毫秒 /*-------- ...

  10. JLRoutes--处理复杂的URL schemes-备

    关键字:URL,URL schemes,Parse  代码类库:网络(Networking) GitHub链接:https://github.com/joeldev/JLRoutes   JLRout ...