大数据全系列 教程
1869个小节阅读:464.7k
目录
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
####3.2.3.2符号类型改变文件权限
另一种改变权限的方法就是通过符号了,上文提到,Linux总共9种权限,对应着三种身份,为此我们可以通过u,g,o代表三种身份,另外a代表全部身份。对应的权限可以写为r,w,x,如下图所示:
案例实战:
1.我们要将一个文件的权限改做[-rwxr-xr-x],具体来说就是:
user(u):具有可读可写可执行权限;group与others(go):具有可读可执行权限
xxxxxxxxxx
#不考虑之前的权限,直接使用设定的方式
[root@node1 ~]# chmod u=rwx,g=rx,o=rx .bashrc
#还以省略为如下:
[root@node1 ~]# chmod u=rwx,go=rx .bashrc
2.若要改为[-rwxr-xr--],可以使用[chmod u=rwx,g=rx,o=r filename]来设置:
xxxxxxxxxx
#不考虑之前的权限,直接使用设定的方式
[root@node1 ~]# chmod u=rwx,g=rx,o=r profile
3.要去掉全部的执行权限,但不修改其他权限:
xxxxxxxxxx
[root@node1 ~]# chmod a-x .bashrc
#或
[root@node1 ~]# chmod -x .bashrc
[root@node1 ~]# ll .bashrc
-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc
4.添加全部的可执行权限:
xxxxxxxxxx
[root@node1 ~]# chmod a+x .bashrc
# 或者
[root@node1 ~]# chmod +x .bashrc
[root@node1 ~]# ll .bashrc
-rwxr-xr-x. 1 root root 176 12月 29 2013 .bashrc
5.还原默认的权限rw-r--r--
xxxxxxxxxx
[root@node1 ~]# ll .bashrc
-rwxr-xr-x. 1 root root 176 12月 29 2013 .bashrc
#以下三种方式都可以实现
[root@node1 ~]# chmod a-x .bashrc
[root@node1 ~]# chmod u=rw,go=r .bashrc
[root@node1 ~]# chmod u-x,go=r .bashrc
#4、 目录与文件权限的意义