Search code examples
wordpressamazon-web-servicescommand-linepermissionsbitnami

Editing and Resetting Permissions for all folders, subfolders and files


I've just started to learn Linux Command Line. The setup I am on is AWS Lightsail bitnami Wordpress. I work with wordpress primarily.

I'm still confused about file permissions in Linux. Why do I have permissions denied when I sign in as the owner?

Whenever I have to ftp, overwrite, edit files and folders, I have to change the permissions settings for each affected folders and files manually via SSH.

More often than not, at the end of the day, I lost track of which folders and files' permissions I have edited and need to reset to default. I find this a chore and I believe there is a better way.

I wonder if there are lines of command that can

  1. give me full access to all directories, folders, subfolders and files at once?
  2. change the permissions for directories, folders, subfolders and files at once?
  3. reset the permissions of all edited files to default/original all at once?

To check the permission of the file

sudo stat TARGETFOLDER 

To change the permission of the file

sudo chmod 777 TARGETFOLDER

Solution

  • Bitnami Engineer here,

    We configure the permissions of the WordPress' files by setting bitnami as the user owner and daemon as group owner of the files. This configuration allows you edit the files using the bitnami user and the webserver can use the daemon group to do the same. However, if you make changes to the application using the web interface (install plugins or themes), those new files are owned by daemon:daemon (the Apache and PHP-FPM services use that user and group so they generate the files using those permissions configuration) and you won't be able to edit them unless you use the command line and sudo. In that case, you can run the following commands to be able to edit those files using the bitnami user

    sudo chown -R /opt/bitnami/apps/wordpress/htdocs
    sudo find /opt/bitnami/apps/wordpress/htdocs -type d -exec chmod 775 {} \;
    sudo find /opt/bitnami/apps/wordpress/htdocs -type f -exec chmod 664 {} \;
    sudo chmod 640 /opt/bitnami/apps/wordpress/htdocs/wp-config.php
    

    You can learn more about this here

    https://www.youtube.com/watch?list=PLGgVZHi3XQNn4x0DU7Qj1r_inej3xEUda&v=nKfle7O0vN8&feature=emb_title