Skip to content

Administering WordPress from the Command Line (WP‑CLI)

The WordPress Command Line Interface (WP‑CLI) is a powerful tool that lets you manage WordPress directly from the terminal. On ruachost.com, WP‑CLI can be used to perform administrative tasks faster than through the dashboard, and it can be automated with cron jobs.

  • Perform WordPress tasks quickly without logging into the dashboard.
  • Automate repetitive tasks with cron jobs.
  • Manage plugins, themes, users, and databases efficiently.
  • Useful for developers and system administrators familiar with Linux commands.
  1. Access your server via SSH.
  2. Navigate to the directory where WordPress is installed.
  3. Run the following command to verify WP‑CLI is installed:

✅ If installed, you’ll see version and environment details.

Terminal window
wp --info
  • List installed plugins:

    Terminal window
    wp plugin list
  • Install and activate a plugin:

    Terminal window
    wp plugin install plugin-name --activate
  • Update all plugins:

    Terminal window
    wp plugin update --all
  • Update WordPress core:

    Terminal window
    wp core update
  • Update database after core update:

    Terminal window
    wp core update-db
  • Check current WordPress version:

    Terminal window
    wp core version
  • Export database:

    Terminal window
    wp db export
  • Import database:

    Terminal window
    wp db import backup.sql
  • Optimize database:

    Terminal window
    wp db optimize
  • Repair database:

    Terminal window
    wp db repair
  • List all users:

    Terminal window
    wp user list
  • Update a user password:

    Terminal window
    wp user update username --user_pass=newpassword
  • Update admin email:

    Terminal window
    wp option update admin_email user@example.com
  • Retrieve custom login URL:

    Terminal window
    wp option get rwl_page
You can schedule WP‑CLI commands using cron jobs. For example:
  • Daily database backup at 2:15 AM:

    Terminal window
    15 2 * * * cd /home/username/public_html; /usr/bin/wp db export >/dev/null 2>&1
  • Daily WordPress update at 3:15 AM:

  • WP‑CLI requires basic knowledge of the Linux command line.
  • Always back up your site before running update or database commands.
  • Some commands may not work outside the WordPress installation directory.
  • Test cron jobs carefully to avoid unintended changes.