将一个用户添加到用户组中,千万不能直接用: 
usermod -G groupA

这样做会使你离开其他用户组,仅仅做为 这个用户组 groupA 的成员。 
应该用 加上 -a 选项: 
usermod -a -G groupA user

(FC4: usermod -G groupA,groupB,groupC user)
-a 代表 append, 也就是 将自己添加到 用户组groupA 中,而不必离开 其他用户组。

命令的所有的选项,及其含义: 
Options: 
-c, --comment COMMENT         new value of the GECOS field 
-d, --home HOME_DIR           new home directory for the user account 
-e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE 
-f, --inactive INACTIVE       set password inactive after expiration 
                                to INACTIVE 
-g, --gid GROUP               force use GROUP as new primary group 
-G, --groups GROUPS           new list of supplementary GROUPS 
-a, --append          append the user to the supplemental GROUPS 
                                mentioned by the -G option without removing 
                                him/her from other groups 
-h, --help                    display this help message and exit 
-l, --login NEW_LOGIN         new value of the login name 
-L, --lock                    lock the user account 
-m, --move-home               move contents of the home directory to the new 
                                location (use only with -d) 
-o, --non-unique              allow using duplicate (non-unique) UID 
-p, --password PASSWORD       use encrypted password for the new password 
-s, --shell SHELL             new login shell for the user account 
-u, --uid UID                 new UID for the user account 
-U, --unlock                  unlock the user account

查看用户所属的组使用命令:$ groups user

或者查看文件:$ cat /etc/group

Linux添加用户(user)到用户组(group)的更多相关文章

  1. Linux添加用户user到用户组group

    添加用户:useradd niot 添加到组:usermod -a -G root niot 改密码:passwd niot 切换:su - niot 查看用户组:groups 将一个用户添加到用户组 ...

  2. Linux 添加用户(user),组(Group)以及权限(Permission)

    1. 添加用户 sudo adduser UserName 异常: sudo adduser --force-badname <username> 之后为这个用户添加其他辅助信息 切换用户 ...

  3. linux添加用户、用户组、权限

    # useradd –d /usr/sam -m sam 此命令创建了一个用户sam,其中-d和-m选项用来为登录名sam产生一个主目录/usr/sam(/usr为默认的用户主目录所在的父目录). 假 ...

  4. linux 添加用户、权限

    # useradd –d /usr/sam -m sam 此命令创建了一个用户sam,其中-d和-m选项用来为登录名sam产生一个主目录/usr/sam(/usr为默认的用户主目录所在的父目录). 假 ...

  5. linux 添加用户并赋予root权限

    1.添加用户,首先用adduser命令添加一个普通用户,命令如下: #adduser tommy //添加一个名为tommy的用户#passwd tommy   //修改密码Changing pass ...

  6. Windows与linux添加用户命令

    Windows 查看当前存在用户: net user 查看当前用户组: net localgroup 添加用户(以添加用户test密码test1234为例): net user test test12 ...

  7. linux添加用户、权限

    # useradd –d /usr/sam -m sam 此命令创建了一个用户sam,其中-d和-m选项用来为登录名sam产生一个主目录/usr/sam(/usr为默认的用户主目录所在的父目录). 假 ...

  8. Redhat 下添加用户到docker用户组

    1. 检查系统中是否存在docker用户组,如果没有则手动添加 # sudo cat /etc/group |grep docker # sudo grouped -g 999 docker # -g ...

  9. 怎么添加用户到sudo用户组

    跨平台系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#linux 前段时间用Ubuntu的sudo用惯了,回到kali发现自己的用户太low了, ...

  10. linux 添加用户到sudo中

    步骤 1. 先切到root用户 2. 执行visudo,其实就是修改/etc/sudoers 3. 添加用户,规则如下: youuser ALL=(ALL) ALL %youuser ALL=(ALL ...

随机推荐

  1. *HDU 1757 矩阵乘法

    A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  2. 让代码重构渐行渐远系列(3)——string.Equals取代直接比较与非比较

    重构背景及原因 最近由于项目组的人员在不断扩充,导致项目中代码风格各异,大有百花齐放甚至怒放之势.考虑到团队的生存与发展,经过众人多次舌战之后,最终决定项目组根据业务分成几个小分队,以加强团队管理与提 ...

  3. ASP.NET TextBox 当鼠标点击后清空默认提示文字

    ASP.NET TextBox 当鼠标点击后清空默认提示文字 [ 方法一] 前台代码: <div>    <asp:TextBox ID="txtName" ru ...

  4. C#基础_单例模式

    控制某个类型的实例数量-唯一一个 class Program { static void Main(string[] args) { test t1 = test.GetInstance(); tes ...

  5. Building Modern Web Apps-构建现代的 Web 应用程序(一些感想)

    <iframe src="http://channel9.msdn.com/Series/MVA-China/Web20140611A01/player?h=540&w=960 ...

  6. 深入浅出NodeJS——数据通信,NET模块运行机制

    互联网的运作,最根本的驱动就是信息的交互,NodeJS 在数据交互这一块做的很带感,异步编程让人很惬意,关于 NodeJS 的数据通信,最基础的两个模块是 NET 和 HTTP,前者是基于 TCP 的 ...

  7. 你get了无数技能,为什么一事无成

      前几日看到阮一峰老师的发的一句话,颇有感慨,「你只是坐在电脑前,往网上发表了一段文字或者一张图片,随便什么,就能够接触到多少陌生的灵魂.这就是我热爱互联网的原因」.我打心底认为这是一个最好的时代, ...

  8. CSharpGL(4)设计和使用Camera

    CSharpGL(4)设计和使用Camera +BIT祝威+悄悄在此留下版了个权的信息说: 主要内容 描述在OpenGL中Camera的概念和用处. 设计一个Camera以及操控Camera的Sate ...

  9. Windows Azure Storage (6) Windows Azure Storage之Table

    <Windows Azure Platform 系列文章目录> 最近想了想,还是有必要把Windows Azure Table Storage 给说清楚. 1.概念 Windows Azu ...

  10. promise实现原理

    先看的这篇有问题的文章 花了很长时间研究这篇文章,卡在实现串行Promise那儿了,一直看不明白.就在刚才,发现这篇文章是错的,在第一次用setTimeout( ,0)那儿就错了.虽然用setTime ...