Useful Drush commands | Drupal 8

Useful Drush commands

Submitted by editor on Mon, 01/11/2016 - 16:28

To handle drupal with drust, First of all, you must install drush, and execute drush command from your drupal instalation folder.

  • For default or single site instalation, just put on drupal root folder (Ex : /var/www/drupal8)
  • For Multi sites, put in to the site folder (Ex : /var/www/drupal8/sites/mysite1)


First command : Status
drush status

Download and active a module
drush en module_name -y

Clear All Cache
On D7 # drush cc all
On D8 # drush cr

Get a user login url ( Tempory)
drush uli
drush uli [user_id]
#Set a user password (Here : USER=admin)
drush upwd --password="new admin password" "admin"

Set / Change User password
drush upwd USERNAME --password="The_New_Password"
Example : drush upwd admin --password=admin

Set / Get Variable and configuration

Drupal 7
variable-set (vset)
drush vset variable_name value
Example : drush variable-set stage_file_proxy_origin ""

Drupal 8
drush config-set config_name field value
Example : drush config-set stage_file_proxy.settings origin '' -y


Update disabled modules using Drush

The option --check-disabled Check for updates of disabled modules and themes. This allow you to update modules and themes codes even disabled.
The option --lock allow to exclude a module
Example :
drush up; # Update codes and database
drush upc; # Update codes only
drush updb; # Update database only

drush pm-update --lock=MODULE_TO_EXCLUDE
drush pm-updatecode --check-disabled
#OR, shortcut :
drush upc --check-disabled

NOTE :  To avoid accidentally update and show the list before update, Do not use the option -y.


Get Set Variables / State (set-state / get-state)

Put the site in maintenance mode : Put Site Online / Offline
drush sset system.maintenance_mode 1 // To set
drush sget system.maintenance_mode // To check
drush sset system.maintenance_mode 0 // To Exit maintenance mode
Linke on drupal 7 : drush vset maintenance_mode 1

Get / Set Configuration

#Get site title
drush cget
#Get front page
drush cget page.front
#Set front page
drush config-set page.front my-new-front-page
#Set a custom config's value. Ex:  configname=mumodule.settings, key is ['site']['section']['page']['title'] = 'My page title'
drush cset mumodule.settings 'My page title'

( for More info)

Update Database (/update.php)
drush updatedb


Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.