What is Drush? What is Drush used for?

This tutorial is valid for Drush v.7 for Drupal v.7 and v.8

The name Drush stands for DRUpal SHell. Drush is a command line utility you can use to communicate to your Drupal CMS.

You can use Drush to manage Drupal and:

  • Detect errors and issues and fix them
  • Bypass using the interface when the Drupal backend is unavailable
  • Do regular maintenance and updates

This article lists several useful commands for you, but the list is non-exhaustive. Click on the link to explore more Drush commands.


How do I use Drush?

Drush is installed on all Webhosting packages in Combell. All you have to do is connect to the account via SSH. For Windows you can use a free SSH client such as Putty. For Linux and Mac, simply use your terminal.

All of the following Drush commands have to be executed from the directory where your Drupal website is installed. To change the current directory, simply use the cd command, for example:

cd www/ 

General commands in Drush

Install Drupal with Drush

This will install a blank Drupal website in the directory you execute it from.
Please have in mind this will only work for users with root access, and not for shared hosting. Shared hosting users can simply use the CMS installer in the control panel

drush site-install --db-url=mysql://root:pass@localhost:port/dbname

Drush status

The following command gives information about the website in the current directory such as the Drupal version, database information, theme, settings file and PHP configuration.

drush status

Clear Drupal cache

drush cc all

User management commands in Drush

Create standard user

This command will create a new user with username “username” with standard permissions and with the specified e-mail address and password.

drush user-create username --mail="email@example.com" --password="password"

Delete user

This command will delete the user with the specified username – in this case “username”.

drush user-cancel username

Edit administrator password

This command will edit the password for the user “admin” and will set it to “new_pass”

drush user-password admin --password="new_pass"

Log in as admin via special URL

This command generates a single sign-in link to log in with admin rights via an http address. Copy and paste the generated URL in your browser and you will immediately be taken in the administrative area of your Drupal, as an admin. You can edit the admin password and any other details.

drush uli -l yourdrupaldomainname.extension

Database commands in Drush

Empty database

This command will empty the database associated with your Drupal website in the current folder.
!Caution This action will disable your website.

drush sql-drop

Export database via Drush

Use the following command to generate a database export with the current date as the file name.

drush sql-dump | gzip --stdout > $(date +\%Y-\%m-\%d-\%H-\%M-\%S).sql.gz

Import database via Drush

Use the following command to import an sql dump with name “dump.sql” in your Drupal database. Tip: If you are testing importing the file from the previous step, make sure you unzip it first, using the command gunzip

gunzip dump.sql.gz
drush sql-cli < dump.sql

Update Drupal via Drush

Discover available updates for Drupal via Drush

Use the command below to look for new available versions of Drupal

drush up -n | grep available

Updates in Drupal via Drush

Use the command below to update the core / module / theme in both the code and the database

drush up

For example the following will update the drupal core.

drush up drupal

Use the command below to update the core / module / theme in the code but not in the database.

drush upc

Use the command below to update the core / module / theme in the database but not in the code.

drush updatedb
Updated on 2 June 2021

Was this article helpful?

Need support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact support

Couldn't find a solution?


Our specialists are available 24/7 to provide you with free support. Feel free to contact Joachim and his colleagues via e-mail or by phone.

Joachim Coessens Specialist Support