LinuxCommandLibrary

drush

Manage Drupal websites from the command line

TLDR

Enable module "foo"

$ drush en [foo]
copy

Uninstall module "foo"
$ drush pmu [foo]
copy

Clear all caches
$ drush cr
copy

Clear CSS and JavaScript caches
$ drush cc css-js
copy

SYNOPSIS

drush [global-options] <command> [<argument>...] [-- <command-options>]

PARAMETERS

-r, --root=<path>
    Drupal root directory

-l, --uri=<uri>
    Site URI (e.g., example.com)

-u, --user=<id>
    Run as specific user ID

-v, --verbose
    More verbose output

-d, --debug
    Debug mode with full backtrace

-y, --yes
    Assume yes to all prompts

-n, --no
    Assume no to all prompts

--cache-clear
    Clear bootstrap caches

-h, --help
    Show command help

--version
    Show Drush version

--php=<path>
    Path to PHP executable

--backend
    Backend invoke (machine-readable)

-vvv
    Very verbose output

--simulate
    Simulate actions without changes

--include=<path>
    Include directory for commands

DESCRIPTION

Drush (DRUpal SHell) is a powerful command-line interface for managing Drupal websites. It enables developers and administrators to perform tasks like module installation, cache clearing, database updates, configuration exports, and site backups directly from the terminal.

Key benefits include speed, automation scripting, remote site management via SSH, and integration with Drupal's APIs without a web browser. Drush bootstraps Drupal environments, supports multisite setups, and offers tab-completion for commands and arguments. It's compatible with Drupal 7 through 10+, with Drush 12 being the latest major version.

Essential for workflows, Drush reduces GUI dependency, supports Drush Make (legacy) for build recipes, and includes extensions like Drush Launch Queue. Usage starts with global options for site targeting, followed by subcommands like cr (cache-rebuild) or pm:enable.

CAVEATS

Requires Drupal installation and PHP >=7.4. Version must match Drupal core (e.g., Drush 12 for Drupal 10). Not all commands available in all versions; test in non-production. Composer recommended for install.

INSTALLATION

Via Composer: composer global require drush/drush. Add ~/.composer/vendor/bin to PATH. Verify: drush --version.

COMMON COMMANDS

drush cr - Cache rebuild
drush pm:enable <module> - Enable module
drush updb - Run database updates
drush config:export - Export config.

ALIASES

Define site aliases in drush/sites.php for remote ops: drush @site status.

HISTORY

Released in 2007 by Moshe Weitzman for Drupal 6. Evolved with Drupal: major rewrite for Drupal 8 (Drush 8, 2015). Drush 10/11 for Drupal 9/10; Drush 12 (2023) adds PHP 8.2 support. Community-maintained via GitHub.

SEE ALSO

composer(1), php(1), git(1)

Copied to clipboard