↑ ↓ select, Enter open, Esc close

WP-CLI

Manage WordPress without the dashboard: core, plugins, users, search and replace in the database, cron and cache. Saves hours when you run many installations.

50 one-liners: 19 harmless, 26 caution, 5 destructive

All WP-CLI one-liners

Back up the WordPress database as a gzip file

$wp db export - --path=/var/www/vhosts/example.com/httpdocs | gzip > /var/www/vhosts/example.com/db-backup.sql.gz
harmless

Change domain: replace the old domain in the database

$wp db export /var/www/vhosts/example.com/before-domain-change.sql --path=/var/www/vhosts/example.com/httpdocs && wp search-replace '//old.example.com' '//example.com' --all-tables --skip-columns=guid --path=/var/www/vhosts/example.com/httpdocs
destructive

Change the role of a WordPress user

$wp user set-role editorial editor --path=/var/www/vhosts/example.com/httpdocs
caution

Change the siteurl and home addresses

$wp option update siteurl 'https://example.com' --path=/var/www/vhosts/example.com/httpdocs && wp option update home 'https://example.com' --path=/var/www/vhosts/example.com/httpdocs
caution

Check whether WordPress blocks search engines

$wp option get blog_public --path=/var/www/vhosts/example.com/httpdocs
harmless

Check WordPress core files for tampering

$wp core verify-checksums --path=/var/www/vhosts/example.com/httpdocs
harmless

WordPress runs. Does it rank?

Check the Core Web Vitals of your WordPress site

Plugins updated, cache flushed, permissions fixed. GENLOC.SEO shows how Google sees the site: PageSpeed, on-page checks and prioritized recommendations. Free.

by GENLOC.NETWORK, the team behind myline.de

Compare plugin files with the originals from wordpress.org

$wp plugin verify-checksums --all --path=/var/www/vhosts/example.com/httpdocs
harmless

Count WordPress posts by status

$wp post list --post_type=post --post_status=any --field=post_status --path=/var/www/vhosts/example.com/httpdocs | sort | uniq -c
harmless

Create a new WordPress administrator

$wp user create emergencyadmin admin@example.com --role=administrator --path=/var/www/vhosts/example.com/httpdocs
caution

Deactivate a single plugin despite a PHP fatal error

$wp plugin deactivate woocommerce --skip-plugins --skip-themes --path=/var/www/vhosts/example.com/httpdocs
caution

Deactivate all plugins and save the active list

$wp plugin list --status=active --field=name --path=/var/www/vhosts/example.com/httpdocs > /var/www/vhosts/example.com/active-plugins.txt && wp plugin deactivate --all --path=/var/www/vhosts/example.com/httpdocs
caution

Delete a scheduled WP-Cron event

$wp cron event delete old_plugin_daily_event --path=/var/www/vhosts/example.com/httpdocs
caution

Delete all post revisions

$wp post list --post_type=revision --format=ids --path=/var/www/vhosts/example.com/httpdocs | xargs -r wp post delete --force --path=/var/www/vhosts/example.com/httpdocs
destructive

Delete expired transients from the WordPress database

$wp transient delete --expired --path=/var/www/vhosts/example.com/httpdocs
caution

Enable automatic updates for a plugin

$wp plugin auto-updates enable wordfence --path=/var/www/vhosts/example.com/httpdocs
caution

Enable the WordPress debug log without displaying errors

$wp config set WP_DEBUG true --raw --path=/var/www/vhosts/example.com/httpdocs && wp config set WP_DEBUG_LOG true --raw --path=/var/www/vhosts/example.com/httpdocs && wp config set WP_DEBUG_DISPLAY false --raw --path=/var/www/vhosts/example.com/httpdocs
caution

Find posts with a specific meta key

$wp post list --post_type=any --meta_key=_yoast_wpseo_meta-robots-noindex --fields=ID,post_type,post_title --path=/var/www/vhosts/example.com/httpdocs
harmless

Find the largest autoloaded options in WordPress

$wp option list --autoload=on --orderby=size_bytes --order=desc --fields=option_name,size_bytes --path=/var/www/vhosts/example.com/httpdocs | head -n 20
harmless

Flush the WordPress object cache

$wp cache flush --path=/var/www/vhosts/example.com/httpdocs
caution

Import a gzipped dump into the WordPress database

$gunzip -c /var/www/vhosts/example.com/db-backup.sql.gz | wp db import - --path=/var/www/vhosts/example.com/httpdocs
destructive

Install a specific WordPress core version

$wp core update --version=6.6.2 --force --path=/var/www/vhosts/example.com/httpdocs
caution

Install and activate a WordPress language pack

$wp language core install de_DE --activate --path=/var/www/vhosts/example.com/httpdocs
caution

List all sites in a WordPress multisite

$wp site list --fields=blog_id,url,last_updated --path=/var/www/vhosts/example.com/httpdocs
harmless

List all WordPress administrators

$wp user list --role=administrator --fields=ID,user_login,user_email,user_registered --path=/var/www/vhosts/example.com/httpdocs
harmless

List all WordPress users with their roles

$wp user list --fields=ID,user_login,user_email,roles --path=/var/www/vhosts/example.com/httpdocs
harmless

List installed plugins with status and updates

$wp plugin list --fields=name,status,version,update_version --path=/var/www/vhosts/example.com/httpdocs
harmless

List installed themes with status and updates

$wp theme list --fields=name,status,version,update_version --path=/var/www/vhosts/example.com/httpdocs
harmless

List scheduled WP-Cron events

$wp cron event list --fields=hook,next_run_relative,recurrence --path=/var/www/vhosts/example.com/httpdocs
harmless

Optimize the WordPress database

$wp db optimize --path=/var/www/vhosts/example.com/httpdocs
caution

Permanently delete all spam comments

$wp comment list --status=spam --format=ids --path=/var/www/vhosts/example.com/httpdocs | xargs -r wp comment delete --force --path=/var/www/vhosts/example.com/httpdocs
destructive

Read the siteurl and home addresses

$wp option get siteurl --path=/var/www/vhosts/example.com/httpdocs && wp option get home --path=/var/www/vhosts/example.com/httpdocs
harmless

Regenerate missing thumbnails

$wp media regenerate --only-missing --yes --path=/var/www/vhosts/example.com/httpdocs
caution

Regenerate permalinks and rewrite rules

$wp rewrite flush --path=/var/www/vhosts/example.com/httpdocs
caution

Regenerate WordPress security keys (salts)

$wp config shuffle-salts --path=/var/www/vhosts/example.com/httpdocs
caution

Remove the search engine block in WordPress

$wp option update blog_public 1 --path=/var/www/vhosts/example.com/httpdocs
caution

Reset a WordPress user password

$wp user update admin --user_pass=NewSecurePassword --path=/var/www/vhosts/example.com/httpdocs
caution

Roll back a plugin to a specific version

$wp plugin install contact-form-7 --version=5.9.8 --force --path=/var/www/vhosts/example.com/httpdocs
caution

Run a WP-CLI command on every site in a multisite

$wp site list --field=url --path=/var/www/vhosts/example.com/httpdocs | xargs -r -I {} wp cache flush --url={} --path=/var/www/vhosts/example.com/httpdocs
caution

Run due WP-Cron events immediately

$wp cron event run --due-now --path=/var/www/vhosts/example.com/httpdocs
caution

Run PHP code in the WordPress context

$wp eval 'echo PHP_VERSION . " / WP " . get_bloginfo("version") . PHP_EOL;' --path=/var/www/vhosts/example.com/httpdocs
harmless

Run WP-CLI as the Plesk subscription user instead of root

#runuser -u webuser -- wp plugin list --path=/var/www/vhosts/example.com/httpdocs
caution

Show recently registered WordPress users

$wp user list --orderby=registered --order=DESC --fields=ID,user_login,user_email,user_registered,roles --path=/var/www/vhosts/example.com/httpdocs | head -n 15
harmless

Show the size of WordPress database tables

$wp db size --tables --path=/var/www/vhosts/example.com/httpdocs
harmless

Show the WP-CLI version and the PHP it uses

$wp --info
harmless

Switch the WordPress database from http to https

$wp db export /var/www/vhosts/example.com/before-https.sql --path=/var/www/vhosts/example.com/httpdocs && wp search-replace 'http://example.com' 'https://example.com' --skip-columns=guid --path=/var/www/vhosts/example.com/httpdocs
destructive

Switch to a default WordPress theme

$wp theme activate twentytwentyfour --skip-themes --skip-plugins --path=/var/www/vhosts/example.com/httpdocs
caution

Test search and replace in the database

$wp search-replace 'http://example.com' 'https://example.com' --all-tables --dry-run --report-changed-only --path=/var/www/vhosts/example.com/httpdocs
harmless

Turn WordPress maintenance mode on and off

$wp maintenance-mode activate --path=/var/www/vhosts/example.com/httpdocs
caution

Update all WordPress plugins at once

$wp plugin update --all --path=/var/www/vhosts/example.com/httpdocs
caution

Update WordPress core including the database

$wp core update --path=/var/www/vhosts/example.com/httpdocs && wp core update-db --path=/var/www/vhosts/example.com/httpdocs
caution

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.