Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

FIX: newperms working with spaces in folders

Featured Replies

Hi all,

 

I got quite frustrated when the newperms script didn't work when calling it manually to assign new permissions on a folder that contained spaces so I decided to fix it. I use SABnzbd extensively and a few other apps that create files on the array and they're always being created as root with messed up permissions. I couldn't use the new perms script since anything with a space in it would fail.

 

Well, all is good, here it is.. Quite simple fix really.

 

#!/bin/bash

# Usage: newperms [dir]
# Recursively changes the ownership and permissions of the directory and all files/subdirs
# within the directory.  If dir is omitted, then operates on /mnt/cache and /mnt/disk*
# This was created to fix ownership/permissions for unRAID version 5.x

function process {
  if [ -e "$1" ] ; then
    echo "processing $1"
    echo "... chmod -R go-rwx $1"
    chmod -R go-rwx "$1"
    echo "... chmod -R u-x $1"
    chmod -R u-x "$1"
    echo "... chmod -R g+u $1"
    chmod -R g+u "$1"
    echo "... chmod -R ug+X $1"
    chmod -R ug+X "$1"
    echo "... chgrp -R users $1"
    chgrp -R users "$1"
    echo "... chown -R nobody $1"
    chown -R nobody "$1"
  fi
}

if [ -n "$1" ] ; then
  process "$1"
else
  process /mnt/cache
  for disk in /mnt/disk* ; do
    process $disk
  done
fi

 

Great, thanks!

 

I  have sabnzbd set to run a post-processing script to fix the permissions but it isn't always successful.  I think it's to do with the sorting when it doesn't work as expected.

 

The script itself is just a one-liner...

 

chown -R nobody.users "$1"

  • Author

The correct syntax would be

 

chown -R nobody:users "$1"

 

note it's a ":" and not a "." that concatenates the user and the group.

 

Cheers,

ah OK, thanks, I've amended my script.

Actually the character between owner and group does not matter if it's ":" or ".". In Slackware distros, such as unRAID the "." works perfectly fine because of backwards compatability. Even though "." is still supported, it is deprecated and considered to be bad form to still use it.

 

Directly from the "chown" invocation info pages

  Some older scripts may still use `.' in place of the `:' separator. POSIX 1003.1-2001 (*note Standards conformance::) does not require support for that, but for backward compatibility GNU `chown' supports `.' so long as no ambiguity results.  New scripts should avoid the use of `.' because it is not portable, and because it has undesirable results if the entire OWNER`.'GROUP happens to identify a user whose name contains `.'.

  • Author

Interesting.. I did not know that, but then again, I've never seen it used that way.

The correct syntax would be

 

chown -R nobody:users "$1"

 

note it's a ":" and not a "." that concatenates the user and the group.

 

Caveat, I'm new to unRAID so perhaps there are quirks I am unaware of.

 

Not true. Using a '.' works just fine, in fact any character would do the trick to split the two parts.

I've been using '.' for 10+ yeats in Unix/Linux.  I always use this format to avoid also using chgrp command.

 

 

 

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.