How do I access the occ command interface?

Sorry for the really noob question guys but how do I access tge occ interface?
I know that occ is a php script on my directory and I can see it but how do I run it?
The wording HTTP user confuses me in the guide.

Will appreciate any help I can get. I have been searching for this for quite some time.

Thanks

Hi,

the script has to run as the same user as the webserver runs. Check it with ps aux

root@nextcloudhost ~ # ps aux | grep apache
www-data 1933 0.0 0.8 406268 65548 ? S Feb04 1:40 apache2 -DFOREGROUND

First column is the user running the apache process. So you can call occ via:

sudo -u www-data php occ

More examples here: https://docs.nextcloud.com/server/13/admin_manual/configuration_server/occ_command.html

Cheers,
Andreas

1 Like

Thanks guddl

The thing is I am on shared hosting.
So my understanding now is that I have to run occ through SSH. Is that correct?

If you have no access to the shell, this is not possible.

1 Like

So I managed to get shell access but when I navigate to my nextcloud directory and type sudo -u www-data php occ I get “sudo: effective uid is not 0, is sudo installed setuid root?”

What am I doing wrong?

I think the issue might be that I am on shared hosting and therefore I dont have root access and so cannot use sudo command.

Is there a way to run occ without sudo?

occ has to be run as the same user as your webserver, sudo is just a method for running a command as a different user. sudo does not need to be run as root, but it needs the setUID bit set, so it runs as root when executed by any user. You will probably need to ask your hosting provider.