Command 'occ' not found, but there are 21 similar ones

When running the OCC command on the www root folder where Nextcloud is installed this happens:


So the command doesn’t work and I have no idea why that happens.

Nextcloud version: 28.0.4
Operating system: Ubuntu server 22.04.4 LTS
Apache or nginx version (eg, Apache 2.4.25): Latest versions.
PHP version: Version 8.2.17
Is this the first time you’ve seen this error? Yes.

Thoughts? :thinking:

Kind regards

Typically *nix shells do not place the current working directory in your command search path by default (this is for security reasons).

Try ./occ. Or specifying the entire path /var/www/vhosts/xxx/public_html/occ.

1 Like

That seems not to be correct.
In many installations occ is not an executable anymore.

Because the permissions for execution are very important, the sudo command is needed, specially on Ubuntu-Systems.

sudo -u www-data php /path/to/occ command


1 Like

Thanks guys @jtr @Mornsgrans for sharing the information.
We however use the Plesk CP for partition up our servers into different business functions so I’m not sure yet what to replace the
-u www-data php
with as Plesk uses some of its own webserver users and also both run ngix and Apache on the same time.

That is always the Nextcloud directory correct?

Also is there some command in Ubuntu server which is needed to turn on OCC support?

Thanks in advance
Kind regards

I think you must run it with php command. Try this command

php occ db:add-missing-indices

Or if it’s still fail try

sudo -u www-data php occ db:add-missing-indices

You need to enter the full pass to your OCC binary.if your prompt is already in the right location, it will work without specifying the full path.

Hmm well that makes it even more odd then…

I mean if you look on my screenshot of the Linux prompt window you see that I’m already cd’ed into the correct directly where Nextcloud is installed e.g. “public_html” so then according to your quote:

It then makes absolutely no sense that it should not work, right?

As mentioned its a Linux server enabled by Plesk so we can partition it tino different business functions / Business apps so it is partly mananged by the Plesk software. But that should not - at least not in theory - impact the server functions and commands like OCC for Nextcloud. :thinking:

I don’t use Plesk, so I couldn’t test it, but maybe this and this is of any help.


You did not read the mentioned docs, or?

You cannot call OCC directly.

1 Like

well it’s not as important to get to know where your NC is installed but you should know the /path/to/your/php and use it

so an example could be
sudo -u www-data (or whatever your webuser is) /path/to/your/php occ your_command

Maybe you find the user:

ls -l /path/to/occ

There are two important points:
occ is not executable. So you have to prepend the comand php.
You have to execute the command as web server user. If you run apache as webserver, the correct user is www-data.
Additionaly: You have to supply the full path or you have to navigate to the nextcloud root directory before. In your screenshot you are in the root directory, so occ without path should work. The full command:

sudo -u www-data php occ db:add-missing-indices
sudo -u www-data php /var/www/vhosts/…/public_html/occ db:add-missing-indices

1 Like

Thank you Franz, that is very intertesting information. :+1: