I was stupid and messed up my filesystem permissions. How do i fix them?

Alternative title: I f***** up. How do i unf*** my installation?

I’m actually sorry

I recently had a low point in my life and ran something like sudo chown -R $USER:$USER nextcloud-bind from my host machine. (nextcloud-bind is mounted at /var/www/html inside the container). Needless to say, it blew it up.

Setup

My docker-compose.yaml is very simple: image is nextcloud:24, there’s a single volume bind as described above and everything else is just related to networking, which is unrelated to my issue.

Output of ls -la

Here’s the output of running sudo ls -la (with my normal name being replaced with abcde) in the mounted directory from the host machine (using pastebin to make this post not as large):

As you can see, i’ve tried to follow the instructions by the Nextcloud error messages and change the owners of data and apps dirs back to www-data. I’ve also tried various flag combinations like 700, 660 etc. on those same directories.

With the permissions as shown above, the error i get when trying to open Nextcloud is still “Cannot write into apps directory…”.

Logs

The next thing i did was crank up the log level and enable debug, neither provided me any more information in nextcloud.log. Unfortunately i can’t run the occ:log family of commands because occ dies as well:

www-data@61d511f1ef6d:~/html$ php occ log
Cannot write into "apps" directory.
This can usually be fixed by giving the web server write access to the apps directory or disabling the App Store in the config file.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/html/lib/private/Console/Application.php:164
Stack trace:
#0 /var/www/html/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/html/occ(11): require_once('/var/www/html/c...')
www-data@61d511f1ef6d:~/html$

The current output from either docker logs nextcloud or nextcloud.log don’t appear to give any more detail as well. Here’s one entry i pulled from nextcloud.log when trying to access the service (there are some weird whitespaces because of the way i copied this from the terminal, the file is fine):

If anyone here has the mercy to help me to fix the mess i’ve made i will be very, very thankful! You guys and girls out there are doing amazing things helping people gain digital sovereignty and i can fully understand if someone says i shot myself in the foot and need to figure it out myself.

I did the most obvious solution which actually ended up working:
Just set up a new folder with a new docker-compose, install nextcloud, then compare the fresh installation with the broken one and just chown/chmod your way through until it looks about right…
I used clear && ls -l a lot.

If you’ve still read this, thank you.

1 Like