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 ~]# 
相关推荐
挥剑决浮云 -15 分钟前
Linux 之 安装软件、GCC编译器、Linux 操作系统基础
linux·服务器·c语言·c++·经验分享·笔记
立秋678938 分钟前
Python的defaultdict详解
服务器·windows·python
Lansonli1 小时前
云原生(四十一) | 阿里云ECS服务器介绍
服务器·阿里云·云原生
小O_好好学1 小时前
CentOS 7文件系统
linux·运维·centos
哲伦贼稳妥2 小时前
一天认识一个硬件之机房地板
运维·网络·经验分享·其他
john_hjy2 小时前
11. 异步编程
运维·服务器·javascript
x晕x2 小时前
Linux dlsym符号查找疑惑分析
linux·运维·服务器
活跃的煤矿打工人2 小时前
【星海saul随笔】Ubuntu基础知识
linux·运维·ubuntu
tangdou3690986553 小时前
两种方案手把手教你多种服务器使用tinyproxy搭建http代理
运维·后端·自动化运维
北京智和信通3 小时前
云平台和虚拟化智慧运维监控,全面提升故障感知与处置能力
运维·虚拟化·云平台·虚拟机监控