Adding files to Nextcloud using the command line

  • I am tring to add local files to Nextcloud, but getting an error. sudo: unable to execute ./occ: Permission denied



    My data directory on the server is :


    /sharedfolders/NextCloud/admin/files


    occ is in


    /sharedfolders/Appdata/nextcloud/www/nextcloud


    Running the below command


    root@openmediavault:/sharedfolders/Appdata/nextcloud/www/nextcloud# sudo -u www-data ./occ files:scan --path="/admin/files"sudo: unable to execute ./occ: Permission denied
    root@openmediavault:/sharedfolders/Appdata/nextcloud/www/nextcloud# ls -la
    total 160
    drwxrwsr-x 14 911 911 4096 Mar 30 21:32 .
    drwxrwsr-x 3 911 911 4096 Mar 28 23:57 ..
    drwxrwxr-x 32 911 911 4096 Jan 11 18:29 3rdparty
    drwxrwxr-x 62 911 911 4096 Mar 29 21:53 apps
    -rw-rw-r-- 1 911 911 12063 Jan 11 18:25 AUTHORS
    drwxrwxr-x 2 911 911 4096 Mar 29 09:05 config
    -rw-rw-r-- 1 911 911 3650 Jan 11 18:25 console.php
    -rw-rw-r-- 1 911 911 34520 Jan 11 18:25 COPYING
    drwxrwxr-x 18 911 911 4096 Jan 11 18:29 core
    -rw-rw-r-- 1 911 911 4979 Jan 11 18:25 cron.php
    -rw-rw-r-- 1 911 911 2928 Mar 28 23:59 .htaccess
    -rw-rw-r-- 1 911 911 156 Jan 11 18:25 index.html
    -rw-rw-r-- 1 911 911 3172 Jan 11 18:25 index.php
    drwxrwxr-x 6 911 911 4096 Jan 11 18:25 lib
    -rwxrwxr-x 1 911 911 283 Jan 11 18:25 occ
    drwxrwxr-x 2 911 911 4096 Jan 11 18:25 ocm-provider
    drwxrwxr-x 2 911 911 4096 Mar 29 08:05 ocs
    drwxrwxr-x 2 911 911 4096 Jan 11 18:25 ocs-provider
    -rw-rw-r-- 1 911 911 2951 Jan 11 18:25 public.php
    -rw-rw-r-- 1 911 911 5139 Jan 11 18:25 remote.php
    drwxrwxr-x 4 911 911 4096 Jan 11 18:25 resources
    -rw-rw-r-- 1 911 911 26 Jan 11 18:25 robots.txt
    drwxrwxr-x 12 911 911 4096 Jan 11 18:26 settings
    -rw-rw-r-- 1 911 911 2232 Jan 11 18:25 status.php
    drwxrwxr-x 3 911 911 4096 Jan 11 18:25 themes
    drwxrwxr-x 2 911 911 4096 Jan 11 18:25 updater
    -rw-rw-r-- 1 911 911 163 Jan 11 18:25 .user.ini
    -rw-rw-r-- 1 911 911 362 Jan 11 18:28 version.php
    root@openmediavault:/sharedfolders/Appdata/nextcloud/www/nextcloud#
    root@openmediavault:/sharedfolders/NextCloud/admin/files# ls -la
    total 711644
    drwxr-xr-x 3 911 www-data 4096 Mar 30 20:49 .
    drwxr-xr-x 4 911 911 4096 Mar 29 09:48 ..
    -rwxrwxrwx 1 www-data www-data 3432040 Mar 26 17:53 11111111111111111111.rar
    -rwxrwxrwx 1 www-data www-data 5249470 Mar 26 17:54 ARC FLASH ANALYTIC V4.1.rar
    drwxr-xr-x 3 911 911 4096 Mar 29 09:48 Downloads
    -rw-r--r-- 1 www-data www-data 568890 Mar 29 10:01 Enerji-Kablolari-Fiyat-Listesi-21-05-2018_0.xlsx
    -rwxrwxrwx 1 www-data www-data 719454208 Jan 17 2015 winxp.iso

  • Gives below error


    PHP Warning: require_once(/sharedfolders/Appdata/nextcloud/www/nextcloud/console.php): failed to open stream: Permission denied in /sharedfolders/Appdata/nextcloud/www/nextcloud/occ on line 11
    PHP Fatal error: require_once(): Failed opening required '/sharedfolders/Appdata/nextcloud/www/nextcloud/console.php' (include_path='.:/usr/share/php') in /sharedfolders/Appdata/nextcloud/www/nextcloud/occ on
    line 11

  • Next cloud folder permission :


    root@openmediavault:/sharedfolders/Appdata/nextcloud/www/nextcloud# ls -la
    total 160
    drwxrwsr-x 14 911 911 4096 Mar 30 21:32 .
    drwxrwsr-x 3 911 911 4096 Mar 28 23:57 ..
    drwxrwxr-x 32 911 911 4096 Jan 11 18:29 3rdparty
    drwxrwxr-x 62 911 911 4096 Mar 29 21:53 apps
    -rw-rw-r-- 1 911 911 12063 Jan 11 18:25 AUTHORS
    drwxrwxr-x 2 911 911 4096 Mar 29 09:05 config
    -rw-rw-r-- 1 911 911 3650 Jan 11 18:25 console.php
    -rw-rw-r-- 1 911 911 34520 Jan 11 18:25 COPYING
    drwxrwxr-x 18 911 911 4096 Jan 11 18:29 core
    -rw-rw-r-- 1 911 911 4979 Jan 11 18:25 cron.php
    -rw-rw-r-- 1 911 911 2928 Mar 28 23:59 .htaccess
    -rw-rw-r-- 1 911 911 156 Jan 11 18:25 index.html
    -rw-rw-r-- 1 911 911 3172 Jan 11 18:25 index.php
    drwxrwxr-x 6 911 911 4096 Jan 11 18:25 lib
    -rwxrwxr-x 1 911 911 283 Jan 11 18:25 occ
    drwxrwxr-x 2 911 911 4096 Jan 11 18:25 ocm-provider
    drwxrwxr-x 2 911 911 4096 Mar 29 08:05 ocs
    drwxrwxr-x 2 911 911 4096 Jan 11 18:25 ocs-provider
    -rw-rw-r-- 1 911 911 2951 Jan 11 18:25 public.php
    -rw-rw-r-- 1 911 911 5139 Jan 11 18:25 remote.php
    drwxrwxr-x 4 911 911 4096 Jan 11 18:25 resources
    -rw-rw-r-- 1 911 911 26 Jan 11 18:25 robots.txt
    drwxrwxr-x 12 911 911 4096 Jan 11 18:26 settings
    -rw-rw-r-- 1 911 911 2232 Jan 11 18:25 status.php
    drwxrwxr-x 3 911 911 4096 Jan 11 18:25 themes
    drwxrwxr-x 2 911 911 4096 Jan 11 18:25 updater
    -rw-rw-r-- 1 911 911 163 Jan 11 18:25 .user.ini
    -rw-rw-r-- 1 911 911 362 Jan 11 18:28 version.php
    root@openmediavault:/sharedfolders/Appdata/nextcloud/www/nextcloud#




    Data folder permission



    root@openmediavault:/sharedfolders/NextCloud/admin/files# ls -la
    total 711644
    drwxr-xr-x 3 911 911 4096 Mar 30 20:49 .
    drwxr-xr-x 4 911 911 4096 Mar 29 09:48 ..
    -rwxrwxrwx 1 911 911 3432040 Mar 26 17:53 11111111111111111111.rar
    -rwxrwxrwx 1 911 911 5249470 Mar 26 17:54 ARC FLASH ANALYTIC V4.1.rar
    drwxr-xr-x 3 911 911 4096 Mar 29 09:48 Downloads
    -rw-r--r-- 1 911 911 568890 Mar 29 10:01 Enerji-Kablolari-Fiyat-Listesi-21-05-2018_0.xlsx
    -rwxrwxrwx 1 911 911 719454208 Jan 17 2015 winxp.iso
    root@openmediavault:/sharedfolders/NextCloud/admin/files#



    all folders 911 group and 911 user permission. Do I missing someting?

  • Tried this on my VM Testserver - getting an error message on the login screen:

  • Actually, maybe yes. I installed the Nextcloud-Docker according to TechoDadLife'sTutorial (as most of the ppl here, probably).



    Today is the first part of a series on installing Nextcloud on Openmediavault using dockers. After this video, Nextcloud will be configured to run on your local network.


    What I realised now, after watching it for the probably 10th time, that he does not enter the PGID and PUID when setting up the Nextcloud-Docker. The owner 911 seems to be the default user if these parameters are not specified.


    @TechnoDadLife was this on purpose? If not, which user should be specified? The Nextcloud Manual states that it should be the the www-data - user. Or can we use the standart Docker user?

  • Hi,
    Im running nextcloud in docker as well. When I want to excute an 'occ' command for some reason, I do it from 'within' the docker container:


    Code
    docker exec -it nextcloud bash

    where 'nextcloud' is the name of the container. when Im doing a 'ls -l' it looks like this:

    as you can see, the owner of the 'data' folder is 'abc' in my case. I can execute an 'occ' command then like:

    Code
    sudo -u abc /config/www/nextcloud/occ status

    the result would be:


    Code
    - installed: true
    - version: 15.0.5.3
    - versionstring: 15.0.5
    - edition:


    hope that helps.


    p.parker

  • You have to create a shared folder and share it via smb. In Nextcloud you to App -> deactivated Apps and there activate the External storage support-App.
    Then go to settings. Under administrative settings you can allow users to mount external storage. Then with your regular user account you go to settings -> External storage.
    Choose a displayed folder name and SMB / CIFS. Authentification Username and Password. Host is the IP-Adress of your OMV-Machine. Share is the name of the shared folder. Subfolder and Domain can be left blank. Lastly enter a Username and PW of an OMV-User who has R/W Privileges to the shared folder.
    Thats how it worked in my case. If you want to share files from this folders with others you also want to check sharing allowd behind the ...-menu.

  • Works! Thank you!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!