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 / 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 "http://www.drupal8.ovh"

Drupal 8
config-set
drush config-set config_name field value
Example : drush config-set stage_file_proxy.settings origin 'http://www.drupal8.ovh' -y

 

Install drupal from drush

drush dl drupal --drupal-project-rename=example
cd example
drush site-install standard --db-url='mysql://[db_user]:[db_pass]@localhost/[db_name]'
Options
--site-name=Example --account-name=admin --account-pass=adminpassword

Example 2 : Install drupal 8 using sqlite database
drush site-install standard --db-url='sqlite://sites/default/files/.ht.db.sqlite' --site-name=D8 --account-name=admin --account-pass=admin --notify=0

Enable few usefull contrib modules.

drush en workbench workbench_moderation youtube imce linkit captcha honeypot securelogin pathauto -y
drush en admin_toolbar admin_toolbar_tools -y

Enable drupal development modules.

drush en devel kint coffee features features_ui -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.
Example :
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

(http://drushcommands.com/drush-8x/core/site-install/ for More info)

Update Database (/update.php)
drush updatedb

http://drushcommands.com/

Add new comment