Setting correct permissions

15,924

For a little more secure approach I'd recommend creating a group for those 3 users and then chown'ing the directory by the group.

1. sudo groupadd mygroup

2. sudo usermod -aG {group-name} username

In your case it'd be

sudo usermod -aG mygroup plex ; sudo usermod -aG mygroup root ; sudo usermod -aG mygroup myuser

3. chown -Rf :mygroup /media
Share:
15,924
Panic0815
Author by

Panic0815

Updated on September 18, 2022

Comments

  • Panic0815
    Panic0815 almost 2 years

    First of all let me say that i am almost new to Linux so please be patient :) I have an Ubuntu 14.0.4 running on my Systems.

    What i am trying to do is: On my system there are sabnzbd and plex running. sabnzbd is running as root and plex has an own user (plex) with an own group (plex).

    What i need is that the user plex, myuser and also sabnzbd (root) have read, write and execute permission at /media and also all subfolders and files. I studied now a lot of stuff at the internet and tried my luck with chmod; chown; the /etc/group file; and many more but i am to stupid to get it to work.

    Can someone tell me what i need?

  • Panic0815
    Panic0815 over 9 years
    Sound pretty good - thanks. Just one more thing. Under /media there i have an ntfs hdd mounted with the permission option at fstab. Can i somehow remove unneccessary permissions first because acl is active and i already messed up a bit :( or will chown remove everything anyway? I tested now and "sudo useradd -G mygroup plex" will give me back something like this "useradd: User >>plex<< already exists" also for the other users.
  • olipinski
    olipinski over 9 years
    Sorry i got the wrong command. Edited the answer accordingly. In case of the ntfs i think that the chown will edit the permissions anyway, but in case any problem arise don't hesitate to comment here
  • Panic0815
    Panic0815 over 9 years
    I did this now and rebooted my system. Access seems to be OK but i seem no to be a sudoer any more: myuser ist nicht in der sudoers-Datei. Dieser Vorfall wird gemeldet. - myuser is not an member of the sudoers file. What to do?
  • olipinski
    olipinski over 9 years
    Reboot to the recovery console and add your user back to sudo from there on newer installations you will likely need to remount the root filesystem read-write first # mount -o remount,rw / # usermod -aG sudo user # exit
  • David Foerster
    David Foerster over 9 years
    This grants write privileges to everybody, not just the 3 mentioned users, and may not be what OP wants or needs. It also makes all files executable, which may lead to confusion and even security problems.
  • olipinski
    olipinski over 9 years
    Well that is due to the sabnzbd running as root. If you do not require to run it as such, then your problem is solved. I can't see any other way than this, but maybe a more experienced user would know. Only thing i can think of, that won't involve manually changing the permission is scheduling a script that does it to run every now and then.
  • olipinski
    olipinski over 9 years
    Thanks :) feel free to accept this as the answer if the issue was resolved