Linux如何用命令管理文件和目录的权限
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,Linux如何用命令管理文件和目录的权限?针对这个问题,今天小编总结这篇有关linux文件和目录权限的文章,可供感兴趣的小伙伴们参考借鉴,希望对大家有所帮助。一、文件的权限和归属概述1、访问权限读取r
千家信息网最后更新 2025年12月02日Linux如何用命令管理文件和目录的权限
Linux如何用命令管理文件和目录的权限?针对这个问题,今天小编总结这篇有关linux文件和目录权限的文章,可供感兴趣的小伙伴们参考借鉴,希望对大家有所帮助。
一、文件的权限和归属概述
1、访问权限
读取r:允许查看文件内容、显示目录列表;
写入w:允许修改文件内容,允许在目录中新建、移动、删除文件或子目录;
- 可执行x:允许运行程序、切换目录
2、归属(所有权)
属主:拥有该文件或目录的用户账号;
- 属组:拥有该文件或目录的组账号;
3、查看文件的权限和归属

4、chmod设置文件权限
chmod命令的基本语法格式如下:
应用举例:
[root@centos01 ~]# touch 1.txt [root@centos01 ~]# ll 总用量 8-rw-r--r-- 1 root root 0 1月 11 22:27 1.txt-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg[root@centos01 ~]# chmod u+x ./1.txt [root@centos01 ~]# ll总用量 8-rwxr--r-- 1 root root 0 1月 11 22:27 1.txt-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg[root@centos01 ~]# chmod u-x,g+x,o+w 1.txt [root@centos01 ~]# ll总用量 8-rw-r-xrw- 1 root root 0 1月 11 22:27 1.txt-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg[root@centos01 ~]# chmod 755 1.txt [root@centos01 ~]# ll总用量 8-rwxr-xr-x 1 root root 0 1月 17 02:36 1.txt-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg5、chown设置文件的归属
chown命令的基本语法格式如下:
应用举例:
[root@centos01 ~]# chown bob 1.txt [root@centos01 ~]# ll总用量 8-rwxr-xr-x 1 bob root 0 1月 17 02:36 1.txt-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg[root@centos01 ~]# chown :benet 1.txt [root@centos01 ~]# ll总用量 8-rwxr-xr-x 1 bob benet 0 1月 17 02:36 1.txt-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg[root@centos01 ~]# chown bob:benet 1.txt [root@centos01 ~]# ll总用量 8-rwxr-xr-x 1 bob benet 0 1月 17 02:36 1.txt-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg二、目录的权限和归属
1、访问权限
2、归属(所有权)
属主:拥有该目录的用户账号;
- 属组:拥有该目录的组账号;
3、chmod设置目录权限
chmod命令设置目录权限的基本格式如下:
应用举例:
[root@centos01 ~]# chmod -R 755 benet/ [root@centos01 ~]# ll总用量 8-rw-r-xrw- 1 root root 0 1月 11 22:27 1.txt-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfgdrwxr-xr-x 3 root root 18 1月 11 22:39 benet-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg4、chown设置目录的归属
chown命令设置目录归属的基本格式如下:
应用举例:
[root@centos01 ~]# chown -R bob:benet benet/ [root@centos01 ~]# ll总用量 8-rw-r-xrw- 1 root root 0 1月 11 22:27 1.txt-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfgdrwxr-xr-x 3 bob benet 18 1月 11 22:39 benet-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg三、权限掩码umask
1、umask的作用
控制新建的文件或目录的权限,默认权限去除umask的权限就是新建的文件或者目录的权限。
2、设置umask
umask 0223、查看umask
umask4、应用举例:
[root@centos01 ~]# umask 0022[root@centos01 ~]# umask 000 [root@centos01 ~]# umask 0000[root@centos01 ~]# touch 2.txt [root@centos01 ~]# ll总用量 8-rwxr-xr-x 1 bob benet 0 1月 17 03:48 1.txt-rw-rw-rw- 1 root root 0 1月 17 03:48 2.txt -rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg[root@centos01 ~]# umask 022 [root@centos01 ~]# umask 0022[root@centos01 ~]# touch 3.txt [root@centos01 ~]# ll总用量 8-rwxr-xr-x 1 bob benet 0 1月 17 03:48 1.txt-rw-rw-rw- 1 root root 0 1月 17 03:48 2.txt-rw-r--r-- 1 root root 0 1月 17 03:49 3.txt -rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg看完这篇文章,你们学会管理文件和目录的权限的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读。
目录
权限
文件
用量
归属
命令
应用
格式
账号
内容
管理文件
管理
所有权
更多
用户
语法
作用
兴趣
子目
子目录
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
oracle数据库查看是否锁表
数据库
网络安全项目施工图
服务器要求用户名和密码
战壕博客网络安全
罗布乐思12月8日停止服务器 啥时候上架
涉密网络安全工程师
中兴通讯的软件开发有什么部门
全球网络安全大学排名
三级网络技术备考时间
华为笔记本代理服务器没响应
如何实施数据库安全
佛山南海软件开发招聘
安宁gpu云服务器多少钱
网络安全法治标语
厦门it服务管理软件开发
浪潮服务器开机按F几做RAID
网络技术总监具备哪些技能
网络技术与软件工程就业方向
网站打不开 数据库
视频管理服务器断电后起不来
京东拍卖网络技术有限公司
流花湖服务器
软件开发过程中的资源
重庆销售erp软件开发
长白县网络安全周宣传活动
法院网络技术人员工作内容
互联网科技纪录片
word文管理服务器
分布式数据库 pec模块