Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Useful Drush commands

By editor , 11 January, 2016

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 "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

 

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 system.site
#Get front page
drush cget system.site page.front
#Set front page
drush config-set system.site 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 site.section.page.title 'My page title'


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

Update Database (/update.php)
drush updatedb

http://drushcommands.com/

Tags

  • Drupal 8
  • Drupal 7
  • Drush
  • Shell
Install and Update Drush on Linux
Install drush on Widows
Execute a drush command programmatically
Create a custom DRUSH command on drupal 8
Install drupal 8, modules and themes from Drush.

Comments

Plain text

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

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer