Question

I am having trouble getting a few plugins to play nicely in wordpress. On top of that I can't even deactivate or delete several of them, they appear to be locked. I apologize I am somewhat of a linux newb, I have learned a lot but am baffled. I think it has to do with one of two things I did when I setup my VPS, which was guided by a tutorial. One was to install this script which would make commands wpupgrade for installing / deleting plugins and wpsafe for reverting to safe ownership.

    ### Edit the 2 values first, then post the whole lot. 
    #
export DOMAIN="mydomain.com"
export USER="myusername"
#
echo '
#########################
### WordPress 'chown' ###
#########################
## Allow WordPress Upgrades/Plugin Installs
alias wpupgrade="sudo find /home/USERNAME/public_html/DOMAIN/public/wp-admin -exec chown -R www-data:webmasters {} \; && sudo find /home/USERNAME/public_html/DOMAIN/public/wp-content -exec chown -R www-data:webmasters {} \;"
## Revert to Safe WordPress Ownership
alias wpsafe="sudo find /home/USERNAME/public_html/DOMAIN/public/wp-admin -exec chown -R USERNAME:webmasters {} \; && sudo find /home/USERNAME/public_html/DOMAIN/public/wp-content -exec chown -R USERNAME:webmasters {} \;"
' >> /home/$USER/.bashrc
sed -i "s/USERNAME/$USER/g" /home/$USER/.bashrc
sed -i "s/DOMAIN/$DOMAIN/g" /home/$USER/.bashrc
source /home/$USER/.bashrc
source /root/.bashrc

However, now all my wp-content and wp-includes are owned by www-data:webmasters and I cannot delete or modify them. I never created a www-data user. I try to use:

    chown -R myusername:webmasters /home/myusername/public_html/mydomain.com/public/wp-content

and it tells me

    chown: changing ownership of `/home/myusername/public_html/mydomain.com/public/wp-content': Operation not permitted

I have no idea what I'm doing wrong or what to do to fix this.. any help?

Was it helpful?

Solution

data is the user which executs apache. You must be running the script through apache user on you machine. To do a chown you must be the owner or a super user try sudo chown -R. Or log into super-user mod type su - in your terminal then enter the root password. Beware as root you can do anything you have all rights, think twice before executing a commande.

[edit] I see that your script is in public_html -> this is tha apache folder for your user maybe that is why it has changed the script to www-data as owner.

try this sudo setfacl -R -m u:www-data:rwX -m u:myusername:rwX /home/myusername/public_html/mydomain.com/public/wp-content

to add you and www-data as uses

OTHER TIPS

1) To change the ownership of a single file, run the command below.

$ sudo chown username:groupname filename

For Ex.

$ sudo chown richard:richard lockfile

Replace with the username of the account you wish to take ownership of the file. And is the group that will assume ownership of the file.

2) Now that you know how to change the ownership of a single file, the below commands show you how to change the ownership of a folder and all sub-folders within.

$ sudo chown -R username:groupname FolderName

For Ex.

$ sudo chown -R richard:richard Songs/

That’s it! And I hope you liked it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top