Linux 如何在 ubuntu 上将文件设置为此 drwxrwsrwx 权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9129959/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:21:48  来源:igfitidea点击:

How to set a file to this drwxrwsrwx permission on ubuntu

linuxubuntu-11.04

提问by Morne Zeelie

How do I set my file permissions to this drwxrwsrwx? I need it to be the same as my folders.

我如何设置我的文件权限到这个 drwxrwsrwx?我需要它与我的文件夹相同。

Thanks

谢谢

采纳答案by jon

Edit: Correct Answer is by user112358132134

编辑:正确答案是 user112358132134



My wrong answer:

我的错误答案:

The first character of drwxrwsrwxis dand that means directory. You won't be able to set a file so that it's a directory, because it's a file :)

drwxrwsrwxis的第一个字符d表示目录。您将无法将文件设置为目录,因为它是一个文件:)

To set all files in the current directory to -rwxrwsrwxyou can use chmod 777 *

要将当前目录中的所有文件设置为-rwxrwsrwx您可以使用chmod 777 *

To do this recursively, from the current directory use: chmod -R 777 *

要递归地执行此操作,请从当前目录使用: chmod -R 777 *

Try man chmodfor more info. Hope this helps.

尝试man chmod了解更多信息。希望这可以帮助。



Edit: Correct Answer is by user112358132134

编辑:正确答案是 user112358132134



Edit: Me checking:

编辑:我检查:

enter image description here

在此处输入图片说明

回答by Christopher Neylan

chmod 777does notapply rwxrwsrwx. This implicitly means chmod 0777, would apply rwxrwxrwx, and is significantly different from rwxrwsrwx.

chmod 777适用rwxrwsrwx。这隐含地意味着chmod 0777,将适用rwxrwxrwx,并且与rwxrwsrwx.

The permission rwxrwsrwxcan be applied with:

该权限rwxrwsrwx可以通过以下方式应用:

chmod 2777 your_target

You can show the effective permission string of a file or directory with:

您可以使用以下命令显示文件或目录的有效权限字符串:

ls -lad your_target

A file would look like:

一个文件看起来像:

-rwxrwsrwx    1 user  group         0 Feb  3 13:24 foo

And a directory would look like:

一个目录看起来像:

drwxrwsrwx    2 user  group      4096 Feb  3 13:24 bar

The first character of the string indicates the type of object that it is. A normal file will have -and a directory will have d. There are other possibilities for other objects.

字符串的第一个字符表示它是对象的类型。一个普通文件将有-一个目录将有d. 其他对象还有其他可能性。

The remaining 9 characters, in order, refer to the read/write/execute permission for the user owner, the read/write/execute permission for the group owner, and then the read/write/execute permission for everyone else.

剩下的9个字符依次是用户所有者的读/写/执行权限,组所有者的读/写/执行权限,然后是其他所有人的读/写/执行权限。

In your example, the user owner and everyone permissions are rwx, which means that the user owner and everyone have permission to read, write, and execute the object.

在您的示例中,用户所有者和所有人的权限为rwx,这意味着用户所有者和所有人都具有读取、写入和执行对象的权限。

The group owner permissions in your example are rws, which means that the group owner has read, write, and execute process AND the object has the setguidbit set (this is the sin rws). On a file, the setgidbit means that, if the file were executed, that it would be run with the effective rights of the group owner (instead of that of the user who executed it). On a directory, the setgidbit means that, if a file is created in the directory, its group-owner would be that of the directory (instead of that of the user who created it).

您的示例中的组所有者权限是rws,这意味着组所有者具有读取、写入和执行过程,并且对象setguid设置了位(这是sin rws)。在文件上,该setgid位意味着,如果文件被执行,它将以组所有者的有效权限运行(而不是执行它的用户的权限)。在目录上,该setgid位意味着,如果在目录中创建文件,则其组所有者将是目录的所有者(而不是创建它的用户的所有者)。

You can read about Linux permissions, including what read/write/execute means on files and directories, hereand here.

您可以在此处此处阅读有关 Linux 权限的信息,包括读/写/执行对文件和目录的含义。