drush presentation

 

What is drush?  "drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt."  You can use it to update modules, update the system, run SQL commands, and much, much more.

Where do I get it?  The website is drush.ws.  It is vital to understand that drush is NOT a Drupal module, and it is not anything which installs itself into Drupal as such.  It is a command-line tool which you install on the UNIX system which is hosting Drupal.  Well, originally just on UNIX systems: drush stands for "DRUpal SHell" meaning the bash shell, but it has since been ported to Windows and is coming closer to feature-parity all the time.

How do I use it?  Once you have drush installed on your system (or rather, your ISP's system), you invoke it at the command line from within your Drupal directory.  Some commands which affect the entire system (such as "drush update", which updates your entire Drupal install) are run from the root directory; other command which only affect modules (such as "drush dl cck" which downloads the CCK contributed module) are run from within the sites/all/modules directory.  If you are using Drupal 7 already, there is a nice chapter online.

From drupal site-root, type the following command:

http://130.212.75.70/workstation/sites/all/themes/acquia_marina/images/c...); ">

http://130.212.75.70/workstation/sites/all/themes/acquia_marina/images/o...); ">drush status

This will give you the status of your current site, including your Drupal version number, database connection type and status, default and administrative themes, and various other useful details.  You especially want to make sure that the paths to both Drupal and site roots are correct before running any updates.  Speaking of which, the very useful command to update your entire site, core as well as contributed modules and themes, is the following:

http://130.212.75.70/workstation/sites/all/themes/acquia_marina/images/c...); ">

http://130.212.75.70/workstation/sites/all/themes/acquia_marina/images/o...); ">drush up

Pretty simple, no?  Now let us download and install some modules.  For this you'll want to change directory to be in your default (<em>NOT</em> the core modules directory!) site's modules directory. Typically that is "sites/default/modules" (if you have created any custom sites you should probably know your way around the hierarchy of "sites" subfolders).  For our example, let's use a clean install of Drupal and download the Chaos Tools module.  This is what one might call a "good bad example" as it really isn't the first module one would begin with, as it has a number of dependencies, but that is precisely why we want to use it here.  We see right away that Chaos Tools in turn requires both Advanced Help (which we will want for sure) and Panels (which we might eventually want, but not right away).  So let's try a very different tack, a very likely first install line:

http://130.212.75.70/workstation/sites/all/themes/acquia_marina/images/c...); ">

http://130.212.75.70/workstation/sites/all/themes/acquia_marina/images/o...); ">drush dl admin_menu cck views filefield imageapi imagefield imagecache print vertical_tabs advanced_help

...which is a very respectable set of modules to begin with.  Now to show that it works for themes as well, let's issue the following:

http://130.212.75.70/workstation/sites/all/themes/acquia_marina/images/c...); ">

http://130.212.75.70/workstation/sites/all/themes/acquia_marina/images/o...); ">cd ../themesdrush dl zen

now let's head back to our modules section and install a module with a great many dependencies, to show how that might look, and how much more quickly we can resolve it:

http://130.212.75.70/workstation/sites/all/themes/acquia_marina/images/c...); ">

http://130.212.75.70/workstation/sites/all/themes/acquia_marina/images/o...); ">cd ../modulesdrush dl migratedrush en migrate


my cheat sheet:

  • drush status
  • drush up
  • drush dl <module-name>
  • drush en <module-name>
  • drush cron
  • drush help
  • drush cc     (clear cache)
  • drush pml     (module listing; you may want to |more on this one)

Some random links: