How to Open the Terminal in cPanel and Run WP-CLI

Investigate: how to open the Terminal and run WP-CLI

Most WordPress security work, from verifying core files to finding hidden administrator accounts, is faster and more reliable from the command line. This guide covers the essentials: opening the Terminal in cPanel, checking whether WP-CLI is installed (and installing it if it isn’t), and running your first WordPress commands safely.

No Linux experience is needed. If you can log in to cPanel and copy and paste, you can follow every step.

What you are working with

The Terminal is a text window that lets you type commands straight to your hosting account. Instead of clicking through File Manager, you type an instruction and the server answers in text.

WP-CLI is the official command-line tool for WordPress. It lets you do things like check WordPress files, list users or update plugins with one command. For security work it is the most useful tool I know, because it can check thousands of files in seconds.

Step 1: Find the Terminal in cPanel

  1. Log in to cPanel.
  2. Scroll to the Advanced section, or type “terminal” in the search box at the top.
  3. Click Terminal.

The first time you open it, cPanel shows a warning that commands typed here can break your account. Click I understand and want to proceed. You only see this once.

A black window opens with a line that ends in a $ sign. That is the prompt. The server is waiting for you to type.

If you can’t find Terminal: your host has not turned it on. The Terminal only appears when your account has shell access and the host has enabled the “SSH Access & Terminal” feature. Ask your host to enable it. If they won’t, ask for SSH access instead (cPanel → Security → SSH Access), which gives you the same thing from a program on your own computer.

Step 2: Find out where you are

Type this and press Enter:

pwd

It prints the folder you are in, usually your home folder, something like /home/yourusername. Now list what is inside:

ls

You should see public_html among the results. That is where your main website lives.

Step 3: Check whether WP-CLI is already installed

Many hosts install WP-CLI for you. Check by typing:

wp --info

If you see details such as the PHP version and the WP-CLI version, it is installed and you can skip to Step 5.

If you see wp: command not found, it is not installed yet. Go to Step 4.

Step 4: Install WP-CLI in your own account (only if needed)

The official WP-CLI guide installs it for the whole server, which needs administrator rights you won’t have on shared hosting. Instead, I install it inside my own home folder. It works the same way and only affects my account.

First, check that PHP is new enough. WP-CLI needs PHP 7.2.24 or later:

php --version

Then run these commands one at a time:

cd ~
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info

If the last command prints WP-CLI details, the download worked. Now make it a proper wp command:

chmod +x wp-cli.phar
mkdir -p ~/bin
mv wp-cli.phar ~/bin/wp
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Check again:

wp --info

It should now work. You only do this once.

Step 5: Go to your website’s folder

WP-CLI needs to know which WordPress site you mean. The simplest way is to move into the site’s folder:

cd ~/public_html

If your WordPress is in a subfolder or an addon domain, go there instead, for example cd ~/public_html/blog or cd ~/example.org.

Step 6: Run your first safe commands

These commands only read information. They change nothing.

wp core version

Shows your WordPress version.

wp plugin list

Lists every plugin, whether it is active, and whether an update is available.

wp user list --role=administrator

Lists every administrator. On a site I look after, I know exactly who should be here. Any name I don’t recognise is a warning sign.

Step 7: Be careful on a site that might be hacked

When WP-CLI runs, it loads WordPress, and that includes your plugins and theme. If the site is infected, loading it can run the attacker’s code. On a site I suspect, I add two options to every command:

wp core version --skip-plugins --skip-themes

This tells WP-CLI to start WordPress without plugins or the theme. It is a small habit that prevents a nasty surprise. You will see me use it throughout my security series.

Two more rules I follow:

  • Read before you change. Start with commands that only look (list, version, verify-checksums) before running anything that deletes or updates.
  • Never run WP-CLI as root on a hacked site. In cPanel you are already your own user, so this is safe. It matters if you manage a whole server through WHM.

Common problems and what they mean

What you seeWhat it meansWhat to do
wp: command not foundWP-CLI isn’t installed, or isn’t on your pathFollow Step 4, then run source ~/.bashrc
This does not seem to be a WordPress installationYou are in the wrong foldercd into the folder that contains wp-config.php, or add --path=/home/yourusername/public_html
Error establishing a database connectionWordPress can’t reach its databaseCheck the database details in wp-config.php, or ask your host
A PHP fatal error that names a pluginA plugin crashes when loadedAdd --skip-plugins --skip-themes
Allowed memory size exhaustedPHP ran out of memoryRun the command again with php -d memory_limit=512M ~/bin/wp …

What you can do now

Once you can open the Terminal and run wp, a lot of WordPress security work becomes quick and reliable. In my series on investigating a real hosting breach, I use WP-CLI to:

  • check that WordPress core files match the official versions
  • find PHP files hiding in the uploads folder
  • spot fake administrator accounts

Each of those starts exactly where this guide ends: with the Terminal open and WP-CLI working.

Ready to start your project?

Share what you need, and the next steps follow.

Planning a project?

Your details are used only to answer your request. Privacy notice