49

To download and install a module, I run:

drush dl module_name
drush en module_name -y

I put that in a Bash script function, and just call "drin module_name" to simplify.

function drin(){
  drush dl $1
  drush en $1 -y
}

Is there a one-line command in Drush to download and enable a module?

2
  • There is a proposal for several improvements in download and enable. See this issue drupal.org/node/1364814
    – jonhattan
    Commented Feb 8, 2013 at 9:18
  • There is an update in the latest drush that does this. See new selected answer. Thanks!
    – radj
    Commented Nov 5, 2013 at 7:19

5 Answers 5

86

The following will download and enable the module:

drush en module_name -y

Edit: The download (dl) command is not needed. When trying to enable a module that is not downloaded yet, Drush will ask if you want to download it and then ask if you want to enable it. The -y automates the "yes" answers to these questions.

This was added in Drush 6.0.0 (#1364814 by eiriksm, jonhattan: Added Extend pm-enable to offer downloading the project for missing extensions.)

7
  • Can you expand on how this is different than the other answers?
    – mpdonadio
    Commented Oct 30, 2013 at 22:29
  • 2
    I think this is a new implementation. At the time I posted this QA, this was not possible.
    – radj
    Commented Nov 5, 2013 at 7:17
  • 1
    This didn't work for me, using a fresh install of drush from the repository.
    – RevNoah
    Commented Nov 19, 2013 at 19:06
  • 2
    This didn't work. I tried the following: drush en schema -y and got this: schema was not found and will not be enabled. [warning] There were no extensions that could be enabled. [ok]
    – cdmo
    Commented Jun 12, 2014 at 15:23
  • 1
    Okay, this approach works fine on Drush 6.3.0.
    – cdmo
    Commented Jun 12, 2014 at 17:35
18
drush dl module_name && drush en module_name -y
3
  • 1
    Thanks for this but this is the same as typing in the commands twice, or using a semi-colon to separate them. I was looking for an actual drush subcommand.
    – radj
    Commented Feb 8, 2013 at 12:44
  • Yes though your original question, before you edited it, was asking for a "single line solution" which it is. Commented Feb 8, 2013 at 23:34
  • Yeah, I know. I'm sorry about the confusion. That's why I edited it to clarify and not mislead the next contributors.
    – radj
    Commented Feb 9, 2013 at 0:55
7

Downloading and enabling a module can be done with drush en project_name. It asks for a confirmation; if you don't want to confirm, use the -y parameter.

drush en project_name -y

You can download more projects with the same command.

drush en rules views token -y

For a list of some basic Drush commands see Basics drush commands.

1
  • 1
    Yes, 'drush en' works with more recent versions of drush Commented Nov 26, 2014 at 5:53
2

In Drush 9, you download a module with composer require drupal/module_name.

See the new documentation for Drush 9 on drush pm:download.

After, you will need to enable the module with drush pm:enable module_name.

*Other useful commands for modules are:

  • See all the modules installed

    drush pm:list
    
  • Uninstall a module

    drush pm:uninstall module_name
    
0

in Drupal 8 you no longer use Drush. Use composer require drupal/module_name instead.

2
  • This downloads it but does not enable it. How do I enable it in command line for D8?
    – Christia
    Commented Apr 23, 2019 at 10:21
  • 1
    @kiamlaluno I am not sure why it was necessary to edit my comment since there was no substantive change in what you edited. In fact, by changing it you took the command out of its own element which allows users to double click on it to copy and paste it, which was the whole point in why I placed it in a code element in the first place. I understand you're a moderator, but I fail to understand your reasons here.
    – Jason
    Commented Dec 13, 2019 at 14:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.