news 2026/7/22 15:22:10

linux的特殊权限

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
linux的特殊权限
  • 权限


  • umask
    默认值为0022

0022
Special bitugo
  • 默认权限
  1. 目录的默认权限是 777 - umask = 755
  2. 文件的默认权限是目录的默认权限去掉执行权限(x = 1):755 - 111 = 644
  3. 非特权用户默认的 umask = 0022(0022,且在/etc/bashrc中定义
    ~ 目录权限将为 777 - 022 = 755(rwxr-xr-x
    ~ 文件权限将为 777 - 022 - 111 = 644(rw-r–r–
  4. root的默认umask = 022(0022)
  • SUID
    Command run with permissions of the owner of the command, not executor of the command.
    在u位:
rwx描述
sx + SUID,文件原来有执行权限
S- + SUID,文件原来没有执行权限
  • SGID
    Command runs with group affiliation of the group of the command.Files created in directories with the SGID bit set have group affiliations of the group of the directory.
    应用于一个目录,任何人在该目录里创建的文件及目录会自动属于该目录的组。
    在g位:
rwx描述
sx + SGID,文件组成员拥有执行权限
S- + SGID,文件组成员不拥有执行权限
  • Sticky-bit

Files in directories with the sticky-bit set can only be removed by the owner and root, regardless of the write permissions of the directory.
在o位:

rwx描述
tx + Sticky-bit,文件原来有执行权限
T- + Sticky-bit,文件原来没有执行权限
  • 特殊权限的总结
special permissionsexecutabledirectory
SUIDCommand run with permissions of the owner of the command, not executor of the command. Such as: ping.N/A
SGIDCommand runs with group affiliation of the group of the command.File created in directories with the SGID bit set have group affiliations of the group of the directory.
Sticky-bitN/AFiles in directories with the sticky bit set can only be removed or modified by the owner and root, regardless of the write permission. Such as: /tmp. Often both the Sticky bit and the SGID permission will be set on a project directory.
  • 相关命令
chmod u+s exefile chmod 4755 exefile ls -ld /apath chmod g+s /apath chmod 2771 /apath ls -ld /apath chmod o+t /apath chmod 1777 /apath ls -ld /apath
  • 其他
  1. SUID只能应用于可执行文件。
  2. SGID可应用于可执行文件,也可应用于目录。
  3. Sticky-bit只能应用于目录。
  4. SUID和SGID可同时出现,special bits = 6。当同时出现时,SUID的优先级高于SGID。
  5. SUID和Sticky-bit不可能同时出现,special bits ≠ 5。
  6. ls -l的回显数字
[user@bee-a admin]$ ll total 36 drwxrwxr-x. 2 user user 59 Jun 20 07:53 bak -rw-rw-r--. 1 user user 644 Jun 16 22:38 get_sys_info.py drwxrwxr-x. 5 user user 41 Jun 16 22:38 __pycache__ -rw-r--r--. 1 user user 3736 Jun 18 13:13 repond.xml -rw-rw-r--. 1 user user 407 Jun 19 22:38 test1.csv -rw-rw-r--. 1 user user 162 Jun 19 21:31 test1.txt -rw-rw-r--. 1 user user 407 Jun 19 22:42 test2.csv -rw-rw-r--. 1 user user 497 Jun 20 12:50 test3.txt -rw-rw-r--. 1 user user 429 Jun 20 12:43 test4.txt -rw-rw-r--. 1 user user 181 Jun 19 22:02 test.csv -rw-rw-r--. 1 user user 1161 Jun 18 13:52 test.xml 第二列的数字: 2 表示只有 . 和 .. 两个子目录 5 表示除. 和 .. 两个子目录外还有3个子目录 第一列表示文件类型: - regula file d directory l symbolic link b block special file : U盘,磁盘,光驱等存储设备 c character special file : 键盘等I/O设备 p named pipe s socket
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/22 15:20:35

Canvas粒子系统实现情绪化动画:从烟花易冷看代码艺术创作

那天晚上,我正为一个项目渲染一段粒子特效,屏幕上的光点明明灭灭,忽然就想起了很多年前用代码模拟烟花的日子。那些简单的二维动画,没有复杂的三维模型和物理引擎,却总能精准地触动人心。于是,我关掉了庞大…

作者头像 李华
网站建设 2026/7/22 15:18:16

智能体个人信息保护公约发布:开发者合规指南与技术实践

智能体个人信息保护自律公约发布:31家企业首批签署,开发者如何应对新规范? 近日,中国人工智能产业发展联盟发布了《智能体个人信息保护自律公约》,百度、腾讯、阿里、火山引擎等31家知名企业成为首批签署单位。这一公约…

作者头像 李华
网站建设 2026/7/22 15:15:11

用飞算JavaAI生成SpringCloud Alibaba分布式架构全流程

搭建一套SpringCloud Alibaba微服务体系,涉及多个环节:Nacos注册中心与配置中心、Sentinel流量控制与熔断降级、Gateway网关路由与鉴权、Seata分布式事务、OpenFeign服务间调用,以及每个微服务独立的数据源和业务逻辑。在传统开发流程中&…

作者头像 李华
网站建设 2026/7/22 15:13:41

YOLOv8目标检测优化:CAA注意力机制详解与实践

1. 项目背景与核心价值在目标检测领域,YOLOv8作为当前最先进的实时检测框架之一,其性能优化一直是工业界和学术界关注的焦点。复杂场景下的多尺度目标检测(如交通监控中的远/近车辆、医疗影像中的不同尺寸病灶)始终存在特征感知不…

作者头像 李华
网站建设 2026/7/22 15:13:39

脚本跑通了,Agent 却卡死在权限日志:运维转大模型的真实分水岭

聊《运维转大模型,真正值钱的为什么不是会调 API?》之前,先说一句实在的:别急着背概念,先看它在真实项目里到底解决什么问题。摘要先把这篇文章的目标说清楚:看完之后,你应该能判断这件事值不值…

作者头像 李华
网站建设 2026/7/22 15:13:28

OpenAI 专门发了一份协议,教你怎么嘲讽 AI

最近在修改 x-cmd 的 rfc 模块,翻 RFC 列表 时,我看到一份 2023 年 4 月 1 日发布的文档 RFC 9405,标题是 AI Sarcasm Detection: Insult Your AI without Offending It,作者栏写着 C. GPT, OpenAI。 我当时就乐了。 一家 AI 公司…

作者头像 李华