Drush Commands

Mar 25, 2018 10:52 · 107 words · 1 minute read PHP Command Line

Every once in a while I still come across needing to use drush. Here are a few of the commands that have proven to be the most useful.

Setup a complete site from scratch:

drush dl --destination=$DRUPAL_DIR --drupal-project-rename=$DRUPAL_FOLDER_NAME -y
drush site-install standard --account-name=superadmin --account-pass=1234 --db-url=mysql://$DB_USER:$DB_PASS@localhost/$DB_NAME --root=$DRUPAL_ROOT -y
drush en $MODULES_ENABLE --root=$DRUPAL_ROOT -y
drush dis $MODULES_DISABLE --root=$DRUPAL_ROOT -y
drush genc 20 --types=article --root=$DRUPAL_ROOT -y
drush dl $ADMIN_THEME_VERSION --root=$DRUPAL_ROOT -y
drush vset admin_theme $ADMIN_THEME --root=$DRUPAL_ROOT -y
drush cc all --root=$DRUPAL_ROOT -y

Update Security patches only

drush upc --security-only

Reset password on account

drush upwd --password="testing" "username"

Create a user

drush user-create myusername

Grant a role

drush user-add-role administrator myusername