Linux文件权限(深入)-数字到字符串的表示法,反之亦然;额外的文件权限 [英] Linux file permissions(in-depth) - numeric to string notation, and vice versa; additional file-permissions

查看:287
本文介绍了Linux文件权限(深入)-数字到字符串的表示法,反之亦然;额外的文件权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想出了如何将rwx符号部分转换为421八进制部分的方法,这非常简单.但是当涉及到特殊字符时,我感到非常困惑.我们知道-r-xr --- wx转换为0543,但是-r-sr --- wt或-r-xr --- wt转换为什么呢?

I figured out how to read/convert the symbolic rwx parts to 421 octal parts, which was pretty straight forward. But I am extremely confused when there's the special characters involved. We know that -r-xr---wx converts to 0543, but what does -r-sr---wt or -r-xr---wt convert to?

我相信在用户执行许可下有x,s,S.对于组执行许可也有x,s,S.然后所有其他用户执行许可有x,t,T.这些是什么意思,怎么办?他们转换为八进制表示法.我猜它与0421中的0位置有关吗?

I believe for under user execute permission there's x, s, S. For group execute permission there's also x, s, S. Then all other user execute permission there's x, t, T. What do all these mean and how are they converted over to the octal notation. I'm guessing it has something to do with the 0 position in 0421?

在我的课堂笔记中说,5543转换为-r-sr --- wt.然后,示例问题-r-S-wsrw-转换为6536,不同的是它希望我们固定第二个位置(5),以便将其正确转换.

From my class notes it says that 5543 converts to -r-sr---wt. Then a sample question of -r-S-wsrw- converts to 6536 except that it wants us to fix the second position (5) so that it'll be the correct conversion.

我搜索并搜索了很多Google内容,但令人惊讶的是这些特殊字符找不到任何内容.

I searched and Googled plenty, but surprisingly couldn't find anything on these special characters.

推荐答案

在网络上进行了深入搜索之后,我发现了

After in-depth searching on the Web, I found this link about Understanding Linux File Permissions which describes it in detail :

s-此 表示 的setuid/setgid权限.未设定 显示在权限显示的特殊权限部分中, 但在所有者或组的已读取部分中以s表示 权限.

s - This indicated the setuid/setgid permissions. This is not set displayed in the special permission part of the permissions display, but is represented as a s in the read portion of the owner or group permissions.

t-这表示粘滞位权限.未设定 显示在权限显示的特殊权限部分中, 但在所有用户的可执行部分中以t表示 权限

t - This indicates the sticky bit permissions. This is not set displayed in the special permission part of the permissions display, but is represented as a t in the executable portion of the all users permissions

Setuid/Setgid特殊权限

--- setuid/setguid权限用于告诉系统以具有所有者权限的所有者身份运行可执行文件.

---The setuid/setguid permissions are used to tell the system to run an executable as the owner with the owner\'s permissions.

---请谨慎使用权限中的setuid/setgid位.如果您错误地将设置为setuid/setgid的权限分配给root拥有的文件,则可以打开系统进行入侵.

---Be careful using setuid/setgid bits in permissions. If you incorrectly assign permissions to a file owned by root with the setuid/setgid bit set, then you can open your system to intrusion.

---您只能通过显式定义权限来分配setuid/setgid位. setuid/setguid位的字符为s.

---You can only assign the setuid/setgid bit by explicitly defining permissions. The character for the setuid/setguid bit is s.

粘性位特殊权限

---粘性位在共享环境中非常有用,因为当它已分配给目录的权限时,它会对其进行设置,以便只有文件所有者才能重命名或删除该文件.

---The sticky bit can be very useful in shared environment because when it has been assigned to the permissions on a directory it sets it so only file owner can rename or delete the said file.

---您只能通过显式定义权限来分配粘性位.粘性位的字符是t.

---You can only assign the sticky bit by explicitly defining permissions. The character for the sticky bit is t.

从数字(1/2/4421)转换为符号(rwx/s/t)的逻辑:

第一个数字表示所有者权限;第二个代表组权限;最后一个数字代表所有其他用户的权限.数字是rwx字符串的二进制表示形式.

The first number represents the Owner permission; the second represents the Group permissions; and the last number represents the permissions for all other users. The numbers are a binary representation of the rwx string.

r = 4
w = 2
x = 1

--->粘性位可以使用chmod命令进行设置,并且可以使用八进制模式1000或符号t(setuid位已使用s)进行设置.例如,要在目录/usr/local/tmp上添加该位,可以键入chmod 1777 /usr/local/tmp.

---> The sticky bit can be set using the chmod command and can be set using its octal mode 1000 or by its symbol t (s is already used by the setuid bit). For example, to add the bit on the directory /usr/local/tmp, one could type chmod 1777 /usr/local/tmp.

---> setuid和setgid位通常是通过chmod命令设置的,方法是将setuid的高位八进制数字设置为 4 ,对于setgid的设置为 2 . chmod 6711 file将同时设置setuid和setgid位(4 + 2 = 6),从而使文件对所有者(7)可读/可写/可执行,并可由组(前1个)和其他人(第二个1)执行.

---> The setuid and setgid bits are normally set with the command chmod by setting the high-order octal digit to 4 for setuid or 2 for setgid. chmod 6711 file will set both the setuid and setgid bits (4+2=6), making the file read/write/executable for the owner (7), and executable by the group (first 1) and others (second 1).

注意:

s  ---  The setuid bit when found in the user triad; the setgid bit when found in the group 
        triad; it is not found in the others triad; it also implies that x is set.
S  ---  Same as s, but x is not set; rare on regular files, and useless on folders.
t  ---  The sticky bit; it can only be found in the others triad; it also implies that x is
        set.
T  ---  Same as t, but x is not set; rare on regular files, and useless on folders.

s,S,t和T值始终附加在其他用户组之前 权限符号.因此,符号的第一个字母表示附加到字符串的s,S,t或T值.接下来的3个字母是通常的权限.

s, S, t and T values are always appended before the user-group-others permission notation. So, first letter of the notation represents s, S, t or T values appended to the string. The next 3 letters are the usual permission.

您与文件权限有关的问题/示例:

Your questions/examples related to file-permissions :

1. -r-sr---wt   = 5543, first 5(s set for user = 4 + t set for others = 1),
                  second 5(r=4,s=1), third 4(r = 4), and last, fourth 3(w=2, t = 1).


2. -r-S-wsrw-   = 6436, first 6(S set for user = 4 + s set for group = 2),
                  second 5(r=4, x=0, since S don't account for x), 
                  third 3(w = 2, s results in x = 1), and last, fourth 6(r=4,w=2).

这篇关于Linux文件权限(深入)-数字到字符串的表示法,反之亦然;额外的文件权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆