0
点赞
收藏
分享

微信扫一扫

链表加法与节点交换:数据结构的基础技能

爱上流星雨 2023-11-02 阅读 49

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 ~]# 
举报

相关推荐

0 条评论