6197 comments
2357 subscribers
Follow me on Twitter (@sachac)
Subscribe! Feed reader E-mail

How to use Drush to download and install Drupal modules

One of the best things about building websites with Drupal is that there are thousands of modules that help you quickly create functionality.

To set things up, you need to download Drush and add it to your path. For example, you might unpack it into /opt/drush and then add the following line to your ~/.bashrc:

PATH=/opt/drush:$PATH
export PATH

Reload your ~/.bashrc with source ~/.bashrc, and the drush command should become available. If you’re on Microsoft Windows, it might need some more finagling. (Or you can just give up and use a virtual image of Linux to develop your Drupal websites. You’ll probably end up much happier. ;) )

Once you’ve installed Drush, what can you do with it?

Drush is a huge time-saver. For example, I install dozens of modules in the course of building a Drupal website. Instead of copying the download link, changing to my sites/all/modules directory, pasting the download URL into my terminal window after wget, unpacking the file, deleting the archive, and then clicking through the various module enablement screens, I can just issue the following commands to download and enable the module.

drush dl modulename
drush en -y modulename

(The -y option means say yes to all the prompts.)

So much faster and easier. You can use these commands with several modules (module1 module2 module3), and you can use drush cli to start a shell that’s optimized for Drush.

Drush is also useful if you’ve screwed up your Drupal installation and you need to disable themes or modules before things can work again. In the past, I’d go into the {system} table and carefully set the status of the offending row to 0. Now, that’s just a drush dis modulename.

Drush has a bucketload of other useful commands, and drush help is well worth browsing. Give it a try!

Short URL: http://sachachua.com/blog/p/21853
  • Pingback: Diverse drupal links « Radoeka's Blog

  • Davidis

    Thanks Sacha for this nice Drush intro.
    Is there a table somewhere with the modules list and their file names?

  • http://sachachua.com Sacha Chua

    No, but Drupal and Drupal Modules list many modules. You can look at the URL for the module name when downloading it. For example, the Content Creation Kit is at http://drupal.org/project/cck, so use cck as the module name for downloading it. Some modules have submodules, so you can look in the module directory or search for all the *.info files to find out how to enable them from the command line. Hope that helps!

  • Mahnster

    Um, for me anyway, it wasn’t

    PATH=/opt/drush;$PATH
    export $PATH

    but was

    PATH=/opt/drush;$PATH
    export PATH

    note there is no $ when doing an “export” on a variable.

  • http://sachachua.com Sacha Chua

    Oops! Thanks for catching that. Fixing!

  • Lu

    Can’t believe i lived for so long without using Drush…sniff. Thanks for sharing.

  • http://floatsolutions.com/ Aidan McQuay

    We need a drush emacs major mode ;)

  • Hanmant A Sapkal

    This is good man. Thanks for sharing drush uses

  • drupaler

    Hi, thanks so much. Your’s was the first tutorial that got drush working on my mac! It’s sooooo much quicker to set up drupal now.

    many thanks.

  • Dave

    Good tut, just one question. How do I do this:
    “To set things up, you need to download Drush and add it to your path. For example, you might unpack it into /opt/drush”

  • http://sachachua.com Sacha Chua

    Dave: Oooh, Drush now has even easier installation instructions. See the Drush project page.

  • John

    Great stuff. Thanks. I’m a Drupal7 newbie but Drush looks promising since I’ll be needing to automate tons of stuff on the development process.

  • http://www.facebook.com/fred.smith.5473894 Fred Smith

    I’ve been using Drupal for years and always did it via the GUI. I had problems updating to metatags beta 3 which is the first time I heard about drush as a way to get around it. The pear install simplifies the install of drush even further since it adds the path automatically.

    Will have to spend some time learning how to use it.

On This Day...

  • 2012: Buying time: Experimenting with scheduling — One of my business validation experiments has suddenly kicked into high gear. People love the sketchnotes I’ve been taking. Since [...]
  • 2011: Thinking about how to get even better at bulk-cooking — We like cooking in bulk. We find it to be an efficient way to make sure we’ve got healthy, [...]
  • 2009: Weekly review: Week ending November 8, 2009 — Last week was a high-energy week. Tuesday was networking-intensive: a breakfast meeting, a major presentation, and a speed-mentoring event. On [...]
  • 2008: Weekly review: Week ending November 9, 2008 — This week: Got ready for the second release of my Drupal-based project. Things are going well! Attended the Women in IBM Networking [...]
  • 2007: Other stuff — I like working from home. I set up my work laptop together with my personal laptop as something of a dual [...]
  • 2007: Kaizen: Tweaking my schedule — What’s the best way to spend your day? Today I experimented with my schedule again. Instead of waking up at 6 and [...]
  • 2006: It’s one of those blah days — I stayed up late last night and didn’t feel too well this morning. In fact, I ended up getting out of [...]
  • 2005: Emacs: It’s all about people — Kathy Sierra of Creating Passionate Users quotes Nat Torkington: “It’s no longer aspergers and emacs… we’re putting people back into the equation.” Why [...]
  • 2005: Free and open source programs — Looking for high-quality free and open source programs to help your Microsoft Windows-using friends make the switch? Check out LOOP: [...]
  • 2005: Brilliant idea! — I’m going to make this weekend Planner Documenting weekend. Kinda like the National Novel Writing Month‘s goal of just getting stuff out [...]
  • 2005: Emacs: Not bad, just misunderstood — People love dissing the Emacs text editor. Emacs is one of those arcane things that even _geeks_ aren’t expected to understand. [...]
  • 2004: My timestamping/thumbnailing script — #!/bin/bash while [ -n "$1" ]; do if [ -f $1 ]; then DATE=$(date +"%Y%m%d-%H%M%S" --reference="$1") [...]
  • 2003: Summary of today — Finished the draft of my article for Crossroads. Submitted it already, but haven’t received any confirmation yet. They’ll notify me of acceptance [...]
  • 2003: More emacs coolness – browse apropos — http://www.emacswiki.org/cgi-bin/wiki/BrowseAproposURL
  • 2003: Free NNTP — http://news.individual.net/ free Usenet (no binaries) Extremely good service, good spam filters
  • 2003: BlueJ and jikes — bluej.compiler.type=jikes bluej.compiler.executable=jikes
  • 2003: BlueJ robot world — http://www.rdv.vslib.cz/skodak/en/bluej/RobotWorld/index.html
  • 2003: New wishlist: The Passionate Teacher — http://www.amazon.com/exec/obidos/ASIN/0807031437/ref%3Dpd%5Fluc%5Fmri/103-8079128-4290215
  • 2003: BlueJ stats — http://cerg.csse.monash.edu.au/reports/BlueJ_1.htm
  • 2003: Guidelines for BlueJ — - Guideline 1: Objects first. - Guideline 2: Don’t start with a blank screen. - Guideline 3: Read code. - Guideline 4: Use [...]
  • 2003: The ACM competition — Judging the 2003 ACM ICPC Manila regionals was tons of fun. Although I was somewhat delinquent in terms of making problems [...]