0

I don't know to much about linux and server creating but I wanna create my private owncloud web drive, I have linux Ubuntu 20.04 server on my Raspberry pi4 installed. I have started using this tutorial to set it up but I'm having issues at the beginning. When I'm trying to create Helper Script(?):

Create the occ Helper Script

Create a helper script to simplify running occ commands.

FILE="/usr/local/bin/occ"
/bin/cat <<EOM >$FILE
#! /bin/bash
cd /var/www/owncloud
sudo -E -u www-data /usr/bin/php /var/www/owncloud/occ "\$@"
EOM

Make the helper script executable:

chmod +x /usr/local/bin/occ

In my terminal I get this kind of error:

Terminal screenshot

How make it work?

muru
  • 197,895
  • 55
  • 485
  • 740
Bazi
  • 1
  • 2
    /usr/local/bin/occ is owned by root. The article clearly mentions, *"This guide assumes that you are working as the root user."* You may consider logging in as root temporarily or sudo (note that sometimes sudo may not work, for example, with shell builtins). – Kulfy Jul 28 '21 at 15:59
  • 1
    Please don't post screenshots of text. Copy the text here and use code formatting for commands and command output, please. – muru Jul 29 '21 at 07:26

2 Answers2

0

This is crazy, the tutorial uses ubuntu, where 'root' isn't usable directly, it then assumes you have logged in as root.

Either wrap the code in another script and run that with sudo, or extract the three lines for the script from the code and create the script directly with an editor. If you do the latter, remove the '' from the last line i.e. "\$@" becomes "$@"

0

If you're getting a permission denied error, you can try this instead:

FILE="/usr/local/bin/occ"
sudo tee "$FILE" <<'EOM'
#! /bin/bash
cd /var/www/owncloud
sudo -E -u www-data /usr/bin/php /var/www/owncloud/occ "$@"
EOM

This will run tee with sudo, which should allow writing to the /usr/local/bin/occ file. (See How to solve "permission denied" when using sudo with redirection in Bash?) Then you can use the chmod command with sudo as well.

muru
  • 197,895
  • 55
  • 485
  • 740