Jump to content

Shared Drive Ownership Between User & Program?

I'm nearly finished setting up my Nextcloud server, but I have a slight problem.

When I give permission to Nextcloud to access my local drive (4TB Seagate external drive), my Ubuntu user profile no longer has the ability to make changes to the drive, let alone access the content on the drive at all.


This is the command I'm using to give Nextcloud full permissions on the mounted disk: sudo chown -R www-data:www-data /mnt/sdb1 ~ sudo chmod -R 0750 /mnt/sdb1

My friends suggested I use this command to give my Ubuntu profile (TalaFTW) access to the drive: sudo chown talaftw -v /mnt/sdb1

However, when I use the second command, the files within the drive still can't be accessed, or some will be and others won't.

My question is: Is there any way to give both Nextcloud & my Ubuntu profile permission to do everything we need to do to basically be dual gods to the drive? Shared permissions that won't conflict with each other?
I've asked other forums and none of them would give me a straight and simple to follow answer.

Thank you very much in advance. Cheers

 

Aspiring IT technician... The AF is getting in the way. Poet and PC enthusiast (of a lower caliber, so-to say) :)

 

Link to comment
Share on other sites

Link to post
Share on other sites

add your user to the group www-data by using usermod -G www-data -a User

Edit: Forgot to mention: you need to allow writes from owner groups with sudo chmod -R 0770 /mnt/sdb1

Edited by kompetenzbolzen
Link to comment
Share on other sites

Link to post
Share on other sites

30 minutes ago, kompetenzbolzen said:

add your user to the group www-data by using usermod -G www-data -a User

Edit: Forgot to mention: you need to allow writes from owner groups with sudo chmod -R 0770 /mnt/sdb1

So, once I get Nextcloud to have ownership, I should put do the same with my user profile?

Aspiring IT technician... The AF is getting in the way. Poet and PC enthusiast (of a lower caliber, so-to say) :)

 

Link to comment
Share on other sites

Link to post
Share on other sites

Does anyone know the exact command I can paste into the terminal?
I'm completely new to attaching hard drives to a cloud service like this

Aspiring IT technician... The AF is getting in the way. Poet and PC enthusiast (of a lower caliber, so-to say) :)

 

Link to comment
Share on other sites

Link to post
Share on other sites

What you did was assign the owner & group to netcloud. Then with chmod 750 since your Ubuntu user doesn't belong to the group you removed all permission to access it.

 

Probably the easiest thing you can do is add your user to to netcloud group then use 770 should give each account full access.

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, PCn00b3000 said:

So, once I get Nextcloud to have ownership, I should put do the same with my user profile?

No, just run the commands you used to give nextcloud permission and replace the chmod 750 with chmod 770, then run the usermod.

What you're doing is setting /mnt/sdb1 to be owned by user www-data and group www-data with chown. If you add your user to the group www-data with usermod, the second set of permissions ( 770 ) will apply to your user because it's in the group www-data.

Link to comment
Share on other sites

Link to post
Share on other sites

I would suggest you look up how Linux file permission work. But here's a quick rundown:

Files and folders have both an owner an an owner group.

Files and folders also have three sets of permissions: 1. What the owner can do 2. what members of owner group can do 3. what everyone else can do

 

Those 3digit numbers work like this:

the digits represent seperate sets of permissions (owner,group,everyone)

digits are calculated with: +1 for execute permission, +2 for write, +4 fo read. (eg. 7 = 1+2+4 => full access)

Link to comment
Share on other sites

Link to post
Share on other sites

Looks like I've got some more reading to do... I don't even know what to put in as my user profile besides "root", since that doesn't work either

dce.jpg

Aspiring IT technician... The AF is getting in the way. Poet and PC enthusiast (of a lower caliber, so-to say) :)

 

Link to comment
Share on other sites

Link to post
Share on other sites

Okay. I have access to the drive through my ubuntu user profile, and Nextcloud is accepting the local mount point and saving the settings.

I used the following commands in this exact order on a newly formatted drive (EXT4):

sudo chown -R www-data:www-data /mnt/sdb1
sudo chmod -R 0750 /mnt/sdb1
sudo chown -R talaftw /mnt/sdb1
sudo chmod -R 0770 /mnt/sdb1

After that, my profile can add and edit the files on the drive. Now, Nextcloud (within the control panel) will not show any of the files that are present on the drive, even with the permissions.
 

Aspiring IT technician... The AF is getting in the way. Poet and PC enthusiast (of a lower caliber, so-to say) :)

 

Link to comment
Share on other sites

Link to post
Share on other sites

Try this:

sudo chown -R www-data:www-data /mnt/sdb1

sudo chmod -R 0770 /mnt/sdb1

sudo usermod -G www-data -a talaftw

You want the directory to be owned by www-data (the user the webserver runs as), but add your user to the group www-data to also be able to access the files

 

Link to comment
Share on other sites

Link to post
Share on other sites

All of the commands were accepted, and I see this now (attached photo), so that worked well.
Though, for some reason, Nextcloud is still not showing the test images and files I put onto the drive.
I've rebooted apache2 as well, so I'm not sure what else to do.

Screenshot from 2019-08-30 20-23-35.png

Aspiring IT technician... The AF is getting in the way. Poet and PC enthusiast (of a lower caliber, so-to say) :)

 

Link to comment
Share on other sites

Link to post
Share on other sites

I don't know how nextcloud works exactly, but i think it uses a database for files and just does not show files directly added to the drive.

Link to comment
Share on other sites

Link to post
Share on other sites

13 minutes ago, kompetenzbolzen said:

I don't know how nextcloud works exactly, but i think it uses a database for files and just does not show files directly added to the drive.

I'm using Mariadb for that, and my system is configured properly to where it's recognized on Nextcloud.
I wonder if I need to do any config changes on there at all

Aspiring IT technician... The AF is getting in the way. Poet and PC enthusiast (of a lower caliber, so-to say) :)

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×