zoukankan      html  css  js  c++  java
  • Linux——CentOS7添加/删除用户和用户组1

    Linux——CentOS7添加/删除用户和用户组

    2017.05.02 19:58 23012浏览
     

    前言

    今天又重新装了centos7突然有关用户和用户组有关的命令记不清了,所以记一下,也方便你我学习。

    1.新建用户

    adduser testuser                           //新建testuser 用户
    passwd testuser                            //给testuser 用户设置密码
    -------------------------记得要在root用户下-------------------------

    2.建工作组

    groupadd testgroup                          //新建test工作组

    3.新建用户同时增加工作组

    useradd -g testgroup testuser               //新建testuser用户并增加到testgroup工作组
    
    //注::-g 所属组 -d 家目录 -s 所用的SHELL

    4.给已有的用户增加工作组

    usermod -G groupname username

    5.临时关闭

    在/etc/shadow文件中属于该用户的行的第二个字段(密码)前面加上*就可以了。想恢复该用户,去掉*即可

    //或者使用如下命令关闭用户账号:
    passwd testuser l
    //重新释放:
    passwd testuser u

    6.永久性删除用户账号

    userdel testuser 
    groupdel testgroup
    usermod G testgroup testuser  //(强制删除该用户的主目录和主目录下的所有文件和子目录)

    7.显示用户信息

    id user
    cat /etc/passwd

    补充

    补充:查看用户和用户组的方法
    用户列表文件:/etc/passwd
    用户组列表文件:/etc/group
    查看系统中有哪些用户:cut -d : -f 1 /etc/passwd
    查看可以登录系统的用户:cat /etc/passwd | grep -v /sbin/nologin | cut -d : -f 1
    查看用户操作:w命令(需要root权限)
    查看某一用户:w 用户名
    查看登录用户:who
    查看用户登录历史记录:last

    摘自[centos系统添加/删除用户和用户组的例子],略有修改。

  • 相关阅读:
    性能测试分类
    monkey命令选项参考
    Hibernate三种状态
    Hibernate 的延迟加载
    JAVA2的三个版本
    缓存
    队列、生产消费模型.html
    socketserver剖析.html
    socketserver 之 recv(1024) 问题!
    粘包问题
  • 原文地址:https://www.cnblogs.com/xuanbjut/p/11953136.html
Copyright © 2011-2022 走看看