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

1
  • So add the permissions. What's the trouble?
    – joeqwerty
    Feb 18, 2021 at 19:44

2 Answers 2

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.

1
  • It is for Server 2008 R2.
    – jdrover
    Feb 18, 2021 at 20:20
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.

3
  • Server 2008 R2 is the environment. Structure is \\fileserver\share\username. AD profiles are set to connect to \\fileserver\share\username.
    – jdrover
    Feb 18, 2021 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, 2021 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 support.randomsolutions.nl/… and docs.microsoft.com/en-us/windows-server/storage/… Feb 18, 2021 at 21:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .