Use WP-CLI to Manage WordPress via Command Line on Hosting, Step by Step

This guide focuses specifically on the parts of WP-CLI that trip people up on shared DirectAdmin hosting, which differs from running it on a VPS with full root access — from requesting SSH access, to common permission errors, to scheduling WP-CLI via cron. (For a full command reference covering every category, see our complete WP-CLI guide.)

What Is WP-CLI?

WP-CLI (WordPress Command Line Interface) is the official command-line tool for managing WordPress, replacing clicking through the dashboard. It covers everything from installation and updates to plugin/theme management and database operations — ideal for repetitive tasks or managing several sites at once, and much faster than navigating menus one at a time.

Why Shared Hosting Is Different from a VPS

On a VPS, you have full root access, so you can install WP-CLI globally and run commands with no restrictions. On shared hosting like DirectAdmin, however, users are limited to their own account's home directory, which brings extra considerations: WP-CLI must be installed in a personal folder rather than system-wide, some hosts disable certain PHP functions via disable_functions that WP-CLI may rely on, and the PHP CLI memory limit is often separate from the web memory limit configured in DirectAdmin.

Requesting SSH Access on DirectAdmin Hosting

Most shared hosting disables SSH access by default for security reasons — you'll need to request it before you can use WP-CLI:

  1. Contact your hosting provider's support team and request SSH access for your account.
  2. Once enabled, you'll receive a hostname, port (often not the standard port 22 on some shared hosting, for security), and a username plus password or SSH key.
  3. Connect with ssh [email protected] -p PORT from a terminal, or use PuTTY on Windows.
  4. Verify the connection succeeded by running pwd — you should see your account's home directory path.

AsiaGB Hosting lets customers request SSH access through the ticket system, with the team reviewing and enabling it during business hours.

Installing WP-CLI Without Root Access

Since you don't have sudo mv privileges to place files in /usr/local/bin as you would on a VPS, install WP-CLI in your personal folder instead:

  1. Create a folder for binaries, e.g. mkdir -p ~/bin.
  2. Download the file with curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar.
  3. Make it executable with chmod +x wp-cli.phar, then move it into your personal folder: mv wp-cli.phar ~/bin/wp.
  4. Add your personal folder to the shell's PATH by adding export PATH="$HOME/bin:$PATH" to ~/.bashrc or ~/.bash_profile.
  5. Run source ~/.bashrc, then test with wp --version.

Some hosts already have WP-CLI installed system-wide — always try wp --version first before installing, and skip the setup entirely if it's already there.

Fixing Common Permission Errors

Most Useful Commands for Day-to-Day Hosting Tasks

For everyday work on shared hosting, only a handful of commands come up repeatedly:

Scheduling WP-CLI Automatically via Cron on DirectAdmin

Once you have SSH access, you can create a cron job through the Cron Jobs menu in DirectAdmin to run WP-CLI commands on a schedule — for example, updating plugins every week:

0 3 * * 1 cd /home/username/domains/yourdomain.com/public_html && /home/username/bin/wp plugin update --all --quiet

Always use the full path for both the website folder and the wp binary, since cron doesn't know the PATH configured in .bashrc the way an interactive SSH session does.

Tip: before running any command that changes data — like search-replace or core update — always back up your database first, with JetBackup or DirectAdmin's standard backup. As fast and convenient as WP-CLI is, it applies changes immediately with no confirmation step like the dashboard has.

Does every shared host support WP-CLI?

Not every host does — it depends on whether the provider grants SSH access. AsiaGB Hosting lets customers request SSH access through the ticket system, while some other hosts don't offer it at all for security reasons. Check with your provider first.

Can I use WP-CLI without SSH access?

No, not directly — WP-CLI can only run from a terminal. Without SSH access, you'll need to manage your site through the dashboard as usual, or ask your hosting provider to enable SSH first.

Why do I get Permission Denied when running a wp command?

This usually happens because the SSH-logged-in user doesn't match the file owner, or the installed wp file lacks execute permission. Check with ls -la and run chmod +x to grant execute permission if needed.

What's the difference between wp-cli.phar and wp?

They're the same file — wp-cli.phar is the name of the downloaded file, and wp is the shorter name you give it after moving it into your PATH folder. There's no functional difference between the two.

My WP-CLI cron job isn't running — what should I check first?

Make sure you're using the full path to the wp binary and the website folder in your cron command instead of relying on PATH, since cron doesn't load values from .bashrc the way an interactive SSH session does.

Is WP-CLI safe enough to use on a production site?

Yes, it's the official tool from the WordPress team itself. However, since commands take effect immediately with no confirmation step like the dashboard, always back up your database before running anything that changes data, especially search-replace and core update.

Hosting Ready to Enable SSH for WP-CLI

AsiaGB DirectAdmin Hosting grants SSH access through the ticket system, supporting WP-CLI, Composer, and Git deploy for developers.

View Hosting Plans

View all cheap Thailand web hosting plans →