0

I had to do a restore of a fileserver and the permissions got lost for our personal folders.

Structure is like this.

\fileserver\share\usernames.

I need to set permissions so that each user has access to only their folders.

Thank you for your help

jdrover
  • 11

2 Answers2

0

Assuming that all folders in the /share/ directory represents user names, you can use:

 for dir in /share/*/; do
        # strip trailing slash
        homedir="${dir%/}"
        # strip all chars up to and including the last slash
        username="${homedir##*/}"
    
        case $username in
        *.*) continue ;; # skip name with a dot in it
        esac
    
        chown -R "$username" "$dir"
    done

Test this script in safe place , check if the user is the owner of her folder.

0

Additional information will be required to assist you. What type of environment are you working in? Is it Windows, Linux, OSX, or NAS device? Do you have the database of users on Windows Active Directory? You can pretty much create a file server from a workstation, server, or network device but you will need to create all the usernames and passwords for the clients (users).

If this is a NAS box, create usernames and passwords that match the usernames the individuals use to login to their perspective computer.

There are two sets of permissions. One would be the share permission which allows the user to connect to the share. There are three types of share permissions: Full Control, Change, and Read.

The second set of permission is the folder permissions. Create folders with name of the user. You will give each user full permission to their individual folder.

bitcollision
  • 131
  • 7
  • Server 2008 R2 is the environment. Structure is \\fileserver\share\username. AD profiles are set to connect to \\fileserver\share\username. – jdrover Feb 18 '21 at 20:24
  • I've tried many tutorials without success. It either ends up with everyone having access to everyone's folders or no one having access to any folders. – jdrover Feb 18 '21 at 20:25
  • Change the share permission to READ for Everyone rather than Full Control. Then change the permission on the NTFS permission so only the user has access to the individual folder. Check out https://support.randomsolutions.nl/380508-Security-Recommendations-for-Roaming-User-Profiles-Shared-Folders and https://docs.microsoft.com/en-us/windows-server/storage/folder-redirection/deploy-roaming-user-profiles – bitcollision Feb 18 '21 at 21:05