当前位置:网站首页>[Day6] File system permission management, file special permissions, hidden attributes
[Day6] File system permission management, file special permissions, hidden attributes
2022-08-05 06:09:00 【Mingli Yui】
目录
一、File system permissions management
User identity division and user authority division
一、File system permissions management
User identity division and user authority division
用户管理
添加用户
使用useradd命令创建用户时,系统会默认分配一个uid和gid(在/etc/passwd 文件下查看)
useradd -g 1234 user7 (创建用户user7,同时指定gid,1234for an existing groupgid)
useradd -u 5678 user8 (Specify at the time of user creationuid)
useradd -G group2 user8 (创建用户user8,并给user8指定附加组为group2)
修改用户属性
When assigning additional groups to a user,This group and user must exist:
usermod -G group1 user1 (将用户user1添加到group1组里)
或者 gpasswd -a user1 group1
Remove users from additional groups:
gpasswd -d user1 group1
使用usermod -G 修改用户所属附加组,The original additional group will not be overwritten
usermod -u 1111 user1 (给user1修改uid)
usermod -g user6 user1 (给user1 Modify the base group to user6,The premise is that the group must exist beforehand)
删除用户
userdel 用户名
userdel -r (Delete the user's home directory along with it)
组管理
添加组
groupadd -g user4 231 (新建一个user4组,gid为231)
修改组属性
groupmod -g 6575 love 改love组的gid为6575)
groupmod -n lover love (修改love组的组名为lover)
删除组
改变属主 chown
chown root /u Change the owner of /u to "root".(Only change the owner)
chown root:staff /u Likewise, but also change its group to "staff".(The owner and group are changed)
chown -hR root /u Change the owner of /u and subfiles to "root".改变属组 chgrp
-R参数实现递归修改,即目录下的文件也被同时修改
改变权限 chmod
chmod 640 test1 (640表示-rw--r----,other什么权限都没有)
修改密码
显示ID
sudo (重要)
在/etc/sudoersIt is best to add the absolute path of the command when adding permissions to different users,Otherwise, the system will not recognize it.
修改完成后,执行命令时.要加上sudo
二、文件特殊权限
For independent of the owner、属组、Permissions used by users other than others;
Linux SetUID(SUID)
定义:文件所有者权限中的x权限位,出现了s权限,此种权限通常称为SetUID,简称 SUID 特殊权限.
针对二进制文件,功能:程序运行时的权限从执行者变更成程序所有者的权限
举例来说:
二进制文件passwd,Its owner array is bothroot用户,No one else can modify this file,But with this special permission,Ordinary users are transformed from executors to owners,This file can be modified.
用法:chmodu+s xxx
只针对(二进制可执行程序)The system command takes effect
Linux SetGID(SGID)
当sPermissions are in the owning groupx权限位时,就被称为SetGID,简称SGID 特殊权限.
限定:既可以给二进制可执行程序设置,也可以给目录设置.
功能:在设置了SGID权限的目录下建立文件时,新创建的文件的所属组会继承上级目录的权限.(inherited from the superior目录的属组)
用法:chmodg+s xxx
同 SUID 类似,对于文件来说,SGID 具有如下几个特点:
•SGID Only for executable files,effective grant SGID The user is required to have this executable file x 权限;•用户在执行具有 SGID 权限的可执行文件时,用户的群组身份会变为文件所属群组;•SGID 权限赋予用户改变组身份的效果,只在可执行文件运行过程中有效;
Linux Stick BIT(SBIT)
Sticky BIT,简称 SBIT 特殊权限,可意为粘着位、粘滞位、防删除位等.
限定:只作用于目录,Permissions for other users
功能:目录下创建的文件只有root、文件创建者、目录所有者才能删除.
用法:chmodo+t xxx
创建一个目录,目录默认权限为755,Only group users and ordinary users can use itlsCommands to view files in a directory and access the power of the directory,Even if files are created under that directory,Directory is set666权限,Group users and ordinary users cannot delete files either.
ACL访问控制列表
We cannot set different permission sets for different users on the same directory or file.因而,访问控制列表(ACL)应运而生.
1.Check whether the current operating system version supports itacl控制 grep -i acl /boot/config*
2. Check the required packages.
在开始处理ACL之前,Make sure you have the required packages installed.
检查是否安装:rpm -qa |grep acl
If no installation is required:yum install nfs4-acl-tools acl lib-acl -y
常用参数:
举例:
隐藏属性
查看文件隐藏属性
lsattr filename
修改文件隐藏属性
chattr +i filename 文件不能被删除、改名、Set hard link relationship,It cannot be written or added at the same time
chattr +a filename 只能向文件中添加数据 不能删除 不能覆盖
chattr -a filename 和 chattr -i filename You can remove the hidden attribute of the file that has been added
边栏推荐
- 入门文档03 区分开发与生产环境(生产环境才执行‘热更新’)
- 【UiPath2022+C#】UiPath数据类型
- spark源码-任务提交流程之-2-YarnClusterApplication
- 虚幻引擎5都有哪些重要新功能?
- 专有宿主机CDH
- Unity常用模块设计 : Unity游戏排行榜的制作与优化
- Hard Disk Partitioning and Permanent Mounting
- 每日一题-字典
- 每日一题-有效的括号-0719
- 错误类型:reflection.ReflectionException: Could not set property ‘xxx‘ of ‘class ‘xxx‘ with value ‘xxx‘
猜你喜欢
随机推荐
Hard Disk Partitioning and Permanent Mounting
每日一题-下一个排列-0723
硬盘分区和永久挂载
Lua,ILRuntime, HybridCLR(wolong)/huatuo热更对比分析
vim的三种模式
【Day8】 RAID磁盘阵列
入门文档05 使用cb()指示当前任务已完成
游戏引擎除了开发游戏还能做什么?
spark算子-parallelize算子
D39_向量
【Day5】软硬链接 文件存储,删除,目录管理命令
【UiPath2022+C#】UiPath 循环
Unity huatuo 革命性热更系列1.3 huatuo示例项目源码分析与启发
入门文档03 区分开发与生产环境(生产环境才执行‘热更新’)
每日一题-有效的括号-0719
Getting Started 04 When a task depends on another task, it needs to be executed in sequence
【UiPath2022+C#】UiPath If条件语句
[Day5] Soft and hard links File storage, deletion, directory management commands
【Day8】RAID Disk Array
Cocos Creator小游戏案例《棍子士兵》