I am setting up a web development uBuntu server for multiple users.

The website files are all owned by root and in the group root.

As I was trying to avoid giving parts of the file structure 777 permissions, I tried solving my problem by using user groups with the following lines of code:

user@localhost:~$ sudo groupadd developers
user@localhost:~$ grep 'developers' /etc/group
user@localhost:~$ sudo usermod -a -G developers user
user@localhost:~$ sudo chown -R root:developers test
user@localhost:~$ sudo chmod 664 test
user@localhost:~$ ll

-rw-rw-r--  1 root developers    0 Oct 10 11:33 test
  • I add my "developers" group
  • I confirm my developers group exists
  • I add an existing user to the new group
  • I change the group of a test file from root to developers
  • I give the group read and write permissions on the test file
  • I list the contents of the directory to confirm the group and permissions have been correctly altered

With all those steps accomiplished, attempts to save the test file are still unsuccessful.

Am I doing something wrong, please?

  • What are you using to edit the file? If it's an application that tries to rename the old file to keep a backup before writing a new file that could be a reason (lacking directory permissions). – Seth Oct 10 '17 at 13:06
  • I mounted the remote file structure to my local harddrive and I edit them using sublime – sisko Oct 10 '17 at 14:53
  • What are permissions of the folder where your file test is situated? If it lacks write permissions for the corresponding group you can not write to this file even if it has write prmission. – Oleg Bolden Oct 10 '17 at 16:31
  • The containing folder has 664 permissions – sisko Oct 10 '17 at 18:37
  • With such folder permissions you can not operate with the content of this folder as a nonroot user unless you set an execution bit (--x). In your case, if your folder group permission is 6 and you want to alter content of the file inside this folder with the same group (developers), you need odd 1,3,5 or 7 permissions for the folder group. With 1 and 3 you can alter the file content being outside the folder, because you can not enter it without enabled read permission (4). With 5 and 7 you can alter the file content being within this folder. – Oleg Bolden Oct 10 '17 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.