Linux命令(111)之groupadd

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 ~]# 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小黑要上天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值