Linux命令(111)之groupadd-CSDN博客

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

linux命令之groupadd

1.groupadd介绍

linux命令groupadd是用来创建新的用户组用户组信息会被添加到系统文件(/etc/group)中。

2.groupadd用法

groupadd [参数] GroupName

groupadd常用参数
参数说明
-g指定用户组的gid号
-r创建系统工作组
-f如果组已经存在则成功退出

3.实例

3.1.创建普通用户组

命令

groupadd aa

[root@rhel77 ~]# groupadd aa
[root@rhel77 ~]# cat /etc/group | grep aa
aa:x:1129:
[root@rhel77 ~]# 

默认普通用户组gid的范围可以在/etc/login.defs文件查看

[root@rhel77 ~]# cat /etc/login.defs | grep ^GID
GID_MIN                  1000
GID_MAX                 60000
[root@rhel77 ~]# 

3.2.创建指定gid号的普通用户组

命令

groupadd -g 1200 bb

[root@rhel77 ~]# groupadd -g 1200 bb
[root@rhel77 ~]# cat /etc/group | grep bb
bb:x:1200:
[root@rhel77 ~]# 

3.3.创建系统账户组

命令

groupadd -r aa

[root@rhel77 ~]# groupadd -r aa
[root@rhel77 ~]# cat /etc/group | grep aa
aa:x:981:
[root@rhel77 ~]# 

默认系统用户组gid的范围可以在/etc/login.defs文件查看

[root@rhel77 ~]# cat /etc/login.defs | grep ^SYS_GID
SYS_GID_MIN               201
SYS_GID_MAX               999
[root@rhel77 ~]# 

3.4.创建指定gid号的系统账户组

命令

groupadd -r -g 210 aa

[root@rhel77 ~]# groupadd -r -g 210 aa
[root@rhel77 ~]# cat /etc/group | grep aa
aa:x:210:
[root@rhel77 ~]# 

3.5.创建已经存在的系统账户组

命令

groupadd -f -r -g 220 aa

[root@rhel77 ~]# cat /etc/group | grep aa
aa:x:210:
[root@rhel77 ~]# groupadd -f -r -g 220 aa
[root@rhel77 ~]# cat /etc/group | grep aa
aa:x:210:
[root@rhel77 ~]# 
阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: linux