-2

I have a directory where I used to make the backup of my owncloud files from Ubuntu. It's owned by user 33 and group 33, which in Ubuntu are the www-data (Apache) user and group. Now I have changed the server's OS to OpenSUSE and the user and group for Apache are wwrun and www respectively with id 459. I'm pretty sure (although I haven't tried, but that's kind of irrelevant to the question) that that will give me problems when I mount that volume and try to backup stuff in it (it's not writable by everybody).

So I tried to change the ownership and/or the permissions of that directory, but even sudo and sudo -u www-data are impotent in this.

There are some similar questions around (like this, 15 years old), but I couldn't find any with an answer: is it at all possible to change owner or permission in such a case? If yes, how?

Further information

I tried the commands sudo chown -R user:user path/to/dir, sudo -u wwwrun chown -R user:user path/to/dir (because I was doing it from OpenSUSE) and sudo -u www-data chown -R user:user path/to/dir (because I was doing it to Ubuntu)
and each time I got the error permission denied.

I should however also say that I in the meantime "solved" the problem by mounting the disk with my uid and gid and now I have full access to it.

It would still be nice to know why those commands didn't work, since, like I said, by searching I have seen that other people have this problem.

Andyc
  • 97
  • 2

1 Answers1

0

You can w/o any problem to change the owner with command:

cd /var/www # or wherever they are web files
chown -R wwrun:www *

This will change the files and directories owner to wwrun and group to www

From comment: you can use option --from:

chown -R wwrun:www --from=33:33 *
Romeo Ninov
  • 5,263
  • 4
  • 20
  • 26
  • 1
    It might be worth noting the `--from=33:33` option which is particularly useful in this case since it would allow to remap the old uid/God to the new ones without affecting other backups (if there are any). – Ginnungagap Apr 08 '23 at 06:35
  • @Ginnungagap, probably. To be honest I didn't know this option :) – Romeo Ninov Apr 08 '23 at 06:52