zoukankan      html  css  js  c++  java
  • contos7 用户管理相关操作命令

    # 查看用户列表
    cut -d : -f 1 /etc/passwd
    
    # 查看可以登录系统的用户
    cat /etc/passwd | grep -v /sbin/nologin | cut -d : -f 1
    
    # 查看登录用户正在使用的进程信息
    w
    
    # 查看曾经使用过系统的用户信息
    last
    
    # 添加用户(创建home目录lixingwu,指定shell:/bin/sh,添加用户描述:this is a lixingwu)
    useradd -m -d /home/lixingwu -s /bin/sh -f -1 -c "this is a lixingwu" lixingwu
    
    # 查看用户信息
    cat /etc/passwd |grep lixingwu
    id lixingwu
    
    # 查看用户状态
    passwd -S lixingwu
    
    # 锁定用户(二选一,需要一一对应使用)
    passwd -l lixingwu
    usermod --lock lixingwu
    
    # 解锁用户(二选一,需要一一对应使用)
    passwd -u lixingwu
    usermod --unlock lixingwu
    
    # 修改密码
    passwd lixingwu
    
    # 删除用户及home目录
    userdel –r lixingwu 
    
    # 创建组
    groupadd test
    
    # 查看组
    cat /etc/group
    
    # 删除组
    groupdel test
    
    # 修改组
    groupmod -n test1 test
    
    # 用户分配组
    usermod -G test1 lixingwu
    
    # 查看文件或目录的权限
    ls -l
    
    # 分配权限(分配详情:https://blog.csdn.net/neubuffer/article/details/16901075)
    chmod g+rwx a.txt
    chmod u+rwx,g+rx,o+r b.txt
    chmod u-x b.txt
    
    # 修改文件所有组
    chgrp test1 c.txt
    
    # 修改文件所有者
    chown -R lixingwu b.txt
    
    # 查看权限详细信息
    getfacl a.txt
    

    权限码计算方式

    r=4,w=2,x=1 
    
    chmod u+rwx,g+rx,o+r b.txt 等价于:chmod 754 b.txt
    chmod u=rwx,g=rwx,o=rwx b.txt 等价于:chmod 777 b.txt
    
    计算方式:
    u+rwx   g+rx    o+r
    4+2+1   4+1     4
    7       5       4
    
  • 相关阅读:
    fedora 安装open office
    git rebase(转)
    javascript typeof
    正则表达式入门
    XML格式
    zz 通用线程:Awk 实例,第 3部分
    ELF BIN HEX
    i2c总线(iic总线/ I square C)
    grep
    把Nginx注册成Windows 系统服务(转载)
  • 原文地址:https://www.cnblogs.com/lixingwu/p/11237946.html
Copyright © 2011-2022 走看看