Skip to main content

Drush is a CLI tool that makes managing a Drupal site a very easy task. Here are some essential Drush commands that will help you while developing or debugging.

User

drush uli # Logs in default user
drush uli --name=john # Logs in user with username "john"
drush upwd <username> <password>
# Examples:
drush upwd admin "Admin@123456567" # This will make the password for admin "Admin@123456567"
drush user:block(unblock) # Block or unblock user
drush | grep user # Find user related Drush commands

Cache

drush cr # Rebuild all Drupal cache
drush cc css-js # Specifically clear css and js cache
drush cc bin # Choose a Drupal cache bin to clear (static, dynamic_page_cache, page etc)

General

drush si --existing-config # Install new site using existing configs from config folder
drush sql-cli # Opens an SQL shell
drush php # Opens in interactive PHP shell
drush site:ssh # Opens the site server shell
drush # Lists all commands
drush | grep <keyword you want to search for> # Find the right command

Generate code

drush generate # Generate boilerplate code
drush generate | grep field # Find the commands to generate code for field widget, formatter, type etc.
drush generate module # Generate code for a module like .info.yml, .routing.yml etc

These commands I use on a daily basis and to explore more just run drush without any arguments.

x

Work

Therefore logo
80 Atlantic Ave, Toronto, ON Canada
Email: hello@therefore.ca
Call us: +1 4166405376
Linkedin

Let us know how we can help!