Quick sh script cronjob to fix user homes permissions on Synology

If you have a Synology where multiple users access files, but frequently moves files around as the admin user, you’ve no doubt noticed that permissions can frequently get messed up, where regular users won’t be able to delete files created by the admin user, and so on. This can be especially prevalent when using the “user homes” feature.

You could use file manager as the admin user to fix permissions by hand, but there’s an easier way.

This quick little script, when run as a cron task, will traverse the home directories, resetting permissions automatically. It’s especially handy.

This was done on a DS211j running DSM-4.2 BETA.

So, here’s the script:

HOMES="/volume1/homes"
cd $HOMES
for x in *; do chown -R $x $x; done

Change HOMES to reflect where your user home is.

So, first go in and upload it somewhere on your DiskStation where you like it. In this case, I’m uploading it to admin’s user home.

homeperms_1

Now, right-click on it and select Properties, and set it as follows (that’s chmod 0700 for those of you paying attention)

homeperms_2

Now, to simply set it as a scheduled task. Open Control Panel > Task Scheduler and click Create > User Defined Script.

homeperms_3

Set up the task as follows:

 

homeperms_4

Under the general tab, use something descriptive for the task name, and run as root. Make sure enabled is checked.

Enter the full path to your script (the provided is typical, but yours may differ — use SSH to help you locate the file if unsure)

For the schedule tab:

homeperms_5

I have mine set to run hourly. Granted, I don’t update my files that often, but it helps to make sure permissions are set correctly and make sure they’re never wrong for very long.

And then click Ok. This should show:

homeperms_6

And that’s it. Your home permissions will be fixed automatically from now on.

Questions, comments, or feedback on the above? Please leave it in the comment section below. Thank you!

 

About these ads
  1. #1 by Bob on January 2, 2014 - 12:41 pm

    Hi, The text looks interesting, but the graphics are broken at this site: http://mikebeach.org/2013/03/02/quick-sh-script-cronjob-to-fix-user-homes-permissions-on-synology/

    • #2 by Mike on January 2, 2014 - 4:44 pm

      Thanks for letting me know. Images are fixed.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: