Linux命令(111)之groupadd

linux命令之groupadd

1.groupadd介绍

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

2.groupadd用法

groupadd [参数] GroupName

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

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 ~]# 
相关推荐
ai_xiaogui20 小时前
Debian系统PVE虚拟机安装详解:ISO镜像上传+硬件配置+图形化安装指南
运维·debian·php·panelai兼容测试·图形化安装指南·iso镜像上传配置·debian pve虚拟机安装
周周记笔记20 小时前
Ubuntu 中如何配置域名
运维·服务器
KYGALYX20 小时前
Win10/11系统下WSL2+Ubuntu的全流程安装
linux·运维·ubuntu
寰天柚子1 天前
裸金属服务器深度解析:适用场景、选型指南与运维实践
服务器·网络·github
Yyyy4821 天前
Ubuntu安装Jenkis
linux·运维·ubuntu
克莱斯勒ya1 天前
服务器硬件配置
运维·服务器
GTgiantech1 天前
精准成本控制与单向通信优化:1X9、SFP单收/单发光模块专业解析
运维·网络
tzhou644521 天前
Docker容器技术指南
运维·docker·容器
zhuzewennamoamtf1 天前
Linux SPI设备驱动
android·linux·运维
春日见1 天前
在虚拟机上面无法正启动机械臂的控制launch文件
linux·运维·服务器·人工智能·驱动开发·ubuntu