Site Building
Topic

Drush for Drupal 7, 8, 9, and 10

Drush is a command line interface for your Drupal site. It allows you to perform common administrative tasks in a scripting environment. Using Drush you can do things like clear your cache, import configuration settings, create new users, and enable modules from the command line. Once you become familiar with Drush you will find yourself doing a lot less clicking through your site's backend during development.

Install Drush with Composer:

composer require drush/drush

Example tasks

  • Perform common site administration commands from the command line.
  • Speed up and improve your daily development workflow.
  • Automate common repetitive manual tasks (like importing configuration files) during the deployment process.

Confidence

Our Drush tutorials have been updated and tested with the latest version of Drush. Some tutorials have alternative commands for Drush 8 (an older version of Drush, before major API changes were implemented).

Drupalize.Me resources

More information

While the administrative UI for Configuration synchronization certainly provides a simple and effective means to export and import configuration, it is by no means the preferred method. The Drush command line utility provides the same functionality without the need for a web interface or the need to log in.

More information

There are some administrative UI tools for managing configuration, but some tasks can only be completed with Drush. As a site administrator, you will find Drush an indispensable tool for managing configuration between instances of the same site. Furthermore, Drush includes integration with Git in certain commands, enabling you to create a configuration workflow with Drush that also uses best practices in version control.

By the end of this lesson you should be able to:

  • Get the status of a site's configuration
  • List configuration on a site
  • View configuration objects
  • Set values for a specific key inside a configuration object
  • Edit a configuration object in active configuration without needing a configuration form
  • Integrate a Git workflow with Drush
More information

In this tutorial we will run a site migration using Drush, and understand how to deal with any failures that occur.

Guides

Not sure where to start? Our guides provide useful learning tracks for all skill levels.

Navigate guides

External resources

  • Installation documentation (drush.org)
    • This is the official installation documentation for the various versions of Drush.
  • All Drush documentation (docs.drush.org)
    • This will illustrate the various Drush commands you can use once you have the tool installed and available on your system.
  • drush-ops/drush GitHub repository (github.com)
    • This is where the actual Drush codebase and issue tracker live. The documentation available here in the README.md contains links to the installation and general documentation mentioned above, as well as several additional resources.
  • Drush Commands (drushcommands.com)
    • A community resources with Drush commands from various versions, including commands added with popular contributed modules. (Commands new to Drush 10 are probably not going to be listed here. But there's a lot of overlap between Drush 9 and 10.)