文件权限号的手册页

mas*_*mas 2 man permissions chmod

是否有文件权限号的手册页?

我具体说的是

r = 4
w = 2
x = 1
Run Code Online (Sandbox Code Playgroud)

我永远记不起它们,每次需要设置除 755 之外的权限时,我都必须用 google 搜索。我也不认为我是孤单的,因为甚至有一个网站可以为您计算该数字

我刚刚意识到手册页chmod没有任何数字描述,我不知道其他页面会有它们。我想一个info页面也可以工作,因为显然它是预先安装的(我有拱门;我以为我必须自己安装那个 - 显然不是)。如果我可以参考“在线”手册页(我在 参考资料中使用“在线” man man),那么对我来说会容易得多。

Ste*_*ris 6

man chmod可能会给你命令行工具。这可能包括一些容易错过的文字

第二个数字选择拥有该文件的用户的权限:读取 (4)、写入 (2) 和执行 (1)

如果你man 2 chmod这样做了,那么你就会得到真正完成工作的系统调用。这很难读,但确实包含了神奇的数字:

   S_IRUSR  (00400)  read by owner
   S_IWUSR  (00200)  write by owner
   S_IXUSR  (00100)  execute/search  by owner ("search" applies for direc-
                     tories, and means that entries within  the  directory
                     can be accessed)
   S_IRGRP  (00040)  read by group
   S_IWGRP  (00020)  write by group
   S_IXGRP  (00010)  execute/search by group
   S_IROTH  (00004)  read by others
   S_IWOTH  (00002)  write by others
   S_IXOTH  (00001)  execute/search by others
Run Code Online (Sandbox Code Playgroud)

它还提供了一些其他神奇的值:

   S_ISUID  (04000)  set-user-ID  (set  process  effective  user   ID   on
                     execve(2))

   S_ISGID  (02000)  set-group-ID  (set  process  effective  group  ID  on
                     execve(2);  mandatory  locking,   as   described   in
                     fcntl(2);  take a new file's group from parent direc-
                     tory, as described in chown(2) and mkdir(2))

   S_ISVTX  (01000)  sticky bit (restricted deletion flag, as described in
                     unlink(2))
Run Code Online (Sandbox Code Playgroud)

  • @undercat我总是猜测它是“stat”“inode”...但这只是一个猜测,可能完全错误:-) (4认同)