A summary of Linux file permissions

Source: Internet
Author: User

Summary of permissions: for ordinary files:
r:read 可读,表示具有读取、阅读文件内容的权限w:write可写,表示具有新增、修改文件内容的权限(是否可以删除看上级目录的权限)1)  如果没有r,那么vim会提示无法编辑(可强制编辑,echo可以重定向编辑或追加)2)  如果没有r,那么执行他也会提示权限不足3)  删除文件(修改文件名等)的权限是受父目录的权限限制的,和目录本身权限无关x:execute 执行权限,
For the directory:
r:表示具有浏览目录下面及子目录的权限,即ls 和dir1)  如果没有x权限,不能进入到目录里面2)  如果没有x权限,ls列表是可以看到所有文件名,但是会提示无权访问目录下的文件3)  如果ls –l列表,所有的属性会带有问号,也会提示无权访问目录下的文件,但是可以看到所有文件名。w:具有增加、删除和修改目录内文件名(一般指文件名)的权限(需要x权限配合)x:表示具有进入目录的权限,没有r权限能进去但是不能修改,创建和删除的功能。
[[email protected] tmp]$ ll -d zsf/   #查看这个目录的权限drwxr-xr-- 2 oldgirl incahome 4096 Mar 22 23:17 zsf/[[email protected] tmp]$ ls zsfls: cannot access zsf/test.sh: Permission denied   #提示权限被拒绝test.sh   #但是显示里面的文件内容[[email protected] tmp]$ cd zsf/  #切换目录不成功,没有权限-bash: cd: zsf/: Permission denied[[email protected] tmp]$ ll zsf   #对应上面的3解释ls: cannot access zsf/test.sh: Permission deniedtotal 0-????????? ? ? ? ?            ? test.sh
The default properties for a file are determined by Umask:
临时设置umask值:umask 0022目录默认的总权限为0777,然后实际权限为0777-umask==实际权限文件默认的总权限为0666,然后实际权限为0666-umask(当碰到奇数的时候在奇数位加上1)==实际权限
Special permissions:
sUID:set uid数字代号“4”在一个程序或命令上添加setuid以后(u+s),这样属主就有了s权限,意味着任何用户在执行此程序时,其进程的属组不再是发起者本人,而是属主。最典型的例子passwd命令;[[email protected] tmp]# ll -d `which passwd`-rwsr-xr-x. 1 root root 30768 Feb 22  2012 /usr/bin/passwd普通用户不具备对/etc/passwd文件的修改权限[[email protected] tmp]# ll -d /etc/shadow-rw-r--r-- 1 root root 1057 Mar 16 21:32 /etc/shadow,但是普通用户却能修改自己的密码。是因为passwd有setuid权限,当他执行passwd命令时就相当于root在执行,在对shadow修改文件。当user权限本身具有x权限的时候,s为小写,当不具备x权限的时候S为大写sgid:set gid 数字代号“2”,在一个程序或命令上添加set gid以后(g+s),这样属组就有了s权限,意味着任何用户在执行此程序时,其进程的属组不再是发起者本人的属组,而是文件属组。给目录设置Set gid权限,任何用户在该目录下创建的文件,则该文件属组都和目录的属组一致。当group权限本身具有x权限的时候,s为小写,当不具备x权限的时候S为大写t:sticky 数字代表1,附加在other的权限上,当设置此权限的之后,每个人的文件或目录只能有自己本身删除。文件的权限可以通过chmod指令来修改,支持运算表达式。

A summary of Linux file permissions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.