drupal Drush Drush commands


Example

Drush status

drush status

This will give you an overview of your Drupal site. Version, URI, database location, file paths, default theme etc. If you use this command and you do not see this information, it means you are in a wrong folder and Drush does not know which Drupal site you are referring to.


Resetting password for any user

drush upwd admin --password="newpassword"

Where "admin" is an existing username and "newpassword" is the desired password.


Generate a one time use admin login URL

drush uli

Generates a URL which can be used to login into the admin section. The URL has a one time use token. The result should look like this:

http://example.com/user/reset/1/1469178712/MEn1QOXo3YGKAUHCknFQF0rEPJ_itkS-a6I8LJwaNYs/login

Sometimes the hostname or IP is not resolvable, and the result is a warning like this:

default does not appear to be a resolvable hostname or IP, not starting browser.   [warning]
You may need to use the --uri option in your command or site alias to indicate
the correct URL of this site.
http://default/user/reset/1/1469178629/-zFS_0u8is2N2uCKuLUdGBpJ3cZzV9am5_irsbtVAOs/login

The solution is using the "--url" parameter like the following example:

drush uli --uri="http://example.com/"

Clearing the caches

drush cache-rebuild

Rebuilds the cache for Drupal 8. For drupal 7, you can use

drush cache-clear

These commands are also available shorter with

drush cr

or

drush cc // optionally pass all to clear all the caches

Enable modules

drush pm-enable mymodule

Enable 'mymodule' like activating a module in the admin interface

These commands are also available shorter with

drush en mymodule // optionally pass the -y option to avoid the interactive question 

Mainteneace

To enable the maintenance mode using Drush you can use this command:

drush vset maintenance_mode 1 // pass 0 to disable the maintenance

Remember to clear the caches after you have enabled / disabled the maintenance mode.