Abstract: 30 commonly used Drush Commands for Drupal. Drush is specific to Drupal. It’s a command-line shell and scripting interface designed specifically for managing Drupal websites. With Drush, you can perform tasks such as module management, cache clearing, database updates, and more, all from the command line, which helps streamline the workflow for developers and site administrators working with Drupal.

This list should help anyone new to Drupal Admin with the most frequent tasks related to Drupal management through Drush.

For more information on Drush follow the links below.
The Drush Command Dictionary lives here: https://www.drush.org/11.x/commands/all/

Core Drush Commands:

  1. Clear cache:

    drush cr
    • Purpose: Clears all caches.
  2. Check status:

    drush status
    • Purpose: Shows information about the Drupal site such as Drupal version, database status, and other configurations.
  3. Enable a module:

    drush en MODULE_NAME
    • Purpose: Enables a specific module.
  4. Disable a module:

    drush pm-disable MODULE_NAME
    • Purpose: Disables a specific module.
  5. Uninstall a module:

    drush pm-uninstall MODULE_NAME
    • Purpose: Uninstalls a specific module.
  6. Install a module (via composer):

    composer require drupal/MODULE_NAME
    • Purpose: Installs a new module using Composer.
  7. Update a module or Drupal core:

    drush up MODULE_NAME
    • Purpose: Updates the specified module or Drupal core.
  8. Database updates:

    drush updb
    • Purpose: Runs any pending database updates for modules or core.
  9. Run cron:

    drush cron
    • Purpose: Triggers the Drupal cron system.
  10. Create a user: bash drush user:create USERNAME --mail="user@example.com" --password="password"

    • Purpose: Creates a new user with a specific email and password.
  11. Block/unblock a user: bash drush user:block USERNAME drush user:unblock USERNAME

    • Purpose: Blocks or unblocks a user account.
  12. List installed modules: bash drush pm-list --status=enabled

    • Purpose: Shows all enabled modules.
  13. View all available updates: bash drush pm:security

    • Purpose: Shows any security updates for installed modules or Drupal core.
  14. Backup the database: bash drush sql-dump > backup.sql

    • Purpose: Backs up the database into an SQL file.
  15. Restore the database: bash drush sql-cli < backup.sql

    • Purpose: Restores the database from a backup file.
  16. Clear a specific cache: bash drush cache-clear PAGE_CACHE

    • Purpose: Clears a specific cache, such as PAGE_CACHE.

Drush Commands for Content & Config:

  1. Import configuration: bash drush config-import
    • Purpose: Imports configuration from YAML files.
  2. Export configuration: bash drush config-export
    • Purpose: Exports the entire site configuration to YAML files.
  3. Edit a configuration setting: bash drush config-edit CONFIG_NAME
    • Purpose: Edits a specific configuration item (opens the file for editing).
  4. View configuration: bash drush config-get CONFIG_NAME
    • Purpose: Displays the value of a specific configuration setting.
  5. Create new content: bash drush create-content TYPE --title="Title"
    • Purpose: Creates a new content entity (replace TYPE with content type, like article).
  6. List content: bash drush content-list
    • Purpose: Lists all content on the site.
  7. Delete content: bash drush entity:delete node --id=NODE_ID
    • Purpose: Deletes a specific content entity (node).

Drush Alias Management:

  1. Drush site aliases: bash drush site:alias
    • Purpose: Lists all available Drush site aliases.
  2. Use a specific site alias: bash drush @ALIAS status
    • Purpose: Runs Drush commands on a remote or different Drupal installation using its alias.

User Management Commands:

  1. Change password for a user: bash drush user:password USERNAME --password="newpassword"
    • Purpose: Changes the password for a specific user.
  2. Assign role to a user: bash drush user:add-role 'ROLE' USERNAME
    • Purpose: Assigns a role to a user.
  3. Remove role from a user: bash drush user:remove-role 'ROLE' USERNAME
    • Purpose: Removes a role from a user.

Other Useful Commands:

  1. Run PHP code: bash drush php-eval 'CODE'
    • Purpose: Runs PHP code on the fly.
  2. Watchdog log: bash drush watchdog:show
    • Purpose: Displays recent log entries.

This reference list should provide a solid foundation for using Drush effectively.

For more information on Drush follow the links below.
Drush Command Dictionary Lives Here:
https://www.drush.org/11.x/commands/all/

 

 

Primary Category
Confidentiality
No