linux权限讲解

Linux有两种用户:

  • 超级用户:可以在Linux系统下做任何事情,不受限制
  • 普通用户:可以在Linux系统下做有限的事情
  • 超级用户的提示符是$  ,而普通用户的提示符是 #

要了解权限,我们从三个问题入手

1.始终权限问题

目录

1.始终权限问题

搞清楚 权限始终问题 后,我们开始下一个问题

2.目录权限:

3.粘滞位


在Linux系统中系统默认  目录权限:777, 普通文件:666

[root@zhangsan mytmp]# mkdir teset
[root@zhangsan mytmp]# mkdir test
[root@zhangsan mytmp]# ll
total 0
drwxr-xr-x. 2 root root 6 Apr  4 19:10 teset
#为什么目录权限是755
-rw-r--r--. 1 root root 0 Apr  4 19:14 test
#为什么文件权限是644

其实这是指令 umask 在搞鬼

[root@zhangsan mytmp]# umask
0022
#这里的 umask 掩码值每台机子可能不一样 我的是0022


搞清楚 权限始终问题 后,我们开始下一个问题

2.目录权限:

想要观察 目录文件的权限 对其本身的影响时,需先进入

#观察哪一个权限能够影响是否进入目录
#'r'权限
[why@zhangsan share]$ chmod 444 test
[why@zhangsan share]$ ll
total 0
dr--r--r--. 2 why why 17 Apr  4 22:05 test
#'w'权限
[why@zhangsan share]$ cd test
-bash: cd: test: Permission denied
[why@zhangsan share]$ chmod 222 test
[why@zhangsan share]$ ll
total 0
d-w--w--w-. 2 why why 17 Apr  4 22:05 test
#'x'权限
[why@zhangsan share]$ cd test
-bash: cd: test: Permission denied
[why@zhangsan share]$ chmod 111 test
[why@zhangsan share]$ ll
total 0
d--x--x--x. 2 why why 17 Apr  4 22:05 test
[why@zhangsan share]$ cd test
[why@zhangsan test]$ 

总结:想要进入所创建目录文件,其必须包含权限 'x' ,'x'权限是必须的

观察 对目录文件内容进行增加、修改、删除

因为我们测试时权限不够,所以用root用户进行查看文件的修改

#对目录文件 内容 进行查看和修改  /* 普通用户 */
[why@zhangsan share]$ cd test
[why@zhangsan test]$ ls -l
ls: cannot open directory '.': Permission denied
[why@zhangsan test]$ touch new
[why@zhangsan test]$ mv new chese
[why@zhangsan test]$ rm -rf chese
# 使用 root用户 观察命令的修改
[root@zhangsan share]# ls -l
total 0
d-wx-wx-wx. 2 why why 6 Apr  4 22:37 test
[root@zhangsan share]# cd test
[root@zhangsan test]# ll
total 0
-rw-r--r--. 1 why why 0 Apr  4 22:38 new
[root@zhangsan test]# ll
total 0
-rw-r--r--. 1 why why 0 Apr  4 22:38 chese
[root@zhangsan test]# ll
total 0
-rw-r--r--. 1 why why 0 Apr  4 22:38 chese
[root@zhangsan test]# ll
total 0

总结:修改目录文件内容需要 'w' 权限,还可以得出,想要查看指定目录的内容,需要目录的 'r'权限

搞清楚 目录文件权限 对应的作用后,我们继续下一个问题

3.粘滞位

有时候我们多个用户想要进行文件数据的共享,但是进行文件创建后,如果碰上不讲理的人删掉我们的文件,我们这时是没办法直接阻止其删掉我们的文件

不用怕,想要解决这个问题,只需要了解新的执行权限

-t(粘滞位) -- 一种特殊的执行权限

[root@zhangsan share]# chmod o+t test
[root@zhangsan share]# ll
total 0
d-wx-wx-wt. 2 why why 6 Apr  4 22:40 test

这样子修改后,其他人就只能对文件进行增加,修改,不能进行删除

w

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值