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:

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!

One Pingback/Trackback

  • 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?

  • 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, 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

    export $PATH

    but was

    export PATH

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

  • Oops! Thanks for catching that. Fixing!

  • Lu

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

  • 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”

  • 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.

  • 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.

  • Mike

    Hi Sacha,
    I just ran across your site looking for information about Drush commands and started perusing your other post, you have a nice site… I could use some help with Drush, I’ve got it install and it works, but I’m completely confused about setting up an aliases file so I can upgrade one of my sites from Drupal 6 to Drupal 7… I know this post is old but Im hoping you can help.
    Thank you…

    • You don’t need drush aliases if you’re using the drush command on the server that the site is on (assuming you aren’t running multisite?). For upgrading, you may want to copy your site to a development or staging environment, upgrade it there, and then redeploy. Lots of things are likely to break in a major version upgrade, so it’s good to isolate that. =)

      • Mike

        Hi Sacha,

        Thank you for the quick response., I do have multiple sites on the server…

        So, now I’m even more confused., because when I run the Drush command site-upgrade it comes back and tells me “No target argument specified. To perform the site upgrade, define an alias record for the target site.”

        So, maybe I have something messed up?
        Thank you again for your help….

        • Ooh, hey, I didn’t know about the site-upgrade command – beato! Yes, you do need to set up an alias for that one. has details. Looks like you need to create a new empty site that Drush will copy the upgraded site to.

          • Mike

            Yea, I actually found that post a while ago, but the whole process still doesn’t make sense to me.., I really need someone to really spell it out for me, cause it’s driving me crazy….

  • Joe

    Hi Sacha,
    I know this is an old thread but it helped me this week! To say ‘thank you’ I want to post the gist that I created , so it might help others. Here is the link