{
    "title": "WP-CLI",
    "seo_title": "WP-CLI: definition, installation and useful commands",
    "h1": "WP-CLI",
    "description": "WP-CLI: install the WordPress command line and use it for updates, backups, file integrity checks and cron jobs.",
    "lead": "WP-CLI is the official command-line interface for WordPress. From a terminal, often over SSH, it can do almost everything the admin area offers, and more: install and update core, plugins and themes, manage users, export the database, replace URLs or verify file integrity.",
    "language": "en",
    "locale": "en-US",
    "type": "definition",
    "url": "https://www.wp-masquerade.com/glossary/wp-cli/",
    "canonical": "https://www.wp-masquerade.com/glossary/wp-cli/",
    "markdown": "https://www.wp-masquerade.com/glossary/wp-cli/index.md",
    "json": "https://www.wp-masquerade.com/glossary/wp-cli/index.json",
    "published": "2026-10-28T08:00:00+00:00",
    "modified": "2026-10-28T20:14:54+00:00",
    "site": {
        "name": "WP Masquerade",
        "url": "https://www.wp-masquerade.com/"
    },
    "translations": [
        {
            "language": "en",
            "hreflang": "en-US",
            "title": "WP-CLI",
            "url": "https://www.wp-masquerade.com/glossary/wp-cli/",
            "markdown": "https://www.wp-masquerade.com/glossary/wp-cli/index.md",
            "json": "https://www.wp-masquerade.com/glossary/wp-cli/index.json"
        },
        {
            "language": "fr",
            "hreflang": "fr-FR",
            "title": "WP-CLI",
            "url": "https://www.wp-masquerade.com/fr/definitions/wp-cli/",
            "markdown": "https://www.wp-masquerade.com/fr/definitions/wp-cli/index.md",
            "json": "https://www.wp-masquerade.com/fr/definitions/wp-cli/index.json"
        },
        {
            "language": "es",
            "hreflang": "es-ES",
            "title": "WP-CLI",
            "url": "https://www.wp-masquerade.com/es/glosario/wp-cli/",
            "markdown": "https://www.wp-masquerade.com/es/glosario/wp-cli/index.md",
            "json": "https://www.wp-masquerade.com/es/glosario/wp-cli/index.json"
        },
        {
            "language": "de",
            "hreflang": "de-DE",
            "title": "WP-CLI",
            "url": "https://www.wp-masquerade.com/de/glossar/wp-cli/",
            "markdown": "https://www.wp-masquerade.com/de/glossar/wp-cli/index.md",
            "json": "https://www.wp-masquerade.com/de/glossar/wp-cli/index.json"
        },
        {
            "language": "it",
            "hreflang": "it-IT",
            "title": "WP-CLI",
            "url": "https://www.wp-masquerade.com/it/glossario/wp-cli/",
            "markdown": "https://www.wp-masquerade.com/it/glossario/wp-cli/index.md",
            "json": "https://www.wp-masquerade.com/it/glossario/wp-cli/index.json"
        },
        {
            "language": "pt",
            "hreflang": "pt-BR",
            "title": "WP-CLI",
            "url": "https://www.wp-masquerade.com/pt/glossario/wp-cli/",
            "markdown": "https://www.wp-masquerade.com/pt/glossario/wp-cli/index.md",
            "json": "https://www.wp-masquerade.com/pt/glossario/wp-cli/index.json"
        },
        {
            "language": "nl",
            "hreflang": "nl-NL",
            "title": "WP-CLI",
            "url": "https://www.wp-masquerade.com/nl/woordenlijst/wp-cli/",
            "markdown": "https://www.wp-masquerade.com/nl/woordenlijst/wp-cli/index.md",
            "json": "https://www.wp-masquerade.com/nl/woordenlijst/wp-cli/index.json"
        }
    ],
    "headings": [
        {
            "level": 1,
            "text": "WP-CLI"
        },
        {
            "level": 2,
            "text": "Installation"
        },
        {
            "level": 2,
            "text": "The most useful commands"
        },
        {
            "level": 2,
            "text": "For WordPress"
        },
        {
            "level": 2,
            "text": "Limitations"
        }
    ],
    "body": "The official WP-CLI page sums it up: anything you can do in the WordPress admin, you can do from the terminal. The benefit isn't just speed. A command runs identically on ten sites, can be saved in a script, launched by a scheduled task, and keeps working even when the admin area is unreachable, for example after a plugin crashes the site.\n\n## Installation\n\nWP-CLI is a single PHP archive file (phar). The official installation guide says it needs PHP 7.2.24 or later, with no requirements beyond those of WordPress:\n\n```\ncurl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar\nphp wp-cli.phar --info\nchmod +x wp-cli.phar\nsudo mv wp-cli.phar /usr/local/bin/wp\n```\n\n`wp cli update` then keeps it up to date. Many hosts already provide it: try `wp --info` in an [SSH](https://www.wp-masquerade.com/glossary/ssh-sftp/) session before installing it. Run it as the user who owns the site's files, not as root, so you don't create files that PHP can no longer modify.\n\n## The most useful commands\n\n- `wp core update`, `wp plugin update --all`, `wp theme update --all`: updates, with a report for each item.\n- `wp core verify-checksums` and `wp plugin verify-checksums --all`: compare core files and plugins from the official directory against the published checksums, to spot a modified or added file.\n- `wp user list --role=administrator`: the list of administrators, worth checking after an incident; our article on roles and least privilege explains what to do with it.\n- `wp db export`: a database export, the first building block of a [backup](https://www.wp-masquerade.com/glossary/3-2-1-backup-rule/).\n- `wp search-replace`: replaces a URL throughout the database while handling serialized data, with `--dry-run` to check before writing. It's the go-to tool for moving from a [staging site](https://www.wp-masquerade.com/glossary/staging-environment/) to production.\n- `wp cron event list` and `wp cron event run --due-now`: list and run scheduled tasks, useful for replacing the visit-triggered [WP-Cron](https://www.wp-masquerade.com/glossary/cron-wp-cron/).\n\n*Video: “WP-CLI FOR BEGINNERS - Manage multiple WordPress sites easy” (Alessandro “Alecaddd” Castellani)*\n\n## For WordPress\n\n- **Diagnosing a hack**: checking checksums, the list of administrators and the list of active plugins are the first steps in our guide [is my site hacked?](https://www.wp-masquerade.com/wordpress-site-hacked-signs/), and the procedure to [clean up a hacked site](https://www.wp-masquerade.com/clean-hacked-wordpress-site/) relies on the same commands.\n- **Deactivating a plugin that locks you out**: `wp plugin deactivate plugin-name` gives you back control without going through the admin area.\n- **Automating** updates and exports in a script run by cron, while keeping a log of each run.\n- **Adding `--skip-plugins` and `--skip-themes`** when the site is suspect or broken: otherwise WP-CLI loads the plugins' code, including any malicious code.\n\n## Limitations\n\nWP-CLI acts with the rights of the system user, not those of a WordPress account: anyone with SSH access to the account can change everything. Protect that access accordingly. Checksum verification doesn't cover files in the uploads folder, or premium plugins that aren't in the official directory.\n\n## Related terms\n\n- [SSH and SFTP](https://www.wp-masquerade.com/glossary/ssh-sftp/)\n- [Cron (and WP-Cron)](https://www.wp-masquerade.com/glossary/cron-wp-cron/)\n- [Staging environment](https://www.wp-masquerade.com/glossary/staging-environment/)\n- [3-2-1 backup rule](https://www.wp-masquerade.com/glossary/3-2-1-backup-rule/)\n- [Malware](https://www.wp-masquerade.com/glossary/malware/)\n\n\n## Sources\n\n- [WordPress.org : WP-CLI](https://wordpress.org/cli/)\n- [WP-CLI Handbook : Installing](https://make.wordpress.org/cli/handbook/guides/installing/)\n- [WP-CLI Commands : wp search-replace](https://developer.wordpress.org/cli/commands/search-replace/)\n- [WP-CLI Commands : wp cron event run](https://developer.wordpress.org/cli/commands/cron/event/run/)",
    "definition": "WP-CLI is the official command-line interface for WordPress. From a terminal, often over SSH, it can do almost everything the admin area offers, and more: install and update core, plugins and themes, manage users, export the database, replace URLs or verify file integrity.",
    "group": "Web hosting",
    "aka": [
        "WordPress CLI",
        "WordPress command line",
        "wp",
        "wp-cli.phar"
    ],
    "related": [
        {
            "title": "SSH and SFTP",
            "url": "https://www.wp-masquerade.com/glossary/ssh-sftp/",
            "markdown": "https://www.wp-masquerade.com/glossary/ssh-sftp/index.md"
        },
        {
            "title": "Cron (and WP-Cron)",
            "url": "https://www.wp-masquerade.com/glossary/cron-wp-cron/",
            "markdown": "https://www.wp-masquerade.com/glossary/cron-wp-cron/index.md"
        },
        {
            "title": "Staging environment",
            "url": "https://www.wp-masquerade.com/glossary/staging-environment/",
            "markdown": "https://www.wp-masquerade.com/glossary/staging-environment/index.md"
        },
        {
            "title": "3-2-1 backup rule",
            "url": "https://www.wp-masquerade.com/glossary/3-2-1-backup-rule/",
            "markdown": "https://www.wp-masquerade.com/glossary/3-2-1-backup-rule/index.md"
        },
        {
            "title": "Malware",
            "url": "https://www.wp-masquerade.com/glossary/malware/",
            "markdown": "https://www.wp-masquerade.com/glossary/malware/index.md"
        }
    ],
    "sources": [
        {
            "title": "WordPress.org : WP-CLI",
            "url": "https://wordpress.org/cli/"
        },
        {
            "title": "WP-CLI Handbook : Installing",
            "url": "https://make.wordpress.org/cli/handbook/guides/installing/"
        },
        {
            "title": "WP-CLI Commands : wp search-replace",
            "url": "https://developer.wordpress.org/cli/commands/search-replace/"
        },
        {
            "title": "WP-CLI Commands : wp cron event run",
            "url": "https://developer.wordpress.org/cli/commands/cron/event/run/"
        }
    ],
    "format": "application/json"
}