Running Commands
This guide covers the commands available via SSH on your staging environment.
Interactive Mode
Connect without a command to enter an interactive shell:
ssh mysite-staging@ssh.myscalablesite.com
You'll get a wp-shell> prompt where you can run multiple commands without reconnecting:
WordPress Restricted Shell
Type 'help' for available commands, 'exit' to quit.
wp-shell> wp plugin list
wp-shell> composer show
wp-shell> exit
Single Command Mode
Run a single command and exit:
ssh {slug}-staging@ssh.myscalablesite.com 'command here'
Replace {slug} with your site's slug.
File Operations
Listing Files
# List files in WordPress root
ssh mysite-staging@ssh.myscalablesite.com 'ls -la'
# List plugins
ssh mysite-staging@ssh.myscalablesite.com 'ls -la wp-content/plugins/'
# List themes
ssh mysite-staging@ssh.myscalablesite.com 'ls -la wp-content/themes/'
Viewing Files
# View a file
ssh mysite-staging@ssh.myscalablesite.com 'cat wp-config.php'
# View with line numbers
ssh mysite-staging@ssh.myscalablesite.com 'cat -n wp-content/themes/mytheme/functions.php'
WP-CLI
WP-CLI is the command-line interface for WordPress.
Plugin Management
# List all plugins
ssh mysite-staging@ssh.myscalablesite.com 'wp plugin list'
# Install a plugin
ssh mysite-staging@ssh.myscalablesite.com 'wp plugin install woocommerce'
# Activate a plugin
ssh mysite-staging@ssh.myscalablesite.com 'wp plugin activate woocommerce'
# Update all plugins
ssh mysite-staging@ssh.myscalablesite.com 'wp plugin update --all'
# Deactivate and delete a plugin
ssh mysite-staging@ssh.myscalablesite.com 'wp plugin deactivate hello && wp plugin delete hello'
Theme Management
# List themes
ssh mysite-staging@ssh.myscalablesite.com 'wp theme list'
# Activate a theme
ssh mysite-staging@ssh.myscalablesite.com 'wp theme activate flavor'
Database Operations
# Export database to local file
ssh mysite-staging@ssh.myscalablesite.com 'wp db export -' > backup.sql
# Search and replace (useful for domain changes)
ssh mysite-staging@ssh.myscalablesite.com 'wp search-replace "old-domain.com" "new-domain.com" --dry-run'
# Run the replacement (remove --dry-run)
ssh mysite-staging@ssh.myscalablesite.com 'wp search-replace "old-domain.com" "new-domain.com"'
User Management
# List users
ssh mysite-staging@ssh.myscalablesite.com 'wp user list'
# Create a user
ssh mysite-staging@ssh.myscalablesite.com 'wp user create bob bob@example.com --role=editor'
# Reset a password
ssh mysite-staging@ssh.myscalablesite.com 'wp user update admin --user_pass=newpassword'
Cache Management
# Flush object cache
ssh mysite-staging@ssh.myscalablesite.com 'wp cache flush'
# Flush rewrite rules
ssh mysite-staging@ssh.myscalablesite.com 'wp rewrite flush'
WooCommerce Commands
# List orders
ssh mysite-staging@ssh.myscalablesite.com 'wp wc shop_order list --user=1'
# Update stock
ssh mysite-staging@ssh.myscalablesite.com 'wp wc product update 123 --stock_quantity=50 --user=1'
WP-CLI Documentation
For the full list of WP-CLI commands, see the WP-CLI Command Reference.
Composer
Manage PHP dependencies with Composer.
# Install dependencies
ssh mysite-staging@ssh.myscalablesite.com 'composer install'
# Update dependencies
ssh mysite-staging@ssh.myscalablesite.com 'composer update'
# Require a new package
ssh mysite-staging@ssh.myscalablesite.com 'composer require vendor/package'
# Show installed packages
ssh mysite-staging@ssh.myscalablesite.com 'composer show'
Composer on Production
Composer changes on staging need to be deployed to production via the normal deployment process. Running composer install on staging doesn't affect production.