The Power of Drush - for beginners

  • Posted on: 8 August 2015
  • By: Julia

Normally I'm not a command line kind of gal, I can use it but prefer clicking on brightly coloured buttons, dragging and dropping and generally living in the 21st century. For Drush I make an exception, beyond straight forward and each line is supercharged, it's definitely the way to go for both site creation and module / theme installation (creating your sub-themes too). Drush is more than just a tool - it's a powertool!

So what is Drush?

Drush is a mighty powerful command line shell for Drupal - it will save you time and heartache, comes with many out-of-the-box commands, an ever growing number of commands for contributed modules and, well hey - if you can't find you want, and are sick of repeating yourself, you can write your own (official guide here or use a walkthrough). This is a command line tool that really does save you time, even if you just learn a few basic commands.

Installing Drush

As Drush never really was a Drupal module as such the project page will tell you it's moved to git, but you can still view and download releases here and hopefully that'll be the last time you have to click to download from Drupal.org. The heroes at Drupal have also provided an installation guide with specifics for a variety of platforms (including initial Composer install how to).

Some things Drush can do

If you're new to Drush and want to see what it can do try it out by downloading, enabling and updating modules thus:

$ drush dl views [downloads Views, if you don't have Ctools installed it'll offer to install that too!]

$ drush en views [enables that Views module you've just downloaded]

Or download and enable in one step:

$ drush dl views -y [see what you did there? - no going to the project page, clicking on the download, extracting the module, moving it where it should go, going to the modules page, clicking enable, clicking submit, then repeat for ctools, which will now let you go back to the module page and click on enable, then click on submit]

$ drush dis views [you've changed your mind and are disabling that Views module you just installed]

$ drush pm-uninstall views ctools [Let's uninstall Views and Ctools - yes, you can specify multiple modules]

$ drush pm-update [update core, modules, themes]

$ drush updb [performs any pending updates, forget that pesky update.php]

A few other things with Drush

$ drush status [provides an overview of the site you're in]

$ drush cc [prompts you to see which cache you'd like to clear right now]

$ drush cc all [clears all caches]

$ drush sql-dump > /path/to/my/backup/directory/mydumpfile.sql  [exports your database to a sql file in a specified location]

$ drush ws [see watchdog errors and warnings]

$ drush cron [you guessed it]

I promised you a sub-theme install

$ drush dl zen [download zen theme]
$ drush en zen [enable zen theme]
$ drush cc all [clear all caches]
$ drush zen "subtheme name" machine_name --description="My sub-theme Description." --without-rtl [creates the sub theme - now that was easy wasn't it]

Drush Commands

You can find a list of Drush commands here

Some guides for beginners from someone who loves Drush and someone to help you start right from the beginning, plus Drupal again with a command reference.

Got to go - I'm in a drush ... (sorry)