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

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?

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:

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?

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

That works perfectly fine!

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

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

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

Did you tried chmod +x occ
This should work :wink:

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

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)

1 Like

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

Also enabling samba seems to work now!

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

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…

Don´t know, thats weird, but always.

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.

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

@Tim1, @jonaskor

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)?

ok, this confirms my suspicions

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

fixed in v0.41.9

1 Like

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