Adding files to Nextcloud using the command line

    • 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:

      Source Code

      1. Der Server konnte die Anfrage nicht fertig stellen.
      2. Sollte dies erneut auftreten, sende bitte die nachfolgenden technischen Einzelheiten an Deinen Server-Administrator.
      3. Weitere Details können im Server-Protokoll gefunden werden.
      4. Technische Details
      5. Entfernte Adresse: 192.168.178.102
      6. Anfragekennung: dgNLWkmxSTytdzZTJWHj
    • Actually, maybe yes. I installed the Nextcloud-Docker according to TechoDadLife'sTutorial (as most of the ppl here, probably).

      TechnoDadLife wrote:




      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?

      The post was edited 1 time, last by Morlan ().

    • 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:

      Source Code

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

      Source Code

      1. total 4
      2. drwxr-xr-x 1 abc abc 0 Feb 9 00:17 app
      3. drwxr-xr-x 1 root root 6 Feb 9 00:51 bin
      4. drwxr-sr-x 1 abc abc 48 Jan 5 14:15 config
      5. drwxrwx--- 1 abc abc 268 Mar 20 11:01 data
      6. drwxr-xr-x 1 abc abc 0 Jan 25 20:08 defaults
      7. drwxr-xr-x 5 root root 320 Mar 31 13:18 dev
      8. drwxr-xr-x 1 root root 136 Mar 31 13:18 etc
      9. drwxr-xr-x 1 root root 0 Feb 9 00:16 home
      10. -rwxr-xr-x 1 root root 389 Sep 9 2018 init
      11. drwxr-xr-x 1 root root 190 Feb 9 00:52 lib
      12. drwxr-xr-x 1 root root 104 Sep 9 2018 libexec
      13. drwxr-xr-x 1 root root 28 Feb 9 00:16 media
      14. drwxr-xr-x 1 root root 0 Feb 9 00:16 mnt
      15. dr-xr-xr-x 257 root root 0 Mar 31 13:18 proc
      16. drwx------ 1 root root 26 Apr 1 13:29 root
      17. drwxr-xr-x 1 root root 64 Mar 31 13:18 run
      18. drwxr-xr-x 1 root root 152 Feb 9 00:17 sbin
      19. drwxr-xr-x 1 root root 0 Feb 9 00:16 srv
      20. dr-xr-xr-x 12 root root 0 Apr 1 13:09 sys
      21. drwxrwxrwt 1 root root 2790 Apr 2 14:45 tmp
      22. drwxr-xr-x 1 root root 68 Feb 9 00:52 usr
      23. drwxr-xr-x 1 root root 18 Feb 9 00:51 var
      Display All
      as you can see, the owner of the 'data' folder is 'abc' in my case. I can execute an 'occ' command then like:

      Source Code

      1. sudo -u abc /config/www/nextcloud/occ status
      the result would be:

      Source Code

      1. - installed: true
      2. - version: 15.0.5.3
      3. - versionstring: 15.0.5
      4. - edition:

      hope that helps.

      p.parker
      Odroid HC1 | HGST Travelstar 7K1000 | OMV 4.1.23-1 (Arrakis) | 4.14.94-odroidxu4
    • 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.
    • peterparker wrote:

      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:

      Source Code

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

      Source Code

      1. total 4
      2. drwxr-xr-x 1 abc abc 0 Feb 9 00:17 app
      3. drwxr-xr-x 1 root root 6 Feb 9 00:51 bin
      4. drwxr-sr-x 1 abc abc 48 Jan 5 14:15 config
      5. drwxrwx--- 1 abc abc 268 Mar 20 11:01 data
      6. drwxr-xr-x 1 abc abc 0 Jan 25 20:08 defaults
      7. drwxr-xr-x 5 root root 320 Mar 31 13:18 dev
      8. drwxr-xr-x 1 root root 136 Mar 31 13:18 etc
      9. drwxr-xr-x 1 root root 0 Feb 9 00:16 home
      10. -rwxr-xr-x 1 root root 389 Sep 9 2018 init
      11. drwxr-xr-x 1 root root 190 Feb 9 00:52 lib
      12. drwxr-xr-x 1 root root 104 Sep 9 2018 libexec
      13. drwxr-xr-x 1 root root 28 Feb 9 00:16 media
      14. drwxr-xr-x 1 root root 0 Feb 9 00:16 mnt
      15. dr-xr-xr-x 257 root root 0 Mar 31 13:18 proc
      16. drwx------ 1 root root 26 Apr 1 13:29 root
      17. drwxr-xr-x 1 root root 64 Mar 31 13:18 run
      18. drwxr-xr-x 1 root root 152 Feb 9 00:17 sbin
      19. drwxr-xr-x 1 root root 0 Feb 9 00:16 srv
      20. dr-xr-xr-x 12 root root 0 Apr 1 13:09 sys
      21. drwxrwxrwt 1 root root 2790 Apr 2 14:45 tmp
      22. drwxr-xr-x 1 root root 68 Feb 9 00:52 usr
      23. drwxr-xr-x 1 root root 18 Feb 9 00:51 var
      Display All
      as you can see, the owner of the 'data' folder is 'abc' in my case. I can execute an 'occ' command then like:

      Source Code

      1. sudo -u abc /config/www/nextcloud/occ status
      the result would be:

      Source Code

      1. - installed: true
      2. - version: 15.0.5.3
      3. - versionstring: 15.0.5
      4. - edition:
      hope that helps.

      p.parker
      Works! Thank you!