How to Get Started with Drush
Drush and Drupal have co-mingled as trusted companions for more than a decade. Drush can be used to set up Drupal, maintain it, and deploy it.
Drush is a command line shell and Unix scripting interface for Drupal. It runs update.php, executes SQL queries, runs content migrations, along with utilities such as cron or cache rebuild.
The word Drush is a combination of two words: Drupal + Shell. A shell is a command line tool for simplifying the management of websites by writing commands.
Why Use Drush
Here are the main advantages of using Drush:
- Drush expedites development. Using the interface you need to load pages, click on menus, and look for the information. With Drush, you look for a command using Drush help, and that’s it.
- Drush is faster for PHP to execute. No need to load the website interface, it goes straight to PHP, no browser needed.
- Drush enables automation. With Drush, you can make a script to enable 10 modules in a row, apply some updates, clear the cache, and much more. Any command from Drush can be made as part of a script.
Interested in a side-by-side comparison -- without Drush/without Drush -- in executing common Drupal development tasks.
Enabling a Module without Drush
- Click the ‘Extend’ link in the admin toolbar or go to /admin/modules.
- Find the module/s and check the boxes next to them.
- Click ‘Install’ button at bottom
Enabling a Module with Drush
$ drush pm-enable modulename
Note that "modulename" is referring to the module’s machine name, as in the module’s URL.
Example: the machine name of the “Pathauto” module is pathauto, it’s URL is
The command “pm-enable” can also be shortened to “en.”
Disabling a Module without Drush
- Go to ‘Extend > Uninstall module’ in the admin toolbar or go to /admin/modules/uninstall
- Find the module/s and check the boxes next to them
- Click ‘Uninstall’ button at bottom
- Confirm you want to uninstall this module on the next page
- This process could take a while because each module that is dependent on another module needs to be uninstalled before the dependent module can be uninstalled. So, this process could take 10 mins or more if you are just using the UI.
Disabling a Module with Drush
$ drush pm-uninstall modulename
This is a huge time saver in the case where there are dependencies involved because Drush can be instructed to simply uninstall the module. If there are other modules requiring that module they will all be uninstalled automatically in the correct order. The command “pm-uninstall” can also be shortened to “pmu.”
Logging into Drupal without Drush
- If you have forgotten your password you need to go to the /user/password page and put in your email and submit. Then wait for an email to arrive in your email client. Then click on the reset link to be taken to the site and be automatically logged in.
- If the credentials are documented in a project doc or a password manager, then you need to go hunt down that username and password for this environment, or you might need to log in to the password manager and then come back to the site you want to log into and then enter the credentials at /user/login page.
Logging into Drupal with Drush
To login as user 1 superuser.
$ drush user-login
To login as a specific user
$ drush user-login ryan
The command “user-login” can also be shortened to “uli.”
Drush is extremely popular and stable among Drupal developers. As of April 19, 2023, the Drush packagist project had been downloaded 28,248,891 times.
As of April 19, 2023, the Drush packagist project had been downloaded 28,248,891 times.
How to Install Drush Using Composer
The recommended method for installing Drush is using Drush is to use Composer because it will be easier to keep Drush up to date. Composer will manage Drush as a dependency.
$ composer require drush/drush
To test if you have successfully downloaded and installed Drush, open your terminal and type
$ drush list
You should see a long list of Drush commands along with descriptions of what each of the commands does. You can shorten the list of Drush commands and target specific results with the help of “grep” and keywords.
For example, if you are looking for commands associated with the webform module, you can filter by the keyword “webform.”
$ drush list –filter=webform
Drupal Console vs. Drush
Drupal Console became popular with Drupal 8. It has similar functionality as Drush, but the focus is different.
Drush was introduced for Drupal 4.7 has been in use by developers since 2006. Multiple options have been made available during that time.
Drush aims at helping the site builder with regular maintenance or administrative tasks.
Drupal Console, on the other hand, is newer and focuses more on helping developers. Some administrative tasks such as enabling a module can done within Drupal Console, but not nearly as many as within Drush.
Drupal Console, however, is capable of generating PHP code, which is more helpful for developers than for maintenance tasks. The two can work together, and there is the option of installing both.
Interested in learning more about the relative benefits of Drupal Console vs. Drush, or the big-picture of Drush advantages in the set up, deployment, and maintenance of Drupal sites?
Check out Promet’s Drupal training and sign up!