How do I set files to be owned by multiple users?

I tried setting group ownership to sudo, but that still requires the sudo command to edit them. Filezilla also won't display them. I'm looking to add all files under the web server directory as owned by all the administrators and easily editable to all of them.

4 Replies

use groups and group rwx on files to satisfy your needs.

Ensure the default umask is correct.

The default group of users should be the shared group. chmod g+s on directories may help.

to clarify - don't use sudo. Use a different group specifically for this purpose.

Ok, so using sudo requires users to still need to use the sudo command to modify the files? Using another group, such as "administrators" will allow multiple users to access the files normally?

Yes. Take the following file as an example:

-rw-rw-r-- 1 someuser somegroup  81743 Oct  8 00:45 index.html

The file was probably created by "someuser", who is the owner and is able to read and write the file. Any members of "somegroup" can also read and write the file. All other accounts on the system (including the one that your web server runs under) are able to read the file.

If you want "anotheruser" to also be able to modify the file, you can add that account to the "somegroup" group with the usermod -a -G somegroup anotheruser command.

If you use the setgid bit on a directory, all files created in that directory will inherit the same group. This is handy as you then don't have to manually set the group on new files to "somegroup" all the time.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct