Viewers: in countries Watching now:
Manage your Drupal sites even more efficiently with Drush, the shell interface for managing and scripting Drupal site development. In this quick course, author Jon Peck describes what Drush is, how to install it, and how to use it effectively for everyday—and exceptional—tasks.
The course describes how to manage users, download and install modules and themes, archive and restore your entire site, and employ site variables for fast, full control over your Drupal sites. Plus, discover how to script an entire Drupal site installation with and without site profiles.
The Start Drupal interface for module administration works but doesn't scale well when dealing with large numbers of modules and doesn't allow filtering without a third-party module. Additionally, it won't allow downloading of new modules which I've demonstrated in the previous segment. Drush can also provide a fire hose of information. I'll demonstrate how to control that firehouse. The command, Project Manager List, aliased as PML shows the list of available modules and themes, "drush help pml".
To be clear this list is what is available in the Drupal installation, not what's available to download on drupal.org. I'll start by listing every single available extension, "drush pml". A fantastic amount of information, the package, name, type, status, and version are shown. Let's filter this down a bit and only show Enabled extension. The option, Status, takes a comma separated list of options including an; Enabled, Disabled, and Not Installed.
I will start with: drush pml status = " not installed", as this requires quotes. The list can also be changed using a comma, to demonstrate this I will show every module that is not installed and/or disabled. So, status = "not installed, disabled". Another useful argument is type which filters by extension type.
There are two options, Module and Theme, I'll list only themes, type=theme. The four core themes are now shown. I will get into theme management in the next segment as it's similar to module management but has enough quirks to set it apart. The next argument I will demonstrate is filtering by package. Before I do that, I'm going to download the develop project, so there will be some variety, "drush dl devel". The develop projects also provides Drush commands if enabled.
In fact, many Drupal projects provide Drush support. Now that devel has been downloaded, list all extensions again, drush pml. I can see that devel is in package development. I'd like to only show extensions in the development package. So I will use "drush pml" with the option package=development, which also takes a comma separated list of package names, case insensitive. The modules in the devel package are now shown.
I just downloaded a new extension devel. But what information can drush tell me about the devel module itself? Two commands are available, the first, Project Manage Info aliased as PMI, "drush pmi devel" can give me some technical information about the module. A second command, Product Manage Release notes, aliased as RLN, "drush rln", will show release notes on a particular package.
Use arrow keys to scroll, press Space to go down a page and then press Q to quit. What if I want to search for a particular package, but I don't know exactly what package it's in? Drush doesn't support this functionality explicitly. But I will show you a trick that's available on UNIX like systems. By piping the output of the package manager list dgrep, I can search using a keyword. Let's say I want to determine whether or not the comment module is enabled. I will start with "drush pml" to get the list, then the pipe character, to send the output of PML to another command.
I will use grep which will filter based on a regular expression which can also be just the word I'm looking for. I will use "Space -i" to make the search case insensitive. I am looking for comment, so I will just type the word "comment". I can see that there is one module named "comment"; by combining the list command with grep I can quickly filter the list of modules. It looks like the comment module is enabled. I don't want anyone commenting on my development site.
So I will just disable it using the Project manager disable command, which can also be shortened to just dis, drush help dis. The Disable command will disable an extension and any dependent extensions if any. So, "drush dis" and then "comment". I'm prompted if I want to disable comment. While I'm sure I want to, I just want to say yes to any prompt that's given to me by Drush. I'll say no for now. Then redo the command, drush dis comment.
But this time with an additional option, -y. Which will say yes to any prompt. Same as using the web interface disabling the module isn't the same as completely uninstalling it. Drush supports this as well with the Project Manager Uninstall command, drush help pm-uninstall. Notice that there's no alias for this command, pm-uninstall takes a list of modules to be uninstalled. I will uninstall the comment module and I will use the same yes option right at the front to show that it doesn't matter where it is.
So, drush -y pm-uninstall comment. The Comment module is now completely disabled and uninstalled. The inverse is also possible using the Command Project Manager enable, aliased as just en, drush help en. Enable will enable the extension along with any dependencies. Enable will by default also download any libraries that may be used by the module. For example, the devel module downloaded earlier can use fire PHP.
Let's enable the devel module now to see the automatic Library download: drush -y en devel. Devel was enabled but if you don't have subversion installed then fire PHP was not downloaded. This is one of the admittedly goofy bits of Drush. I will occasionally find these little weirdnesses like commands not working quite right and it turns out that there's a missing dependency that it doesn't explicitly state. That's why I went through the trouble of making sure you had Wget an Unzip installed, as that's caused problems in the past when I was trying to figure out why it was failing silently.
In this particular case, you can use the package manager of your system to install subversion. In this case, I'm going to use "sudo apt-get install subversion". Then, "drush -y", I am going to disable devel. And then, "drush -y en devel" to enable it. This time fire PHP was installed.
One more trick, were you ever curious how many modules were installed on a site? I will list every extension of type module in package core that is enabled. I will use an additional argument "--pipe" to only show of module names: drush pml --type=module package=core status=enabled, and then, --pipe. As it stands this would work, but I don't want to count each of these lines. I can pipe the results into the WC or Word Count command with the option -l to count the number of lines. So, Space pipe wc -l.
There are 28 modules in core that are enabled right now. This technique is useful, especially when trying to make the case that there are a large number of modules on a site and someone says, "it's not so bad." Now there's a quantifiable number to back up your claims. Now that I've demonstrated the foundation of listing, enabling, and disabling extensions, let's explore theme management and variables.
There are currently no FAQs about Simplified Drupal Sites with Drush.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.