How to remove WordPress spam users using WP-CLI

If you have a huge amount of spam users in your database you need to check this post https://alltime.pp.ua/blog/how-to-remove-wordpress-spam-users-using-mysql-command-line/ as the way below will take ‘forever’ 🙂

Supposed you’ve decided to leave just ‘administrator’

Using command below you found a pattern

wp user list

So, now run to remove them:

wp user delete $(wp user list --role=author --field=ID)
wp user delete $(wp user list --role=customer --field=ID)
wp user delete $(wp user list --role=subscriber --field=ID)

You should be asked and if you are sure just type ‘y

–reassign parameter not passed.… Read the rest

How to run a shell command as another user without Shell Access enabling

It needs if you don't want to waste time to enable Shell Access for specific user to run some command from his shell

sudo -H -u someuser bash -c 'uptime'

Example of using:

cd ~someuser/www
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
Read the rest

How to install WP-CLI

WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser

cd
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod 755 wp-cli.phar
mv wp-cli.phar wp
mkdir wp_cli
mv wp wp_cli
echo "alias wp='~/wp_cli/wp'" >> ~/.bashrc
Read the rest

How to upgrade your WordPress to the latest version via command line

It may fix various problems with your WordPress

First of all backup your files and database

Enter your www/ folder

cd /home/USER/public_html

Download/extract and replace files using latest WordPress version from an original source

wget https://wordpress.org/latest.zip

unzip latest.zip

rsync -avz wordpress/* ./
Read the rest