Pantheon Terminus Commands: Essential WP-CLI Shortcuts for WordPress Developers

Made on

Floating the Bubbles of Insights on using Terminus
Bubbles” by Clint Mason is licensed under CC BY 2.0.

Firstly: What is WP-CLI?

WP-CLI (WordPress Command Line Interface) is the official command-line tool for managing WordPress installations. Created and maintained by the WordPress community, it allows developers to perform WordPress administrative tasks without using a web browser.

Things WP-CLI Can Do:

  • Install, update, and configure WordPress core
  • Manage plugins and themes
  • Create and manage users
  • Import and export content
  • Run database operations and queries
  • Execute maintenance tasks at scale

Why WP-CLI Matters for Pantheon: Pantheon has WP-CLI pre-installed on all WordPress environments, and Terminus provides a seamless way to execute WP-CLI commands remotely. This means you can manage your Pantheon-hosted WordPress sites from your local terminal without SSH access or complicated server configurations. COOOL.

The Command Line Advantage for Pantheon WordPress

As a Pantheon Platinum Partner, we manage lots of WordPress sites across multiple environments for our clients. While Pantheon’s dashboard is powerful, clicking through multiple screens to perform routine tasks becomes time-consuming when you’re managing multiple sites and environments.

This is where Terminus—Pantheon’s official CLI tool—combined with WP-CLI becomes invaluable. Tasks that take 5-10 clicks in the dashboard become single-line commands that can be scripted, batched, and automated.

What You’ll Accomplish:

  • Execute WordPress commands directly on Pantheon environments
  • Investigate site configurations without logging into dashboards
  • Perform bulk operations across multiple sites
  • Troubleshoot issues faster with direct database access
  • Automate routine maintenance tasks

Prerequisites

Before starting, you’ll need:

  • A Pantheon account with site access
  • Basic command line familiarity
  • Terminal application (Terminal on Mac/Linux, PowerShell on Windows)

Installing Terminus

Step 1: Install Terminus CLI

Macs using Brew:

bash

brew install pantheon-systems/external/terminus

Linux/Mac using Composer:

bash

composer require pantheon-systems/terminus

Windows using Composer:

bash

composer global require pantheon-systems/terminus

Step 2: Authenticate with Pantheon

  1. Generate a machine token in Pantheon dashboard:
    • Go to Account > Machine Tokens
    • Click Create Token
    • Copy the generated token
  2. Authenticate Terminus:

bash

terminus auth:login --machine-token=YOUR_TOKEN_HERE
  1. Verify installation:

bash

terminus site:list

Important Permissions & Limitations

User Permissions:

  • You need site-level access or higher on Pantheon
  • Some commands will require admin privileges within WordPress
  • Environment-specific permissions apply (dev, test, live)

From Terminus’s perspective, each command runs in a single container execution. Each invocation boots WordPress independently—Terminus does not maintain a persistent session between commands. This means:

  • Each command is stateless
  • You can’t chain commands with session variables
  • Commands execute fresh each time

Understanding Terminus Command Structure

Basic Syntax:

bash

terminus wp SITENAME.ENVIRONMENT -- wp-cli-command

Here’s the breakdown

  • terminus is Pantheon’s CLI tool
  • wp  indicates this is going to be a WP-CLI command
  • SITE.ENVIRONMENT  is the target site name in Pantheon and its environment (dev, test, live)
  • --  is the separator between Terminus and the WP-CLI arguments
  • wp-cli-command is the actual WordPress command you wish to run
Free consultation

Or need WordPress support? We’ve completed 50+ migrations and can help you avoid the common pitfalls.

Commands for Site Investigation

When taking over a new website or planning for updates, these commands provide instant insights:

Get WordPress Core Version

A very basic command to try out!

bash

terminus wp knihter.dev -- core version

List All Plugins (Active and Inactive)

 See complete plugin inventory with activation status and version numbers.

bash

terminus wp knihter.dev -- plugin list

Find Plugins with Available Updates

Identify security and feature updates before planning maintenance windows.

bash

terminus wp knihter.dev -- plugin list --update=available

Check Database Size

 Monitor database growth and plan for optimization or upgrades. Perhaps there’s some bad bloat?

bash

terminus wp knihter.dev -- db size

List All Users

Audit user accounts for security reviews or client transitions.

bash

terminus wp knihter.dev -- user list

List Registered Post Types

Discover custom post types when inheriting a site or planning migrations.

bash

terminus wp knihter.dev -- post-type list

List Registered Taxonomies

Understand content organization structure for sites with custom taxonomies.

bash

terminus wp knihter.dev -- taxonomy list

Content Management Commands

Count Posts by Type and Status

Get content inventory statistics for planning migrations or cleanups.

bash

terminus wp knihter.dev -- db query "
SELECT post_type, post_status, COUNT(*) AS n
FROM wp_posts
GROUP BY post_type, post_status
ORDER BY n DESC;
"

List All Block Patterns

Inventory reusable blocks and patterns. Great for planning theme transitions.

bash

terminus wp knihter.dev -- post list --post_type=wp_block

Disable Comments on All Posts and Pages

Bulk disable comments when migrating to external comment systems or reducing spam.

bash

terminus wp knihter.dev -- post update \
  $(terminus wp knihter.dev -- post list --post_type=any --format=ids) \
  --comment_status=closed

Delete All Comments

Clean slate for sites transitioning comment systems.  Caution: This is permanent—backup first!

bash

terminus wp knihter.dev -- comment delete \
  $(terminus wp knihter.dev -- comment list --format=ids) \
  --force

Media Management Commands

List Media Files with Metadata

Audit media library for large files or outdated content.

bash

terminus wp knihter.dev -- post list \
  --post_type=attachment \
  --fields=ID,post_title,post_date,post_mime_type

Find Orphaned Attachments

Identify unused media files consuming storage space.

bash

terminus wp knihter.dev -- post list \
  --post_type=attachment \
  --post_parent=0

Regenerate Thumbnails (Dry Run)

Preview how many images will be affected before running regeneration. We usually just “go for it” and skip the try run.

bash

terminus wp knihter.dev -- post list \
  --post_type=attachment \
  --post_mime_type=image \
  --format=count

Regenerate All Thumbnails

Fix thumbnail issues after theme changes, image size modifications, or after switching to a web friendly image format like AVIF. Caution: Resource-intensive on large media libraries.

bash

terminus wp knihter.dev -- media regenerate

Database Maintenance Commands

Important Note: In Pantheon, database maintenance is largely managed. Databases are managed services with InnoDB tuning handled automatically. Manual optimization is rarely required.

List Database Tables with Sizes

Identify large tables for optimization or troubleshooting slow queries.

bash

terminus wp knihter.dev -- db tables

Show Database Table Prefix

Basic insights, verify the table prefix for custom queries or security audits.

bash

terminus wp knihter.dev -- db prefix

Count Post Revisions

Assess database bloat from excessive revisions.

bash

terminus wp knihter.dev -- post list --post_type=revision --format=count

Delete All Post Revisions

Reclaim database space and improve query performance. Caution: Consider revision history needs and backup everything before deleting.

bash

terminus wp knihter.dev -- post delete \
  $(terminus wp knihter.dev -- post list --post_type=revision --format=ids) \
  --force

Plugin Management Commands

Disable All Plugins

Essential for troubleshooting plugin conflicts or “white screen of death” issues.

bash

terminus wp knihter.dev -- plugin deactivate --all

Enable All Plugins

Re-enable plugins after conflict testing.

bash

terminus wp knihter.dev -- plugin activate --all

Advanced Commands

WARNING: These commands should NEVER be used on live environments without backups. We take no liability for data loss.

Change User Password by ID

 Emergency admin access when locked out.

bash

terminus wp knihter.dev -- user update 1 --user_pass=newpassword

Change User Password by Username

Reset user accounts quickly.

bash

terminus wp knihter.dev -- user update admin --user_pass=newpassword

Search and Replace in Database (Dry Run)

Preview search and replace changes before executing (domain migrations, SSL transitions). 

bash

terminus wp knihter.dev -- search-replace 'http://old.example' 'https://new.example' --dry-run

Delete All Trashed Posts

Clean up after bulk content removal or trash accumulation over time.

bash

terminus wp knihter.dev -- post delete \
  $(terminus wp knihter.dev -- post list --post_status=trash --format=ids) \
  --force

Delete All Posts of Specific Type

Remove obsolete custom post types instantly. Caution: This is destructive and fast—no undo!

bash

terminus wp knihter.dev -- post delete \
  $(terminus wp knihter.dev -- post list --post_type=post_type_target --format=ids) \
  --force

Delete Expired Transients

Clean up stale cached data without affecting active caches.

bash

terminus wp knihter.dev -- transient delete --expired

Delete All Transients

Force cache regeneration when troubleshooting caching issues.  Delete all transients from database, clear both site and network transients, force regeneration of cached values

bash

terminus wp knihter.dev -- transient delete --all

Flush Rewrite Rules

Essential after registering or changing custom post types or taxonomies. Fixes 404 errors on custom URLs.

bash

terminus wp knihter.dev -- rewrite flush

When to Use Terminus

Use Terminus for:

  • Bulk operations across multiple sites
  • Automated maintenance scripts
  • Database queries and investigation
  • Emergency troubleshooting
  • Repeatable processes

Use Pantheon’s Dashboard for:

  • Code deployments between environments
  • Backup management
  • Traffic and performance monitoring
  • Team collaboration and workflows
  • Visual site comparison

Need help optimizing your Pantheon WordPress workflow or managing complex multi-site environments?  Contact Knihter for professional Pantheon development and support services. As a Pantheon Platinum Partner, we specialize in advanced WordPress management and automation.

Related Services: