Skip to content

Instantly share code, notes, and snippets.

@alienresident
Last active July 1, 2021 23:28
Show Gist options
  • Save alienresident/9237479 to your computer and use it in GitHub Desktop.
Save alienresident/9237479 to your computer and use it in GitHub Desktop.
Useful Drush Commands

Drush Shortcuts

A list of Drush shortcuts I find useful for Drupal development.

Dealing with Users

Creating a one-time login link

drush uli

Creating Users and Changing Passwords

drush user-password admin --password="Pa$$w0rd"
drush user-create bobsmith --mail="[email protected]" --password="Pa$$w0rd"

Adding and Removing Roles

drush user-add-role 'Administrator' --uid=17
drush user-remove-role 'Administrator' --uid=10

Dealing with Modules

Download Module to a Custom Destination

drush dl link --destination=/MyCustom/path/drupal/sites/all/modules_available/contrib -y

Enable Module From Outside of the Site Directory

drush en google_fonts --uri=http://localhost/mylocalsite -y

List all projects with available updates using Drush

From this Blog Post that goes into detail.

drush vset update_check_disabled 1 -y && drush --simulate --pipe --no up

List Modules and Find One

drush pml | grep 'diff'

List Symlinks to Modules and Download them to a Custom Destination

drush dl `\ls | tr '\n' ' '` --destination=/MyCustom/path/drupal/sites/all/modules_available/contrib -y

Features

Update Feature

drush fu feature_name

##Clearing Cache

Clear All Cache

drush cc all -y

Clear Cache Multisite outside the Site Directory

drush cc all --uri=http://localhost/mylocalsite -y

Changing Variables

Site Maintenance

Turn off CSS aggregation

drush vset preprocess_css 1 --yes

Turn site offline

drush vset site_offline 0 -y

Turn site back online

drush vset site_offline 0 -y

Set Install profile to default

drush vset install_profile standard

Updating Drupal

Update Drupal Core

drush up

Run Database Updates

drush updb

Theme Stuff

Status of the Site's Themes

drush status theme

List Themes

drush pm-list --type=theme

List Enabled Themes

drush pm-list --type=theme --status=enabled

Set the Default Theme (to mytheme)

drush vset theme_default mytheme -y

Set the Admin Theme (to rubik)

drush vset admin_theme rubik -y
Use the Admin theme for Content Editing
drush vset node_admin_theme 1 -y
@eckmo
Copy link

eckmo commented Jul 1, 2021

This is so useful, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment