chown $www-data results in invalid option -- d

Trying to set up a lamp development environment by following this guide: https://www.linode.com/docs/web-servers/lamp/how-to-install-a-lamp-stack-on-ubuntu-18-04/.

Trouble starts at the virtual hosts section, step #4, I subbed out the example.com to deckdev.local, so the final command should be

sudo chown -R $www-data:$www-data /var/www/html/deckdev.local/public_html

which produces the following output

chown: invalid option -- 'd'
Try 'chown --help' for more information.

I set out to google and discovered this forum thread: https://www.linode.com/community/questions/20208/chown-invalid-option-d which the user jyoo suggests that using the variable names $www-data:$www-data is somehow causing the command parser to misinterpret. I'm leaning towards agreeing with this assestment, problem is no solution was posted on those forums in over two months now.

I personally don't see what's 'wrong' it myself, anyone else able to help unravel this mystery? It's been a little while since I last flexed my linux muscles.


Solution 1:

$www is an empty variable, so chown sees the following:

sudo chown -R -data:-data

-data or rather -d is then interpreted as option.

it should be:

sudo chown -R www-data:www-data /path/to/public_html

That seems wrong in that tutorial.