zoukankan      html  css  js  c++  java
  • Linux用户组的添加及属性的更改

    用户组的创建:

    1
    2
    3
    4
    5
    groupadd [OPTION]  组名
    -g GID 指明GID号;[GID_MIN, GID_MAX]
    -r 创建系统组
    CentOS 6: ID<500
    CentOS 7: ID<1000

    用户组的修改

    groupmod [OPTION]  组名
        -n group_name: 新名字
        -g GID: 新的GID
    

    用户组的删除

    groupdel 组名
    

    更改和查看组成员:

    groupmems [options] [action]
        options:
            -g, --group groupname 更改为指定组 (只有root)
        actions:
            -a, --add username 指定用户加入组
            -d, --delete username 从组中删除用户
            -p, --purge 从组中清除所有成员
            -l, --list 显示组成员列表
    

    首先通过groupadd 组名创建一个新组。并通过groupmems -a 用户名 -g 组名添加一个用户到某个组中。

    1
    2
    3
    4
    5
    6
    7
    8
    大专栏  Linux用户组的添加及属性的更改ass="line">9
    [root@localhost ~]# groupadd test
    [root@localhost ~]# getent group test
    test:x:1008:
    [root@localhost ~]# groupmems -a tom -g test
    [root@localhost ~]# groupmems -a jim -g test
    [root@localhost ~]# groupmems -a user1 -g test
    [root@localhost ~]# groupmems -a user2 -g test
    [root@localhost ~]# getent group test
    test:x:1008:tom,jack,jim,user1,user2

    添加删除用户到组中的另一种方法。

    1
    2
    3
    4
    [root@localhost ~]# gpasswd -a tom jim
    Adding user tom to group jim
    [root@localhost ~]# gpasswd -d tom test
    Removing user tom from group test

    通过groupmems -l -g 组名,列出该组的成员。

    [root@localhost ~]# groupmems -l -g test
        tom  jack  jim  user1  user2 
    

    groups [OPTION].[USERNAME] 查看用户所属组列表

    [root@localhost ~]# groups tom
    tom : tom jim
    [root@localhost ~]# id tom
    uid=1000(tom) gid=1000(tom) groups=1000(tom),1001(jim)
    
  • 相关阅读:
    MySQL教程详解之存储引擎介绍及默认引擎设置
    最简单MySQL教程详解(基础篇)之多表联合查询
    Postfix常用命令和邮件队列管理(queue)
    备份数据库
    Docker基本命令
    ASCII码表
    mysql基本了解
    顺序对列,环形队列,反向链式栈
    进制的标识符
    多个线程的时间同步
  • 原文地址:https://www.cnblogs.com/lijianming180/p/12251450.html
Copyright © 2011-2022 走看看