03-linux System Special Privileges

Source: Internet
Author: User

Special Permissions Set_uid,set_gid

SUID:
Valid only for binary programs
Performer requires x permission for the program
The performer owns the permissions of the program owner while the program is running
For example:
The normal user executes the passwd command.

SGID
For files:
Sgid Useful for binary programs
The program executes to have X permission
The performer will be given permission to change the program user group during execution (equivalent to a user group that has temporarily joined the program)

Special Permissions Stick_bit

Sbit:
Valid only for Catalogs
When a user has WX permissions on a directory, the files or directories created by the user in that directory are deleted only by themselves and by Root.

* How to set special permissions for files:

chmod u+s xxx # 设置setuid权限chmod g+s xxx # 设置setgid权限chmod o+t xxx # 设置stick bit权限,针对目录chmod 4775 xxx # 设置setuid权限chmod 2775 xxx # 设置setgid权限chmod 1775 xxx # 设置stick bit权限,针对目录
Soft link file, hard connect file
软链接(soft link):A是B的软链接(A和B都是文件名),A的目录项中的inode节点号与B的目录项中的inode节点号不相同,A和B指向的是两个不同的inode,继而指向两块不同的数据块。但是A的数据块中存放的只是B的路径名(可以根据这个找到B的目录项)。A和B之间是“主从”关系,如果B被删除了,A仍然存在(因为两个是不同的文件),但指向的是一个无效的链接。
硬链接(hard link):文件A是文件B的硬链接,则A的目录项中的inode节点号与B的目录项中的inode节点号相同,即一个inode节点对应两个不同的文件名,两个文件名指向同一个文件,A和B对文件系统来说是完全平等的。如果删除了其中一个,对另外一个没有影响。每增加一个文件名,inode节点上的链接数增加一,每删除一个对应的文件名,inode节点上的链接数减一,直到为0,inode节点和对应的数据块被回收

Description of the use limit:

硬链接:a:不能对目录创建硬链接,原因有几种,最重要的是:文件系统不能存在链接环(目录创建时的”..”除外,这个系统可以识别出来),存在环的后果会导致例如文件遍历等操作的混乱(du,pwd等命令的运作原理就是基于文件硬链接,顺便一提,ls -l结果的第二列也是文件的硬链接数,即inode节点的链接数)b:不能对不同的文件系统创建硬链接,即两个文件名要在相同的文件系统下。c:不能对不存在的文件创建硬链接,由原理即可知原因。
软链接:a.可以对目录创建软链接,遍历操作会忽略目录的软链接。b:可以跨文件系统c:可以对不存在的文件创建软链接,因为放的只是一个字符串,至于这个字符串是不是对于一个实际的文件,就是另外一回事了

* * The role of hard links and soft links * * *

硬链接:硬连接的作用是允许一个文件拥有多个有效路径名,这样用户就可以建立硬连接到重要文件,以防止“误删”的功能。只删除一个连接并不影响节点本身和其它的连接,只有当最后一个连接被删除后,文件的数据块及目录的连接才会被释放。也就是说,文件真正删除的条件是与之相关的所有硬连接文件均被删除。
软链接:软链接又称之为符号连接(Symbolic Link)。软链接文件类似于Windows的快捷方式。它实际上是一个特殊的文件。在符号连接中,文件实际上是一个文本文件,其中包含的有另一文件的位置信息。

03-linux System Special Privileges

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.