# \[NextcloudPi\] Error: sudo: /var/www/nextcloud/occ: command not found

**URL:** <https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462>\
**Category:** 📦 Appliances (Docker, Snappy, VM, NCP, AIO)\
**Tags:** ncp\
**Created:** [December 7, 2017, 3:18pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462 "2017-12-07T15:18:18Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonaskor](https://help.nextcloud.com/letter_avatar/jonaskor/32/6_22734026db12803ebb3e059622ac3534.png) [@jonaskor](https://help.nextcloud.com/u/jonaskor)\
**Post date:** [December 7, 2017, 3:18pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/1 "2017-12-07T15:18:19Z")

</div>

Hello everybody,  
when I try to activate samba-share in the NextcloudPiPanel I’m getting the following error:

```
udo: /var/www/nextcloud/occ: command not found
Error reading data directory. Is NextCloud running and configured?

```

 ![samba](https://help.nextcloud.com/uploads/default/original/2X/7/7952b7fe85312087b72d6dbe7134ea08c3918222.JPG)

Apparently the NCP is unable to get the right data-directory (I moved it to a USB stick using nc-datadir), where its working without a problem.

```
pi@nextcloudpi:/ $ sudo du -shc /media/*
7.0G /media/myCloudUSB
0 /media/USBdrive
7.0G total

```

The error message is the same if I use the following command that I found [here](https://github.com/nextcloud/nextcloudpi/blob/master/etc/nextcloudpi-config.d/samba.sh):

```
pi@nextcloudpi:/ $ sudo -u www-data /var/www/nextcloud/occ config:system:get datadirectory
sudo: /var/www/nextcloud/occ: command not found

```

The same error appears if I activate fail2ban, but here NCP still manages to activate fail2ban:

```
udo: /var/www/nextcloud/occ: command not found
System config value loglevel set to string 2
System config value log_type set to string file
fail2ban enabled

```

Anybody knows why I’m getting this error? Is there an easy fix for it?

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/6_22734026db12803ebb3e059622ac3534.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [December 7, 2017, 10:58pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/2 "2017-12-07T22:58:46Z")

</div>

> [@jonaskor](#):
>
> sudo -u www-data /var/www/nextcloud/occ config:system:get datadirectory  
> sudo: /var/www/nextcloud/occ: command not found

occ is probably not executable. But you can try to use php:

`sudo -u www-data php /var/www/nextcloud/occ config:system:get datadirectory`

---

<div class="post-metadata">

**Author:** ![jonaskor](https://help.nextcloud.com/letter_avatar/jonaskor/32/6_22734026db12803ebb3e059622ac3534.png) [@jonaskor](https://help.nextcloud.com/u/jonaskor)\
**Post date:** [December 8, 2017, 12:28pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/3 "2017-12-08T12:28:55Z")

</div>

That works perfectly fine!

```
pi@nextcloudpi:~ $ sudo -u www-data php /var/www/nextcloud/occ config:system:get datadirectory
/media/myCloudUSB/ncdata

```

The question is, if its possible to change this also within the samba-configuration-file?  
Unfortunately I’m a total noob in Linux…

---

<div class="post-metadata">

**Author:** ![nachoparker](https://help.nextcloud.com/user_avatar/help.nextcloud.com/nachoparker/32/2975_2.png) [@nachoparker](https://help.nextcloud.com/u/nachoparker)\
**Post date:** [December 12, 2017, 11:22am UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/4 "2017-12-12T11:22:57Z")

</div>

can you verify that `/var/www/nextcloud/occ` has no rights to execute? I am curious about how this could be the case

---

<div class="post-metadata">

**Author:** ![Tim1](https://help.nextcloud.com/letter_avatar/tim1/32/6_22734026db12803ebb3e059622ac3534.png) [@Tim1](https://help.nextcloud.com/u/Tim1)\
**Post date:** [December 12, 2017, 1:12pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/5 "2017-12-12T13:12:39Z")

</div>

Did you tried `chmod +x occ`  
This should work 😉

---

<div class="post-metadata">

**Author:** ![jonaskor](https://help.nextcloud.com/letter_avatar/jonaskor/32/6_22734026db12803ebb3e059622ac3534.png) [@jonaskor](https://help.nextcloud.com/u/jonaskor)\
**Post date:** [December 12, 2017, 2:23pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/6 "2017-12-12T14:23:36Z")

</div>

If I put in just put in `/var/www/nextcloud/occ` I see:

```
pi@nextcloudpi:~ $ /var/www/nextcloud/occ
 -bash: /var/www/nextcloud/occ: Permission denied
pi@nextcloudpi:~ $ sudo /var/www/nextcloud/occ
sudo: /var/www/nextcloud/occ: command not found

```

`chmod +x occ` results in:

```
pi@nextcloudpi:~ $ chmod +x occ
chmod: cannot access 'occ': No such file or directory
pi@nextcloudpi:~ $ chmod +x /var/www/nextcloud/occ
chmod: cannot access '/var/www/nextcloud/occ': Permission denied
```

---

<div class="post-metadata">

**Author:** ![Tim1](https://help.nextcloud.com/letter_avatar/tim1/32/6_22734026db12803ebb3e059622ac3534.png) [@Tim1](https://help.nextcloud.com/u/Tim1)\
**Post date:** [December 12, 2017, 4:57pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/7 "2017-12-12T16:57:06Z")

</div>

So put a sudo at first position. In Linux you always need sudo if you want to chown or chmod.  
Explanation for you, cause you said, you are new to linux: chmod: Change Mode. So you give a file, Folder, whatever permissions. If you do a +x you make the file executable. That worked for me. So, do `sudo chmod +x occ` if it still don´t work, give us please the output from `ls -al` (in /var/www/nextcloud)

---

<div class="post-metadata">

**Author:** ![jonaskor](https://help.nextcloud.com/letter_avatar/jonaskor/32/6_22734026db12803ebb3e059622ac3534.png) [@jonaskor](https://help.nextcloud.com/u/jonaskor)\
**Post date:** [December 12, 2017, 6:50pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/8 "2017-12-12T18:50:18Z")

</div>

That seems to work! Thank you for the explanation!

```
pi@nextcloudpi:~ $ sudo chmod +x /var/www/nextcloud/occ
pi@nextcloudpi:~ $ /var/www/nextcloud/occ
-bash: /var/www/nextcloud/occ: Permission denied
pi@nextcloudpi:~ $ sudo /var/www/nextcloud/occ
Console has to be executed with the user that owns the file config/config.php
Current user: root
Owner of config.php: www-data
Try adding 'sudo -u www-data ' to the beginning of the command (without the single quotes)
pi@nextcloudpi:~ $ sudo -u www-data /var/www/nextcloud/occ config:system:get datadirectory
/media/myCloudUSB/ncdata

```

Also enabling samba seems to work now!

 ![samba2](https://help.nextcloud.com/uploads/default/original/2X/d/dc1ff73f83647bc1aacccb6e3bb69c139f62740d.JPG)

---

<div class="post-metadata">

**Author:** ![nachoparker](https://help.nextcloud.com/user_avatar/help.nextcloud.com/nachoparker/32/2975_2.png) [@nachoparker](https://help.nextcloud.com/u/nachoparker)\
**Post date:** [December 13, 2017, 6:45am UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/9 "2017-12-13T06:45:02Z")

</div>

what I am puzzled about is how did the permissions for `occ` changed

---

<div class="post-metadata">

**Author:** ![jonaskor](https://help.nextcloud.com/letter_avatar/jonaskor/32/6_22734026db12803ebb3e059622ac3534.png) [@jonaskor](https://help.nextcloud.com/u/jonaskor)\
**Post date:** [December 13, 2017, 10:10am UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/10 "2017-12-13T10:10:34Z")

</div>

I don’t know… After first experiencing this error I used `nc-backup`, flashed `NextCloudPi_11-12-17.img` on the SD-card (the newer version didn’t allow me to connect to NextcloudpiPanel through `SSH`), used `nc-update` and `nc-restore` but still had the same error…

---

<div class="post-metadata">

**Author:** ![Tim1](https://help.nextcloud.com/letter_avatar/tim1/32/6_22734026db12803ebb3e059622ac3534.png) [@Tim1](https://help.nextcloud.com/u/Tim1)\
**Post date:** [December 13, 2017, 12:50pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/11 "2017-12-13T12:50:40Z")

</div>

Don´t know, thats weird, but always.

---

<div class="post-metadata">

**Author:** ![Jeffery\_Frederick](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jeffery_frederick/32/4409_2.png) [@Jeffery\_Frederick](https://help.nextcloud.com/u/Jeffery_Frederick)\
**Post date:** [December 14, 2017, 3:31am UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/12 "2017-12-14T03:31:53Z")

</div>

@nacho,  
I am having the same issue. Have not worried about it as I am planning on updating my Board shortly. I will try to change permissions on occ tomorrow.

My only theory is that a update to NCP or an apt-get update/apt-get upgrade changed something. Those are the only two tasks I perform on my NCP box.

---

<div class="post-metadata">

**Author:** ![nachoparker](https://help.nextcloud.com/user_avatar/help.nextcloud.com/nachoparker/32/2975_2.png) [@nachoparker](https://help.nextcloud.com/u/nachoparker)\
**Post date:** [December 14, 2017, 9:17am UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/13 "2017-12-14T09:17:51Z")

</div>

maybe you guys updated to 12.0.4? could it be that?

@Tim1, @jonaskor

---

<div class="post-metadata">

**Author:** ![jonaskor](https://help.nextcloud.com/letter_avatar/jonaskor/32/6_22734026db12803ebb3e059622ac3534.png) [@jonaskor](https://help.nextcloud.com/u/jonaskor)\
**Post date:** [December 14, 2017, 9:57am UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/14 "2017-12-14T09:57:07Z")

</div>

In fact, I upgraded to 12.0.4 through the Nextcloud-settings manually prior to `ncp-backup` (when I was scrolling through all the settings to get to know Nextcloud). I this not recommended? I was unaware of this and didn’t think that this was also being backed-up and restored…  
Thanks for the info! Maybe there should be a warning somewhere… Maybe some info/warnings could be integrated in the wizard (for beginners like me)?

---

<div class="post-metadata">

**Author:** ![nachoparker](https://help.nextcloud.com/user_avatar/help.nextcloud.com/nachoparker/32/2975_2.png) [@nachoparker](https://help.nextcloud.com/u/nachoparker)\
**Post date:** [December 14, 2017, 11:31am UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/15 "2017-12-14T11:31:40Z")

</div>

ok, this confirms my suspicions

it is recommended, but now we have to fix the fact that the update modifies permissions

---

<div class="post-metadata">

**Author:** ![nachoparker](https://help.nextcloud.com/user_avatar/help.nextcloud.com/nachoparker/32/2975_2.png) [@nachoparker](https://help.nextcloud.com/u/nachoparker)\
**Post date:** [December 14, 2017, 12:16pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/16 "2017-12-14T12:16:26Z")

</div>

fixed in v0.41.9

---

<div class="post-metadata">

**Author:** ![fromage9747](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fromage9747/32/31293_2.png) [@fromage9747](https://help.nextcloud.com/u/fromage9747)\
**Post date:** [March 8, 2021, 8:23am UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/17 "2021-03-08T08:23:44Z")

</div>

doing “sudo -u www-data ./occ db:add-missing-indices” worked for me!

---

<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 2, 2024, 3:29pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/18 "2024-12-02T15:29:41Z")

</div>



---

<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 9, 2024, 1:40pm UTC](https://help.nextcloud.com/t/nextcloudpi-error-sudo-var-www-nextcloud-occ-command-not-found/24462/19 "2024-12-09T13:40:59Z")

</div>


