linux 文件权限

执行命令ll

linux 文件权限_第1张图片

linux 文件权限_第2张图片
  • 当文件类型为[* d* ]则是目录
  • 当文件类型为[* -* ]则是文件;
  • 若文件类型是[* l* ]则表示为链接文档(link file);
  • 若文件类型是[* b* ]则表示为装置文件里面的可供储存的接口设备(可随机存取装置);
  • 若文件类型是[* c* ]则表示为装置文件里面的串行端口设备,例如键盘、鼠标(一次性读取装置)。
权限解释(针对目录):
  • 当某用户拥有某目录r|w|x中任意权限时都可以cd 进入该目录
  • 当某用户只有拥有某目录r权限时才可以在该目录中执行ls等命令
  • 当某用户只有拥有某文件r权限时才可以对该文件执行cat等命令
  • 当某用户只有拥有某目录w权限时才可以对该目录执行rm命令,在该目录中执行touch mkdir rm等命令
  • 当某用户只有拥有某文件w权限时才可以对该文件执行编辑/删除操作
  • 在这里举一个例子:
    某用户拥有某目录的x权限,拥有该目录下某文件的r权限,那么如果现在要cat 该文件,则只能在知道该文件名的情况下才能这么操作,因为在该目录下是不允许read的
[root@localhost tmp]# ll | grep testdir
drwxr-x--x. 2 root  root    4096 Dec  4 14:52 testdir
[root@localhost tmp]# cd testdir/
[root@localhost testdir]# ll 
total 4
-rw-r--r--. 1 root root 15 Dec  4 11:47 test
[xxjqr@localhost tmp]$ ll | grep testdir
drwxr-x--x. 2 root  root    4096 Dec  4 14:52 testdir
[xxjqr@localhost tmp]$ cd testdir/
[xxjqr@localhost testdir]$ ll
ls: cannot open directory .: Permission denied
[xxjqr@localhost testdir]$ cat test
This file is created by the root user
权限修改:
linux 文件权限_第3张图片
  • u:user
  • g:group
  • o:other
  • a:all
    权限的增加与削减
[root@localhost testdir]# ll
total 4
-r--r--rwx. 1 root root 15 Dec  4 11:47 test
[root@localhost testdir]# chmod ug+x,o-rw test
[root@localhost testdir]# ll
total 4
-r-xr-x--x. 1 root root 15 Dec  4 11:47 test

权限的数字设定

[root@localhost testdir]# ll
total 4
-r-xr-x--x. 1 root root 15 Dec  4 11:47 test
[root@localhost testdir]# chmod 741 test
[root@localhost testdir]# ll
total 4
-rwxr----x. 1 root root 15 Dec  4 11:47 test

修改所属主与所属组
[root@localhost testdir]# ll
total 4
-rwxr----x. 1 root root 15 Dec  4 11:47 test
[root@localhost testdir]# chown xxjqr:xxjqr test #更改文件属主和属组
[root@localhost testdir]# ll
total 4
-rwxr----x. 1 xxjqr xxjqr 15 Dec  4 11:47 test

你可能感兴趣的:(linux 文件权限)