009_userandgroup

liujun5319 liujun5319     2022-12-29     656

关键词:

1. linux security context
    Which resources a process can access depends on the user running the process.
    For example,the root user own the following file.
        -rw-------. 1 root root 1920 Aug 25 21:05 anaconda-ks.cfg
        But we want to view the file with the cat command in other users
            The owner of the file is root, so we can not access the file with the cat command by its permission of owner
            The group of the file is root, so we can not access the file with the cat command by its permission of group.
            So we can access the file by other permission.
            --------------This is linux security context
2. The type of linux group:
    Basic group of users(the main group):
        The basic group has the same name as user:private group
    Additional group of users:
3. The configuration files related to users and the group of users:
    /etc/passwd:users and their attributes infomations(name、UID、GID);
        name:password:UID:GID:GECOS:directory:shell
        user name:passwd:UID:GID:GECOS:home directory:default shell
    /etc/group:groups and their attributes infomations;
        group_name:password:GID:user_list
        group name:gpasswd:GID:the user list in which users use current group as their additional group (seperated by comma).
    /etc/shadow:用户密码及其相关属性;
        用户名:加密了的密码:最近一次更改密码的日期:密码的最小使用期限:最大密码使用期限:密码警告时间段:密码禁用期:账户过期日期:保留字段
    /etc/gshadow:组密码及其相关属性;
4. 用户相关命令
    4.1 useradd : 添加用户
        [[email protected] ~]# useradd user1
            上面这句命令执行后,/etc/passwd /etc/group /etc/shadow /etc/gshadow这四个文件中都添加了user1相应的内容
        -u 指明UID: 范围在[UID_MIN, UID_MAX], 而这两个值定义在/etc/login.defs
        -g GID:指明用户所属基本组,可为组名,也可以GID;
        -c "COMMENT":用户的注释信息(也就是GECOS);
        -d /PATH/TO/HOME_DIR: 以指定的路径为家目录;
        -s SHELL: 指明用户的默认shell程序,可用列表在/etc/shells文件中;
        -G GROUP1[,GROUP2,...[,GROUPN]]]:为用户指明附加组;组必须事先存在;
        -r: 创建系统用户
            CentOS 6: ID<500
            CentOS 7: ID<1000
        默认值设定:/etc/default/useradd文件中
            useradd -D
                -s SHELL
5. 组相关命令
    5.1 groupadd : 添加组
        -g GID: 指明GID号;[GID_MIN, GID_MAX] 而这两个值定义在/etc/login.defs
        -r: 创建系统组;
            CentOS 6: ID<500
            CentOS 7: ID<1000

6. id : print real and effective user and group IDs
7. su : 切换用户或以其他用户身份执行命令
    切换用户的方式:
        su UserName:非登录式切换,即不会读取目标用户的配置文件;
        su - UserName:登录式切换,会读取目标用户的配置文件;完全切换;
        Note:root su至其他用户无须密码;非root用户切换时需要密码;
        换个身份执行命令:
            su [-] UserName -c ‘COMMAND‘
        选项:
            -l:“su -l UserName”相当于“su - UserName”
8. usermod : 用户属性修改
    -u UID: 新UID
    -g GID: 新基本组
    -G GROUP1[,GROUP2,...[,GROUPN]]]:新附加组,原来的附加组将会被覆盖;若保留原有,则要同时使用-a选项,表示append;
    -s SHELL:新的默认SHELL;
    -c ‘COMMENT‘:新的注释信息;
    -d HOME: 新的家目录;原有家目录中的文件不会同时移动至新的家目录;若要移动,则同时使用-m选项;
    -l login_name: 新的名字;
    -L: lock指定用户
    -U: unlock指定用户
    -e YYYY-MM-DD: 指明用户账号过期日期;
    -f INACTIVE: 设定非活动期限;
9. passwd : 给用户添加密码  /etc/shadow文件
    passwd [OPTIONS] UserName: 修改指定用户的密码,仅root用户权限
    passwd: 修改自己的密码;
    常用选项:
        -l: 锁定指定用户
        -u: 解锁指定用户
        -n mindays: 指定最短使用期限
        -x maxdays:最大使用期限
        -w warndays:提前多少天开始警告
        -i inactivedays:非活动期限;
        --stdin:从标准输入接收用户密码;
            echo "PASSWORD" | passwd --stdin USERNAME
10. userdel : 删除用户 userdel [OPTION]... login
    -r: 删除用户家目录;
11. groupmod : 组属性修改
    groupmod [OPTION]... group
        -n group_name: 新名字
        -g GID: 新的GID;
12. groupdel : 组删除
    groupdel GROUP
13. gpasswd : 组密码
    gpasswd [OPTION] GROUP
        -a user: 将user添加至指定组中;
        -d user: 删除用户user的以当前组为组名的附加组
        -A user1,user2,...: 设置有管理权限的用户列表
14. newgrp命令:临时切换基本组;
    如果用户本不属于此组,则需要组密码;
15. chage : change user password expiry information
    chage [OPTION]... LOGIN
        -d LAST_DAY
        -E, --expiredate EXPIRE_DATE
        -I, --inactive INACTIVE
        -m, --mindays MIN_DAYS
        -M, --maxdays MAX_DAYS
        -W, --warndays WARN_DAYS





































































































009-http_01(代码片段)

请求头:(下面10行都是请求头)GET/index.htmlHTTP/1.1这两行比较重要GET/classic.cssHTTP/1.1Host:127.0.0.1:8997Connection:keep-aliveUser-Agent:Mozilla/5.0(X11;Linuxx86_64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/65.0.3325.1 查看详情

009_stm32程序移植之_内部falsh

flash  模拟  EEPROM  实验1.测试环境:STM32C8T62.测试接口:3.串口使用串口一,波特率9600单片机引脚------------CH340引脚VCC--------------------VCCGND-------------------GNDPA9--------------------RXDPA10---- 查看详情

009_html布局响应式设计

HTML布局网站常以杂志、报纸样式显示使用<div>元素的HTML布局,方便通过css对其进行设计<!DOCTYPEhtml><html><head><style>#header{background-color:balck;color:white;text-align:center;padding:5px:}#nav{line-heit 查看详情

009_一个englishnativespeaker掌握多少单词量(代码片段)

Google"howmanywordsdoesanativespeakerknow"一、anaverageof20,000to30,000vocabularywords①Evenwithintensivestudy,howmanywordsdonon-nativespeakersknow?⑴TheresearchersfoundthatnativeadultspeakersofEnglishund 查看详情

009_ul_ol_dl.html

<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>span</title></head><body><ul><li>asdf</li><li>asdf</li>< 查看详情

javaminecraftmodexample.example000_009.e004_damage_block.blockdamageblock.java(代码片段)

查看详情

javaminecraftmodexample.example000_009.e000_basic_block.initcommon.java(代码片段)

查看详情

javaminecraftmodexample.example000_009.e005_add_fuel.initcommon.java(代码片段)

查看详情

javaminecraftmodexample.example000_009.e000_basic_block.blockbasicblock.java(代码片段)

查看详情

javaminecraftmodexample.example000_009.e006_basic_item.itembasicitem.java(代码片段)

查看详情

javaminecraftmodexample.example000_009.e000_basic_block.initclient.java(代码片段)

查看详情

009_项目制作拍摄视频篇之_《热水壶》

此项目为合作项目需求:1.LED灯提示水温状况:温度传感器模块所采集的数据通过串行口发送给单片机主控模块,单片机控制LED灯显示不同颜色的灯光,让用户能够直观了解到水温的基本状况。(绿色光为凉水,黄色光为温水,... 查看详情

算法笔记_009:字符串匹配蛮力法

1问题描述给定一个n个字符组成的串(称为文本),一个m(m<=n)的串(称为模式),从文本中寻找匹配模式的子串。 2解决方案2.1具体编码packagecom.liuzhen.chapterThree;publicclassBruteForceStringMatch{//根据文本串N,和模式串M,返回... 查看详情

009-快速构建一个业务模块(代码片段)

视频讲解地址:009-快速构建一个业务模块(3)_哔哩哔哩_bilibili009-快速构建一个业务模块(3)https://www.bilibili.com/video/BV1w34y1i7dp?spm_id_from=333.999.0.0本演示讲解一个模拟业务模块从导入到配置的过程,使您可以快速了解本系统... 查看详情

009-快速构建一个业务模块(代码片段)

视频讲解地址:009-快速构建一个业务模块(3)_哔哩哔哩_bilibili009-快速构建一个业务模块(3)https://www.bilibili.com/video/BV1w34y1i7dp?spm_id_from=333.999.0.0本演示讲解一个模拟业务模块从导入到配置的过程,使您可以快速了解本系统... 查看详情

python-009基本数据类型常用功能(详解)(代码片段)

1基本数据类型常用功能:2数字int3n1=24n2=35print(n1+n2)6print(n1.__add__(n2))789#获取二进制的最短位数10#i=411#ret=i.bit_length()12#print(ret)1314字符串str151.capitalize16a1=‘alex‘17rex=a1.capitalize()18print(rex)192.center(self 查看详情

javanet.nyagosu.minecraftmodexample.example000-009.e001_hardest_block.blockglowblock.java(代码片段)

查看详情

javanet.nyagosu.minecraftmodexample.example000-009.e001_hardest_block.blockhardestblock.java(代码片段)

查看详情