◦ Comprehensive security
◦ 24/7 support
WordPress Guide → WP-CLI
WP CLI basics for faster WordPress management
If you’ve ever wished for a faster, cleaner way to manage your WordPress site, you’re in the right place.
Whether you want to clear your plugin backlog in a single command or spin up fresh WordPress installs without touching the dashboard, WP-CLI puts that power at your fingertips.
By the end of this guide, you’ll have WP-CLI installed, know the core commands you’ll reach for every day, and have the confidence to troubleshoot common hiccups on your own.
All you need to follow along is basic terminal access and an SSH connection to your WordPress server, with no fancy dev setup required. Let’s dive in and turn the command line into your new favorite WordPress shortcut.
Get fast, reliable hosting for WordPress
Power your site with the industry’s fastest, most optimized WordPress hosting
What is WP-CLI?
WP-CLI, or WordPress Command Line Interface, allows you to manage WordPress sites through terminal commands rather than the traditional graphical user interface (GUI). This tool simplifies the management of WordPress installations, enabling users to perform tasks swiftly and efficiently, from installing plugins and themes to updating WordPress core files, all through straightforward command inputs.
You can run one-line tasks, update the core, activate plugins, install themes, back up databases, spin up staging copies, and even script them for bulk automation.
The efficiency of WP-CLI is one of its standout features. While the GUI requires multiple clicks and navigation through various menus, WP-CLI lets users execute commands directly from the terminal, saving time and minimizing errors. Additionally, WP-CLI can handle bulk operations, making it an excellent choice for developers and administrators managing multiple sites.
For beginners, WP-CLI offers a clear way to understand the inner workings of WordPress. Common use cases include installing or updating plugins, managing database backups, and running automated scripts. As users become more comfortable with the command line, they can explore its advanced features, ultimately enhancing their WordPress management skills and efficiency.
Note that you will need SSH access (or local terminal access) to your WordPress environment, plus PHP 5.6 or newer to execute WP-CLI commands.
What is CLI in WordPress?
A CLI in WordPress is a text-based tool that lets you manage your site by typing commands instead of clicking menus. It handles everything from creating users to exporting content, making repetitive admin tasks lightning-fast and scriptable, which is ideal for developers and power users.
How does WP-CLI work?
WP-CLI operates by executing commands that interact directly with your WordPress installation. When you run a command, WP-CLI communicates with the WordPress core files and the database to perform actions such as installing plugins, updating themes, or managing users.
When you run wp plugin update --all, for example, WP-CLI connects directly to your WordPress database and file system, checks each installed plugin against the WordPress.org repository, downloads the latest versions, and activates them, without any need for dashboard clicks.
One of the key features of WP-CLI is its ability to handle bulk operations. This means you can perform tasks on multiple sites simultaneously, which is particularly beneficial for those managing several WordPress installations. Additionally, WP-CLI supports scripting, allowing users to automate repetitive tasks, further enhancing productivity.
Furthermore, WP-CLI can be extended with custom commands, enabling users to tailor the tool to their specific needs. This flexibility makes it an invaluable resource for developers looking to create customized solutions or streamline their workflows.
Overall, WP-CLI provides a robust framework for managing WordPress sites effectively and efficiently, making it a must-learn tool for anyone serious about WordPress development.
Benefits of using WP-CLI
If you spend more time waiting for pages to load than actually getting work done, WP-CLI is your solution to a calmer, more productive WordPress routine. Below are three core benefits of WP-CLI that can greatly enhance your WordPress management experience.
- Efficiency: Execute commands in seconds instead of clicking through menus. A single line like wp core update replaces four separate dashboard clicks, page loads, and confirmation dialogs. Multiply that by dozens of plugins, themes, or minor tweaks and you’re saving whole workdays over the course of a month. Fewer page loads also mean less strain on your local bandwidth and server resources, so routine maintenance no longer slows your entire site for visitors.
- Automation: Schedule tasks like backups or database optimizations to run automatically. Because every WP-CLI command can be scripted, you can drop them into a cron job (Linux) or Task Scheduler (Windows) and let the server handle the rest. Need nightly database exports, weekly security scans, or monthly comment-table clean-ups? Write once, schedule once, and sleep easy while the server works on autopilot. If something fails, WP-CLI’s plain-text logs are easy to scan or feed into a monitoring tool for instant alerts.
- Scalability: Manage multiple WordPress sites from one terminal window without logging into each dashboard. Whether you oversee a dozen client blogs or a multisite network with hundreds of subsites, WP-CLI lets you run bulk commands, such as wp plugin update
--all or wp theme activate your-custom-theme, across every install in seconds. Pair it with SSH key authentication, and you can switch between staging, production, and local environments with a single shortcut, keeping each stack perfectly in sync.
Harnessing these three pillars turns busywork into background noise. Once WP-CLI is part of your toolkit, you’ll spend less time inside the WordPress admin and more time launching new features, refining performance, and delighting your audience.
How to install WP-CLI on Linux
Before diving into the WP-CLI installation process, ensure your system meets the necessary requirements for WP-CLI. WP-CLI installation on Linux requires PHP 5.6 or later and access to the command line interface. However, it’s important to note that WordPress itself dropped PHP 5.6 support in 2023 and now requires PHP 7.2.24 or later, and WP-CLI v3.0.0 will also require PHP 7.2.24 or later. Additionally, ensure you have curl or wget installed for downloading the installation script.
To install WP-CLI on your Linux system, follow this step-by-step guide:
- Open your terminal.
- Download the WP-CLI installation script by running:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar - Once downloaded, test that the .phar works:
php wp-cli.phar –info - Make it executable:
chmod +x wp-cli.phar - Move the WP-CLI phar file to PATH:
sudo mv wp-cli.phar /usr/local/bin/wp - Finally, confirm the installation by typing:
wp –info - If everything is set up correctly, you should see WP-CLI’s version information.
While installing WP-CLI is generally straightforward, you may encounter some common issues.
If you receive an error stating that the command is not found, ensure that the executable path is correctly set in your environment. If you face permission issues, try running the installation commands with sudo.
Ensure that your PHP version meets the minimum requirement. If you continue to have problems, consult the WP-CLI documentation or seek assistance from support resources.
How to install WP-CLI on Windows
Getting WP-CLI running on Windows is quick once you have the right tools in place. Before you start, make sure you tick off these Windows-specific requirements:
- Windows 10 or 11 (64-bit). Recent builds handle PATH updates and the console better than older versions.
- PHP 7.4 or newer added to your system Path. You can install it with XAMPP, WampServer, or by typing
choco installphp in an elevated PowerShell window. - A Unix-friendly terminal such as Git Bash. The default Command Prompt doesn’t ship with helpful utilities like curl, chmod, or Unix-style paths. Installing Git forWindows gives you Git Bash plus the tools you need in one go.
- cURL or another downloader. Git Bash bundles curl, while PowerShell can use
Invoke-WebRequest. - Administrator rights (optional but helpful). Running your terminal “as admin” makes it easier to move files into system-wide folders such as
C:\Program Files.
Install WP-CLI using Git Bash
To install WP-CLI on your Windows system, follow this step-by-step guide:
- Open Git Bash from your Start menu.
- Download the Phar file by typing curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
. - Check that it runs with php wp-cli.phar –info. You should see version details for WP-CLI and PHP.
- Create a dedicated installation directory for WP-CLI:
mkdir -p /c/wp-cli
mv wp-cli.phar /c/wp-cli/ - Create a shell script wrapper file named wp (without extension) in the /c/wp-cli/ directory:
nano /c/wp-cli/wp - Make the script executable: chmod +x wp-cli.phar
. - Add the WP-CLI directory to your Windows PATH environment variable.
- Close and reopen Git Bash, then confirm the global command works with wp –info. A clean read-out means you’re ready to roll.
PowerShell alternative
Prefer sticking with Windows tools? Open PowerShell (Admin) and:
- Create a dedicated directory for WP-CLI:
New-Item -ItemType Directory -Path “C:\wp-cli” -Force - Use PowerShell’s Invoke-WebRequest to download the WP-CLI phar file:
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar" -OutFile "C:\wp-cli\wp-cli.phar""https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar" -OutFile "wp-cli.phar". - Verify it with php “C:\wp-cli\wp-cli.phar” –info.
- Create a batch file that will allow you to use the wp command instead of the full path.
- Add the WP-CLI directory to your system PATH environment variable.
- Restart PowerShell and try wp –info.
Common roadblocks and quick fixes
- “php is not recognized” – — Check that the folder containing php.exe is in your Path, then relaunch your terminal.
- “wp: command not found” – — Reopen the terminal after editing the Path or alias; Windows only reloads environment variables on a new session.
- Permission errors when moving files – — Right-click Git Bash or PowerShell and choose Run as administrator before repeating the move command.
If you continue to experience problems, refer to the WP-CLI documentation or seek support from available resources.
How to install WP-CLI on macOS
Running WordPress from a Mac gives you a full Unix shell, so adding WP-CLI is refreshingly simple. Below are two reliable ways to get the tool on your system, one click-and-forget via Homebrew and one hands-on manual route, plus a quick check to make sure everything works.
Homebrew method (recommended)
Homebrew keeps your command-line apps up to date with almost zero effort. If you already use Brew for PHP or Node, this route fits right into your normal workflow.
- Open Terminal.
- Update Homebrew by typing brew update to refresh the formula list.
- Install WP-CLI with brew install wp-cli. Brew downloads the latest stable Phar file and links it into /usr/local/bin, which is already in your Path.
- Verify the install by running wp –info. You should see your WP-CLI version, PHP version (must be 5.6+), and operating system details.
Now every time you update Homebrew, WP-CLI will tag along, ensuring you have the newest features without manual downloads.
Manual installation option
Prefer full control or coming from the Windows section above? The manual installation process is identical to the Windows Git Bash method—same curl, php, and chmod commands—with just one difference:
Final PATH setup: Instead of moving to C:\wp-cli, move the file to macOS’s standard location:sudo mv wp-cli.phar /usr/local/bin/wp
Everything else (download, test, make executable) works exactly as shown in the Windows Git Bash section above.
Verification steps (works for either method)
- Check PHP: Type
php -vto confirm PHP 7.4 or newer is active; WP-CLI depends on it. - Confirm global command:
wp --infoshould return a neat table of version data. - Test a real command: Navigate into a local WordPress folder (
cd /path/to/site) and trywp core version. If you see the WordPress version number, you’re ready to run anything from plugin updates to search-replace tasks.
Once WP-CLI answers back, you can trade dashboard clicks for rapid terminal commands and reclaim valuable development time, straight from macOS.
Basic commands to get started
WP-CLI provides a powerful way to manage your WordPress site without the need for a graphical interface. Familiarizing yourself with basic commands is the first step in harnessing its full potential.
How to install WordPress with WP-CLI
To begin navigating with WP-CLI, open your terminal and navigate to the root directory of your WordPress installation.
You can do this by using the cd command followed by the path to your WordPress folder. For example, cd /path/to/your/wordpress. Once you’re in the correct directory, you can start executing WP-CLI commands.
- Command: wp core install
- Purpose: Installs a fresh WordPress site from scratch.
- Example: wp core install –url=example.com –title=”My Site” –admin_user=admin –admin_password=strongPass123 –[email protected].
Some commonly used commands include:
- wp core version – This command checks the current version of WordPress you are running.
- wp core update – Updates WordPress core to the latest stable version.
- wp plugin list – Use this to view all the plugins installed on your site, along with their status.
- wp plugin install (or) wp plugin activate – Installs or activates a plugin from the WordPress.org repository.
- wp theme list – This shows you the themes available on your site and which one is currently active.
- wp theme install (or) wp theme activate – Installs or activates a theme.
- wp user list – This command will display all the users registered on your WordPress site.
- wp user create – Adds a new user with any role you specify.
- wp db export – Creates a quick database backup in SQL format.
Understanding these basic commands is essential for managing your WordPress site efficiently. As you grow more comfortable with WP-CLI, you’ll discover how it can significantly streamline your workflow and enhance your productivity.
Common WP-CLI errors and solutions
Even seasoned developers hit roadblocks on the command line. As you embark on your journey with WP-CLI, it’s essential to be aware of some common error messages you might encounter. Below are the three issues beginners report most often, plus straightforward steps to get you back on track.
- “Command not found.”
WP-CLI isn’t in your system Path, or the alias hasn’t been created.
1. Type wp –info. If the shell still says command not found, run which wp (macOS/Linux) or where wp (Windows) to confirm the binary’s location.
2. If no path appears, move or symlink the wp (or wp-cli.phar) file into a folder that’s already in your Path; common choices are /usr/local/bin on Unix or C:\wp-cli on Windows.
3. Close and reopen your terminal so the updated Path loads, then try wp –info again. - “Could not open input file.”
You’re running wp from a directory that doesn’t contain a WordPress install.- Navigate to the site root with cd /path/to/wordpress.
- Navigate to the site root with cd /path/to/wordpress.
- Confirm you’re in the right spot by listing contents with ls or dir; you should see wp-config.php.
- Re-run your WP-CLI command. If the error vanishes, add a project-specific alias or note the correct folder path for next time.
- Navigate to the site root with cd /path/to/wordpress.
- Permission errors (EACCES, “Operation not permitted,” etc.).
Your user account lacks write access to the requested file or folder.
1. Prepend the command with sudo (macOS/Linux) or launch your terminal “as administrator” on Windows. Example: sudo wp plugin update –all.
2. If the target directory truly should be writable without elevated rights – —like a development project under your home folder – —run chmod or update folder ownership so future commands don’t need sudo.
3. Re-execute the original WP-CLI command to verify the fix.
Tackle these quick fixes once, and most future WP-CLI hiccups will feel like minor speed bumps instead of full-blown roadblocks.
For beginners, troubleshooting these errors can seem daunting, but following these straightforward tips will make things easy for you.
Advanced WP-CLI usage
Ready to move past one-off commands and treat WP-CLI like a first-class development tool? The four techniques below will help you work faster, avoid typos, and scale your workflows across an entire fleet of WordPress sites.
Tab completion setup
Hitting the Tab key should do more than indent a paragraph – it can finish your commands for you. WP-CLI ships with a bash-completion script that knows every subcommand and flag.
- Download the completion file by typing curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash.
- Move it into your shell’s completion folder – on macOS and most Linux distros that’s ~/.bash_completion.d/.
- Source the file in your ~/.bashrc or ~/.zshrc with source ~/.bash_completion.d/wp-completion.bash, then reload the shell.
Now try wp plu followed by Tab. The shell expands it to wp plugin, saving keystrokes and preventing spelling mistakes.
Configuration file creation
Instead of typing the same flags over and over, stash them in a config file that WP-CLI reads automatically.
- Create a file named
wp-cli.ymlin your project root. - Add default settings such as:
path: /var/www/htmlso you can run WP-CLI from anywhere.color: truefor easier-to-read output.user: adminto run all commands as a specific account.
You can also maintain a global config at ~/.wp-cli/config.yml for options you want on every site.
Automation with bash scripts
A short shell script turns several single commands into one reusable task. Example:
#!/usr/bin/env bash
# nightly-maintenance.sh
wp plugin update –all
wp theme update –all
wp db export “$(date +%F).sql”
Save the file, mark it executable with chmod +x nightly-maintenance.sh, and schedule it with cron (0 2 * * * /path/to/nightly-maintenance.sh). Your site will update itself and create a dated database backup every night at 2 a.m. without manual intervention.
Managing multiple sites
If you oversee dozens of WordPress installs, WP-CLI’s bulk abilities are priceless. Two popular approaches:
- Multisite networks. Navigate to the network root and run commands like wp theme install my-theme –network to push changes across every sub-site instantly.
- Remote loops. Keep a text file of server names, then run:
for host in $(<servers.txt); do ssh $host “cd /var/www/html && wp plugin update –all”; done
The loop SSHs into each server, changes to the site directory, and updates all plugins – no dashboard log-ins, no missed sites.
Mastering tab completion, config files, scripting, and bulk management transforms WP-CLI from a handy utility into a powerful automation engine.
WP-CLI on Liquid Web Hosting
Liquid Web bakes WP-CLI into every Managed WordPress and VPS plan, so you can start issuing commands the moment you log in, without extra installs or downloads.
Some of the advantages of having WP-CLI built into your managed hosting plan include:
- Zero-setup convenience. WP-CLI is pre-installed and kept current by our sysadmin team, so you always have the latest stable release without manual updates.
- Optimized environment. Managed WordPress servers ship with tuned PHP, NGINX accelerators, and generous memory limits, ensuring WP-CLI operations finish quickly, even on large sites.
- Safe experimentation. Each account includes staging environments and automatic nightly backups; you can script updates on staging, test, then push live with confidence.
- 24/7 support from real humans. Our WordPress experts can help troubleshoot any WP-CLI hiccup – whether that’s a permission error, a multisite command, or a complex search-replace.
For a detailed walkthrough, see our support guide on installing WordPress using WP-CLI.
Getting started with WP-CLI
If you find yourself stuck and need further assistance, there are valuable resources available. The official WP-CLI documentation provides comprehensive guides and FAQs for troubleshooting. Additionally, forums such as WordPress.org support and Stack Overflow can offer community-driven insights. Engaging with these resources can enhance your understanding and proficiency with WP-CLI, making your experience smoother and more productive.
When you’re ready to upgrade your WordPress hosting, Liquid Web can help. We’ve been offering the premium hosting for WordPress sites for decades—with the fastest speeds, best uptime guarantees, and most robust security features. Click below to explore options or start a chat to connect with one of our WordPress hosting experts right now.
Additional resources
What is WordPress? →
A complete beginner’s guide—from use cases, to basics, to how to get started
How to install WordPress on localhost →
How it works, benefits for dev, and how to get started
How to integrate WordPress and Slack →
If your org uses Slack and WordPress, there are several ways you can tie them together.