/etc/group 与 /etc/gshadow (一)

本文深入探讨Linux系统中用于管理用户组的两个关键配置文件:/etc/group与/etc/gshadow。通过解析文件格式、解释各字段含义,并提供实际操作示例,帮助读者掌握如何在系统中创建、修改和管理用户组。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

       认识了帐号相关的两个文件/etc/passwd 与/etc/shadow之后,你或许还是会觉得奇怪,那么用户组的配置文件在哪里?还有,在/etc/passwd的第四列不是所谓的GID吗?那又是什么?此时就需要了解/etc/group与/etc/gshadow。

NAME
       group - user group file

DESCRIPTION
       /etc/group  is  a  text  file  which  defines the groups on the system.
       There is one entry per line, with the following format:

      group_name:passwd:GID:user_list

       The field descriptions are:

       group_name
              the name of the group.

       password
              the (encrypted) group password.  If  this  field  is  empty,  no
              password is needed.

       GID     the numerical group ID.

       user_list
              a  list  of  the usernames that are members of this group, sepa‐rated by commas.

FILES
       /etc/group

*****************

这个档案可以让你直接将账号所要支持的群组加进来!例如你有一个账号名称为 myaccount ,你想要让这个账号可以支持 root 这个群组,则你可以直接在 /etc/group 里面加入呢!很方便,不需要动用的指令呦!
 

root:x:0:root
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
adm:x:4:root,adm,daemon

这个内容也说明如下:
 

  1. 群组名称 :就是群组名称啦!
  2. 群组密码 :通常不需要设定,因为我们很少使用到群组登入!不过,同样的,密码也是被纪录在 /etc/gshadow 当中啰!
  3. 群组 ID :就是所谓的 GID 啦!
  4. 支持的账号名称 :这个群组里面的所有的账号,如上面所言,如果你想要让 mysccount 也属于 root 这个群组的话,那么就将上面的第一行最后面加上 ,myaccount (不要有空格)使成为『root:x:0:root,myaccount』就可以啦。














评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值