I have an account with a directory full of images that are regularly changed by scripts in the account. I have another account, and I want its scripts to be able to add / delete images in that same directory.
Eg, main directory:
/home/example/www/images/
should be able to be modified by user "example" and user "new".
I set up a symlink from the new account to the main directory, ala:
ln -s /home/example/www/images/ /home/new/
and the scripts in /new/ can read the files in /example/www/images/, but can't upload new ones. FWIW, the permission for the main directory is 0777.
I should mention that there are 6 directories in /example/ that I really want to share.
Can I just make "new" a user for the existing "example" without any real problems? Eg:
# Add "new_username" to group "example"
usermod -aG example new_username
# Change permissions for each directory to be shared
cd /home/example/images/
umask 002
chmod -R 2777 /home/example/images/
If not, then what if I created /home/shared/ manually (not as an account), then symlink the directories in both /example/ and /new/ to it? Like so (I think):
# Create group
groupadd shared
# Setup username and password for new group
# (do I just make up a username and password here?)
useradd -d /home/shared/ -g shared -m shared_username
passwd shared_password
# Add /example/ as a user
useradd -d /home/shared/ -g shared example_username
passwd example_password
# Add /new/ as a user
useradd -d /home/shared/ -g shared new_username
passwd new_password
# Change group ownership
chown -R shared_username:shared /home/shared/
# Set group permission
chmod -R 2775 /home/shared/
# Symlink
ln -s /home/shared/www/images/ /home/example/
ln -s /home/shared/www/images/ /home/new/
I would much rather not have to create a separate directory, because that would mean a lot of script modifications to /example/; and, of course, the account's stats (storage and bandwidth) would be wrong. But, if it's the best option, it CAN be one.
If neither of these are good options, what's a better idea?