最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Linux下用户添加至组的方法介绍
时间:2016-07-06 编辑:简简单单 来源:一聚教程网
在Linux系统把用户添加至组(Group)时,使用gpasswd -a或者usermod -aG命令。
将用户添加至组的几种方法
创建用户时,把用户添加至指定组的方法有以下几种。
代码如下 | 复制代码 |
(1) 创建用户时指定组 # useradd -g [组名 or gid] -G [附加组 or gid] [用户名] # usermod -g [组名 or gid] -G [附加组 or gid] [用户名] # usermod -aG [组名] [用户名] # gpasswd -a [用户名] [组名] |
在使用usermod命令时仅使用-G选项指定组时需注意,该用户将从原来的所有组里退出,仅属于使用-G选项指定的组。
代码如下 | 复制代码 |
# man usermod -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list. |
实际操作
以下是zabbix用户为例,执行gpasswd -a、usermod -G、usermod -aG命令的结果。
代码如下 | 复制代码 |
# id zabbix # gpasswd -a zabbix wheel # usermod -G zabbix zabbix # usermod -aG wheel zabbix |
相关文章
- Linux系统中用户管理的基本命令整理 12-21
- 快速浏览Linux下基本的用户和用户组管理命令 12-21
- Linux下添加用户和用户组的命令使用教程 12-19
- Linux用户及组的管理的入门常用命令 10-06
- linux nobody用户是什么 nobody用户介绍 06-12
- Linux批量添加用户和组shell脚本 04-26