[Command] Reinstall WordPress core, themes, plugins – malware remover

This guide will help you reinstall core WordPress, Plugins and Themes without losing data. This will help you escapse from mailware.

First, you need to install the wp cli command inteface by command below in SSH terminal.


cd ~ && curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x wp-cli.phar && mv wp-cli.phar /usr/local/bin/wp

After that, go to the your website directory location with cd command. Example, I have a WordPress website domain.com at folder /home/domain.com/public_html
You can get your WordPress path from menu Tools > Site Heath then to go Info tab and check WordPress directory location column.


cd /home/domain.com/public_html

After that, run commands below one by one to reintall cores files

wp core download --skip-content --force --allow-root
wp theme install $(wp theme list --field=name --allow-root) --force --allow-root
wp plugin install $(wp plugin list --field=name --allow-root) --force --allow-root

This commands will reinstall free themes and plugins. In case, your website used premium themes and plugins. Please download them them install via menu Apperance > Themes and Apperance > Plugins > Add New then select overwrite old versions.

Next, we need to remove php code in uploads folders. This will decrease risk of embed code put in that folder before.

find ./wp-content/uploads -type f -name "*.php" -exec rm -f {} \;

That all, I often use this steps when we got malware on website.

Leave a Reply

Your email address will not be published. Required fields are marked *

Zalo
Telegram
Messenger
Messenger
Telegram
Zalo