← back to the blog

Drush commands you need to know

Posted on March 24th, 2019 in Drupal by George

Drush is a command line shell for Drupal. Drush has commands for interacting with code like modules, themes, and profiles in Drupal.

Drush will also execute sql queries and DB migrations.

The most useful command for me is clearing the cache  with : (cr stands for cache-rebuild)


drush cr


A second most useful command is drush status:

drush status

Drush status command

Drush status is returning very useful information regarding your setup.

As you can see in the image above, this is an example with the output generated by drush status on a windows machine where the environment is running on WAMPServer. If you don't know what WAMP is, check this link http://www.wampserver.com/en/ 

The status command is returning pieces of information about the version of Drupal for the instance you are querying. You can see de default theme, default admin theme, where from and which version of PHP is used, the OS, the version of drush which in this care is 9.6 the root of the Drupal instance and misc.


sql:conf     Print database connection details.

      sql:connect  A string for connecting to the DB.

      sql:create   Create a database.

      sql:drop     Drop all tables in a given database.

      sql:cli      Open a SQL command-line interface using Drupal's credentials.

      sql:query    Execute a query against a database.

      sql:dump     Exports the Drupal DB as SQL using mysqldump or equivalent.

      sql:sync     Copy DB data from a source site to a target site. Transfers data via rsync.

      sql:sanitize Sanitize the database by removing or obfuscating user data.


Drush has many commands allowing Drupal fields manipulation or managing Drupal users creation, deletion, adding and removing roles https://www.drupal.org/docs/user_guide/en/user-new-role.html or just getting user information.


Create a new user account with the name newuser, the email address newuser@example.com, and the password letmebe

drush user-create newuser --mail="newuser@example.com" --password="letmebe"