Ready WP-CLI Commands for WordPress

Pick a task and copy the command: update WordPress and plugins, create an admin or reset a password, export the database and replace URLs safely, flush caches. 23 explained commands, with site path and run-as user when you need them.

Pick a task

Commands

Pick a task

WordPress

Plugins and themes

Users

Database

Site

Handy shortcuts

Help for any commandwp help plugin install
Environment infowp --info
Running as root (avoid)wp … --allow-root
Multisitewp … --url=site.example.com

Rules for working safely in the terminal

Do

  • Export the database before any update or replace
  • Run commands as the site owner, not root
  • Try search-replace with --dry-run first

Avoid

  • Typing passwords inside the command
  • Updating everything at once on a live store with no backup
  • Replacing URLs by hand in an SQL file

WP-CLI runs in a terminal (SSH or cPanel Terminal). How to enable Terminal in cPanel. For emergencies: disable plugins without the dashboard and reset a password.

Example: the site broke after a plugin update

Open the terminal, export the database as a backup, then deactivate all plugins in one command. If the site returns, re-enable them one by one to find the culprit, then update or replace it. Much faster than renaming folders by hand.

Key terms

Short definitions of what you meet along the way.

SSH
A secure connection to the server terminal for typing commands.
search-replace
A command that replaces text in the database while handling serialised data.
Dry run
A test run that shows the result without changing anything.

Frequently asked questions

Did not find your answer? Ask us on WhatsApp

What is WP-CLI?

The official command-line tool for WordPress: almost everything from the dashboard, only faster.

Is it available on shared hosting?

It needs SSH or a terminal. On our hosting Terminal is enabled on request.

Why --prompt=user_pass?

So you type the password after running and it stays out of your shell history.

The command cannot find WordPress?

cd into the site folder, or put the path in the Site path box.

A fast WordPress site without the headache?

WordPress-tuned hosting with one-click install, backups and Arabic support.

Contact us on WhatsApp