I'm trying to give every user writing permission to the data partition. However when I do so every user can delete each others folder although he has no rights to that folder. What I want is: 1) Every user can write on "/media/data" 2) No user can delete a folder created by another user on "/media/data"
The data partition is mounted via this entry in the /etc/fstab
/dev/sdb1 /media/data ext4 defaults 0 0
When the partition was empty I also did this:
$ sudo chown -R :users /media/data
$ sudo chmod -R g+rw /media/data
As I recall, without these two last commands non of the users could write anything to the data partition.
Now I think the problem is that giving writing permission to the group "users" (g+rw
), is part of the problem. Since that already means that everyone in "users" can delete anything under "/media/data". Still I want my multiuser Ubuntu System to be configured in the way as mentioned above (Everyone can write to the data partition, but nobody can delete stuff created by other users).
Has anyone an idea how to do this?
The answer to this is to set the sticky bit (t) of your directories.
You set the sticky bit recursively on your data directory by:
This restricts the right to delete or rename a file only to the owner of a file, although the directory might be publicly readable and writeable.
The permissions string will after that look like e.g.
rwxrwxrwt
if the owner user, group and every other user all have full permissions (read, write, execute), whereas only each specific file's owner may delete or rename it.