If you are using Linux with a relatively modern filesystem (ext3/ext4, btrfs, ntfs), this can be done with POSIX ACLs:
Enable ACLs for the filesystem. This is only necessary for ext3 and ext4 on kernels older than 2.6.38. All other filesystems that support ACLs enable them automatically.
mount -o remount,acl /
tune2fs -o acl /dev/<partition>
Give tom
access to the folder:
setfacl -m user:tom:rwx /home/samantha/folder
If the OS or the filesystem does not support ACLs, another way is to use groups.
Create a group.
Some Linux distributions create a separate group for each user: tom
would automatically be in a group also named tom
.
If not, create a group. This should work on Linux...
groupadd tom
gpasswd -a tom tom
...and this - on BSD:
groupadd tom
usermod -G tom tom
chgrp
the directory to that group, and give permissions with chmod
:
chgrp tom /home/samantha/folder
chmod g+rwx /home/samantha/folder