# Permission problem after moving data folder

**URL:** <https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928>\
**Category:** ℹ️ Support\
**Tags:** file\_permission, data\_directory\
**Created:** [May 11, 2022, 8:22pm UTC](https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928 "2022-05-11T20:22:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreaconfa](https://help.nextcloud.com/letter_avatar/andreaconfa/32/5_5575768a8748004e209b776fc1b2916d.png) [@andreaconfa](https://help.nextcloud.com/u/andreaconfa)\
**Post date:** [May 11, 2022, 8:22pm UTC](https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928/1 "2022-05-11T20:22:55Z")

</div>

Hi all,  
i’m new to nextcloud and i’m not able to resolve this problem.  
I installed nextcloud on a new vm running ubuntu server using the standard installation script.  
After that i moved the data folder using the solution1 as explained in this topic: [HowTo: Change / Move data directory after installation](https://help.nextcloud.com/t/howto-change-move-data-directory-after-installation/17170)

Now i’m able to access the files in the new directory but i can’t delete or add new files.

the new data path is in /mnt/nextcloud and it is a samba share auto mounted at the server startp with cifs utils.

Also the command  
**sudo -u www-data php -f /var/www/html/nextcloud/console.php files:scan --all**  
report:

```auto
Permissions can usually be fixed by giving the web server write access to the root directory. See https://docs.nextcloud.com/server/24/go.php?to=admin-dir_permissions.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:164

```

Errors in the nc log:

```auto
|Errore|PHP|Error: fopen(/mnt/nextcloud/data_dir_writability_test_627c1d214e4f6.tmp): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/legacy/OC_Util.php#580||2022-05-11T22:31:29+0200|
|Errore|PHP|Error: fopen(/mnt/nextcloud/data_dir_writability_test_627c1cc9aa4dc.tmp): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/legacy/OC_Util.php#580||2022-05-11T22:30:01+0200|
|Avviso|appstoreFetcher|OCP\Files\GenericFileException: file_put_contents failed||2022-05-11T22:29:22+0200|
|Errore|PHP|Error: file_put_contents(/mnt/nextcloud/appdata_ocijspse9cqd/appstore/apps.json): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#296||2022-05-11T22:29:22+0200|
|Avviso|appstoreFetcher|OCP\Files\GenericFileException: file_put_contents failed||2022-05-11T22:29:21+0200|
|Errore|PHP|Error: file_put_contents(/mnt/nextcloud/appdata_ocijspse9cqd/appstore/apps.json): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#296||2022-05-11T22:29:21+0200|
|Avviso|appstoreFetcher|OCP\Files\GenericFileException: file_put_contents failed||2022-05-11T22:29:21+0200|
|Errore|PHP|Error: file_put_contents(/mnt/nextcloud/appdata_ocijspse9cqd/appstore/apps.json): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#296||2022-05-11T22:29:21+0200|
|Avviso|appstoreFetcher|OCP\Files\GenericFileException: file_put_contents failed||2022-05-11T22:29:20+0200|
|Errore|PHP|Error: file_put_contents(/mnt/nextcloud/appdata_ocijspse9cqd/appstore/apps.json): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#296||2022-05-11T22:29:20+0200|
|Errore|PHP|Error: file_put_contents(/mnt/nextcloud/appdata_ocijspse9cqd/css/icons/icons-vars.css): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#296||2022-05-11T22:27:29+0200|

```

thanks

---

<div class="post-metadata">

**Author:** ![anon75456558](https://help.nextcloud.com/letter_avatar/anon75456558/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon75456558](https://help.nextcloud.com/u/anon75456558)\
**Post date:** [May 11, 2022, 9:08pm UTC](https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928/2 "2022-05-11T21:08:52Z")

</div>

> [@andreaconfa](#):
>
> `Permissions can usually be fixed by giving the web server write access to the root directory. See https://docs.nextcloud.com/server/24/go.php?to=admin-dir_permissions.`

Did you try visiting this link it pointed you to?

[https://docs.nextcloud.com/server/24/go.php?to=admin-dir\_permissions](https://docs.nextcloud.com/server/24/go.php?to=admin-dir_permissions)

You can also verify your permissions and ownership of the directories with `ls -la`  
And change those permissions with chown and such

---

<div class="post-metadata">

**Author:** ![andreaconfa](https://help.nextcloud.com/letter_avatar/andreaconfa/32/5_5575768a8748004e209b776fc1b2916d.png) [@andreaconfa](https://help.nextcloud.com/u/andreaconfa)\
**Post date:** [May 12, 2022, 10:41am UTC](https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928/3 "2022-05-12T10:41:02Z")

</div>

The link unfortunatly is not giving any useful information.

LS -LA Results:

/mnt/nextcloud (my new data folder):

```auto

 0 drwxr-xr-x 2 root root 0 May 11 21:13 appdata_ocijspse9cqd
 0 drwxr-xr-x 2 root root 0 May 11 21:00 files_external
14 -rwxr-xr-x 1 root root 0 May 11 20:58 index.html
 0 drwxr-xr-x 2 root root 0 May 11 21:13 nextcloud

```

/var/www/nextcloud

```auto
 4 drwxrwxrwx 43 www-data www-data 4096 May 2 16:34 3rdparty
 4 drwxrwxrwx 53 www-data www-data 4096 May 11 21:01 apps
20 -rwxrwxrwx 1 www-data www-data 19327 May 2 16:31 AUTHORS
 4 drwxrwxrwx 2 www-data www-data 4096 May 11 22:06 config
 4 -rwxrwxrwx 1 www-data www-data 3924 May 2 16:31 console.php
36 -rwxrwxrwx 1 www-data www-data 34520 May 2 16:31 COPYING
 4 drwxrwxrwx 22 www-data www-data 4096 May 2 16:34 core
 8 -rwxrwxrwx 1 www-data www-data 6260 May 2 16:31 cron.php
 4 drwxrwxrwx 2 www-data www-data 4096 May 11 20:58 data
12 drwxrwxrwx 2 www-data www-data 12288 May 2 16:31 dist
 4 -rwxrwxrwx 1 www-data www-data 156 May 2 16:31 index.html
 4 -rwxrwxrwx 1 www-data www-data 3456 May 2 16:31 index.php
 4 drwxrwxrwx 6 www-data www-data 4096 May 2 16:31 lib
 4 -rwxrwxrwx 1 www-data www-data 283 May 2 16:31 occ
 4 drwxrwxrwx 2 www-data www-data 4096 May 2 16:31 ocm-provider
 4 drwxrwxrwx 2 www-data www-data 4096 May 2 16:31 ocs
 4 drwxrwxrwx 2 www-data www-data 4096 May 2 16:31 ocs-provider
 4 -rwxrwxrwx 1 www-data www-data 3139 May 2 16:31 public.php
 8 -rwxrwxrwx 1 www-data www-data 5340 May 2 16:31 remote.php
 4 drwxrwxrwx 4 www-data www-data 4096 May 2 16:31 resources
 4 -rwxrwxrwx 1 www-data www-data 26 May 2 16:31 robots.txt
 4 -rwxrwxrwx 1 www-data www-data 2452 May 2 16:31 status.php
 4 drwxrwxrwx 3 www-data www-data 4096 May 2 16:31 themes
 4 drwxrwxrwx 2 www-data www-data 4096 May 2 16:32 updater
 4 -rwxrwxrwx 1 www-data www-data 383 May 2 16:34 version.php

```

---

<div class="post-metadata">

**Author:** ![anon75456558](https://help.nextcloud.com/letter_avatar/anon75456558/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon75456558](https://help.nextcloud.com/u/anon75456558)\
**Post date:** [May 12, 2022, 3:11pm UTC](https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928/4 "2022-05-12T15:11:02Z")

</div>

> [@andreaconfa](#):
>
> ```auto
> 0 drwxr-xr-x 2 root root 0 May 11 21:13 appdata_ocijspse9cqd
> 0 drwxr-xr-x 2 root root 0 May 11 21:00 files_external
> 14 -rwxr-xr-x 1 root root 0 May 11 20:58 index.html
> 0 drwxr-xr-x 2 root root 0 May 11 21:13 nextcloud
> 
> ```

Actually it is useful. Nextcloud normally is `www-data` and not root as far as I know for user or group permissions. 🤷

Your new data folder needs to be www-data as opposed to root

---

<div class="post-metadata">

**Author:** ![Eggi](https://help.nextcloud.com/user_avatar/help.nextcloud.com/eggi/32/54257_2.png) [@Eggi](https://help.nextcloud.com/u/Eggi)\
**Post date:** [September 4, 2023, 8:38am UTC](https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928/5 "2023-09-04T08:38:01Z")

</div>

Was the problem resolved? Wenn yes, how?

---

<div class="post-metadata">

**Author:** ![SchVinzenz](https://help.nextcloud.com/user_avatar/help.nextcloud.com/schvinzenz/32/53156_2.png) [@SchVinzenz](https://help.nextcloud.com/u/SchVinzenz)\
**Post date:** [September 4, 2023, 10:17am UTC](https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928/6 "2023-09-04T10:17:00Z")

</div>

For the data directory try to do

> sudo chmod 770 /mnt/nextcloud

If that doesn’t work, try also

> chown -R www-data:www-data /mnt/nextcloud

_(Change /mnt/nextcloud to your path)_

---

<div class="post-metadata">

**Author:** ![bb77](https://help.nextcloud.com/letter_avatar/bb77/32/5_5575768a8748004e209b776fc1b2916d.png) [@bb77](https://help.nextcloud.com/u/bb77)\
**Post date:** [September 4, 2023, 10:18am UTC](https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928/7 "2023-09-04T10:18:34Z")

</div>

This topic has come up a zillion times here in the forum and was even answered in this thread.

The Nextcloud folder and data folder should be owned by the web server user. On Debian/Ubuntu based distributions this is usually the user www-data. Further it is recommended to set the permissions for folders to 750 and for files to 640.

```auto
chown -R www-data:www-data /path/to/nextcloud
find /path/to/nextcloud/ -type d -exec chmod 750 {} \;
find /path/to/nextcloud/ -type f -exec chmod 640 {} \;

```

---

<div class="post-metadata">

**Author:** ![Eggi](https://help.nextcloud.com/user_avatar/help.nextcloud.com/eggi/32/54257_2.png) [@Eggi](https://help.nextcloud.com/u/Eggi)\
**Post date:** [September 4, 2023, 10:29am UTC](https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928/8 "2023-09-04T10:29:32Z")

</div>

Thanks for information  
I have the same problem - but on a Proxmox-container.  
Is the soluten the same for Proxmox?  
I think, it’s different to use the accounts - in Proxmox uid ?

---

<div class="post-metadata">

**Author:** ![bb77](https://help.nextcloud.com/letter_avatar/bb77/32/5_5575768a8748004e209b776fc1b2916d.png) [@bb77](https://help.nextcloud.com/u/bb77)\
**Post date:** [September 4, 2023, 10:54am UTC](https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928/9 "2023-09-04T10:54:51Z")

</div>

> [@Eggi](#):
>
> Is the soluten the same for Proxmox?

I don’t use LXC myself but I’d say yes.

> [@Eggi](#):
>
> I think, it’s different to use the accounts - in Proxmox uid ?

I don’t think so, because Nextcloud and the web server ar not aware they are running in a container, so the Nextcloud folders and files, including the data folder and its contents, need to be owned by www-data, regardless from where and how the storage is mounted.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 14, 2024, 2:32pm UTC](https://help.nextcloud.com/t/permission-problem-after-moving-data-folder/138928/10 "2024-12-14T14:32:35Z")

</div>


