Skip to content

Magento 2.4.5 File/Folder Permissions

I know this has been asked before and there is the magento help documents, but can someone clarify what files/folder permissions i need for magento 2.4.5.
I have been running magento fine for over 2 years and upgrading fine, but when upgrading to 2.4.5 something went wrong with my permissions.
I am running ubuntu 20.04 on a dedicated server, my user is added to the www-data group. I have tried following the instructions on https://experienceleague.adobe.com/docs/commerce-operations/configuration-guide/deployment/file-system-permissions.html (I’ve tried both options and both dont work properly).

My user is the only one i use to login to my server, but obviously there is a root and www-data user as well.
Right now things are sort of working but newly generated css and js files in pub/static/_cache/merged are owned by www-data, not my user. They have what i assume is the correct permissions of 775, but previously generated files are set to owned by my user and the www-data group, but have permissions of 577. The last command i used was find app/code lib pub/static app/etc generated/code generated/metadata var/view_preprocessed ( -type d -or -type f ) -exec chmod g-w {} + && chmod o-rwx app/etc/env.php and find app/code lib var generated vendor pub/static pub/media app/etc ( -type d -or -type f ) -exec chmod g+w {} + && chmod o+rwx app/etc/env.php

I am in production mode and i can run bin/magento commands (at one stage before i got this far i could only run some of them as sudo).
If we assume all permissions are screwed, how do i get back to the correct owner and read/write permissions?