Drush Cheat Sheet: 25 Essential Commands Every Drupal Developer Must Know

Drush Cheat Sheet: 25 Essential Commands Every Drupal Developer Must Know

Tired of clicking through Drupal’s admin UI for simple tasks? This ultimate Drush guide covers time-saving commands to manage content, users, cache, and even automate deployments. Perfect for beginners and pros!
Author
mcruzv
Time to read
10 min

What is Drush?

Drush (Drupal Shell) is a command-line tool that lets you control Drupal faster than using the GUI. It’s like Drupal’s Swiss Army knife – trusted by developers for backups, updates, and debugging.

[IMAGE PLACEHOLDER 1: "Terminal screenshot showing Drush logo + basic command"]


1. Installation & Setup

bash
Copy
# Install Drush globally (requires Composer):
composer global require drush/drush

# Verify installation:
drush --version

Note: On Pantheon/Acquia, Drush is pre-installed.


2. Core Commands

CommandWhat It Does
drush statusShows Drupal version, DB info, and paths
drush crClears all caches (Cache Rebuild)
drush updbRuns pending database updates
drush cronExecutes cron tasks manually

[IMAGE PLACEHOLDER 2: "Side-by-side comparison: Drush vs GUI time for cache clear"]


3. Content & Users

bash
Copy
# Create a new admin user:
drush user:create john --mail="[email protected]" --password="12345"
drush user:role:add administrator john

# Export all nodes:
drush entity:delete node

# Delete all nodes of type 'article':
drush entity:delete node --bundle=article

4. Module Magic

bash
Copy
# Install/uninstall modules:
drush pm:install webform
drush pm:uninstall devel

# List enabled modules:
drush pm:list --status=enabled

# Download a module (no GUI!):
drush pm:download pathauto

5. Advanced Power Moves

bash
Copy
# Generate a one-time login link:
drush user:login john

# Backup database + files:
drush sql:dump --result-file=../backup.sql
drush archive:dump --destination=../site-backup.tar.gz

# Run custom PHP code:
drush php:eval "echo \Drupal::token()->generate('site:name');"

[IMAGE PLACEHOLDER 3: "Infographic: Drush vs GUI efficiency stats"]


Pro Tips

  • Aliases: Manage multiple sites with drush @site1.dev status.
  • Scripting: Chain commands (e.g., drush cr && drush updb).
  • Debugging: Use -d for verbose output (e.g., drush -d cr).