Delete stubborn WordPress Mobile Pack or other web-installed directory and files

In a way to make things easier for novice or new WordPress users, some plugins, such as WordPress Mobile Pack, would employ web-install to install some files into your WordPress directory.

As result, you end up with those web-installed files undeletable and stuck in your directory.

How come and why? Apache web services are running as “nobody” and even though you own all your web directories but since you are NOT a “nobody”, so permission is denied for file and directory deletions. You may be shaking your head, but you may have to live with those directories/files.

Good news is that if you are stuck with files left by WordPress Mobile Pack or any web-installation plugins or scripts, you can still delete those files.

This little tip is intended to those who are comfortable in doing shell command and has some kind of php knowledge.

Be WARNED – DO IT AT YOUR OWN RISK.

Since those files are owned by “nobody”, so the only and best way is to simulate web service as a “nobody” user.

For illustration purpose, we will attempt to remove the WordPress Mobile Pack theme directories.

SSH (preferred) or TELNET into your account and change to wp-contents directory

Do the following:
1. chmod 777 themes
2. cd themes
3. pico remove.php (you may use “nano”, “vim” or any other editor you prefer)
4. add the following codes

5. save file
6. point your browser to
yoururl/wp-contents/themes/remove.php

this should remove the directories – doubt-check to make sure. The change back to wp-contents directory and change the director permission back to 755.

7. cd ..
8. chmod 755 themes

You should probably first back up/download your active theme, just in case you mess up.

What this tip does is run as “nobody” to delete those directories/files. Alternatively, your web host may be able to delete them, but you must make a request, every time you stuck with one or two.

Reference:
Deleting files created by nobody