For example, assuming the filesystem on the disk supports ACL's, and using the hypothetical user, myusername, and the hypothetical group for accessing the disk, diskusers, something like the following could be done. $
indicated a command executed as a regular user; #
indicates a command executed as the user, root.
Create a group to which a user may belong for the purpose.
$ sudo groupadd diskusers
$ sudo usermod -a -G diskusers myusername
$ logout
Log in again.
$ sudo -i
# mount /media/workspace
# chown root:root /media/workspace
# chmod 0750 /media/workspace/
# setfacl -d -m -g:diskusers:7 /media/workspace
# setfacl -m g:diskusers:7 /media/workspace
The "7" in the setfacl
command is octal (read = 4 + write = 2 + execute = 1),
much like normal octal permissions (0400, 0200, 0100).
The -d
is a switch to specify a default mask - new files and directories.
The -m
is the mask to apply to the directory.
You also could apply the mask to all files initially after setting the default (above):
find /media/workspace -exec setfacl -m g:diskusers:7 {} +
At that point, only root and members of diskusers can access the files. I like Mark Plotnick's idea, too, about applying permissions to a subdirectory. This technique could be used that way, too.