0

I have 4 users ( first - fourth ) and two groups to which users belong to: pro: ( first and second users ) lammer: ( third and fourth users ) each of them have home directories of /home/pro/first, /home/pro/second, /home/lammer/third, /home/lammer/fourth.

My problem comes from the fact that I don't really understand what the exercise is asking me to do (this will be rough translation).

Users can do whatever they want with their files.
Same group users can modify and write in each others root directory ( ex: in /home/pro/first, but not in /home/pro/first/example )?
User /home/pro/first can only delete files that he created, but not the ones others created. ( probably applies to others as well )

What I was thinking is that I do for each and every file:

chown first:pro /home/pro/pirmas
chmod 720 /home/pro/pirmas

But does this also prevent people from deleting files created by others and from creating files in /home/pro/pirmas/example?

0

What you need is the sticky bit. From man chmod:

RESTRICTED DELETION FLAG OR STICKY BIT

The restricted deletion flag or sticky bit is a single bit, whose interpretation depends on the file type. For directories, it prevents unprivileged users from removing or renaming a file in the directory unless they own the file or the directory; this is called the restricted deletion flag for the directory, and is commonly found on world-writable directories like /tmp. For regular files on some older systems, the bit saves the program's text image on the swap device so it will load more quickly when run; this is called the sticky bit.

For the directory to have the preferred privileges, I'd use

chmod 1770 /home/pro/pirmas

The group does at bare minimum need the execution bit in addition to write, or they cannot cd to the directory. I suggest giving the read bit too, since otherwise they cannot see the list of files there, even though they can create, edit and delete them :)

For more information on the permissions, see e.g. this excellent answer to a related question.

  • I will take it that chown part is good? Also will anyone from that group be able to write and view for example: /home/pro/pirmas/example? Cause that should be forbidden. – Wowy Apr 26 '20 at 9:43
  • Yes, chown is correct. Whether the other users are able to view or write the subdirectories depends on their priviledges: chmod 700 should prevent everything :) – Jaripekka Juhala Apr 27 '20 at 5:31

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.