Video tutorials

Drush Tutorial: Installation and Main Commands

When it comes to Drupal administration and development tasks, Drush is the number one tool everyone should have in their arsenal. Drush can assist with variety of common tasks, from installing and updating Drupal core and contributed projects to running specific commands like clearing cache to synching between staging and live servers. And any of these tasks is accomplished with just a single command (with maybe some adjustment of the configuration settings for more advanced stuff).

In this video tutorial, we're going to quickly install Drush on Ubuntu (using the development setup from the previous tutorials) and then run through some of the most useful commands intended to simplify management of your Drupal sites.

Watch the Screencast

Tutorial In a Nutshell

Drush Installation on Ubuntu

Download Drush from the project webpage( Drush works with any Drupal release. In command line you can use wget command:

$ wget [link to latest release]

Then unpack it:

$ tar -xvzf<archive file>

You should now have a Drush directory under /home/your_username/ Cd to this directory.

You can see the full set of instructions on the readme file (in the module directory or online). We’re done with step 1 (unpacking), now let’s make drush executable:

$ chmod u+x drush

Make Drush Executable

Then create a symlink:

$ sudo ln –s /home/<username>/drush/drush /usr/bin/drush

Create a symlink to Drush

Basic Drush commands

Change to your Drupal directory to run Drush commands (go to the documentation to see full list of Drush commands).

$drush status

Lets you see the status of your Drush installation.

Drush status

$ drush cron

Runs cron, as you might gess. Shows success if everything is ok.

$ drush help

Shows all available commands, with short aliases.

Drush help

Specific commands can also have a help menu:

$ drush command --help

Other modules can also add their own commands - don't forget to check when you install them.

To download a module or a theme type:

$ drush dl project_name

Drush download

To enable a project, type

$ drush en <project name>

Then choose “y” to continue.

Drush enable project

You can also download and install several projects at once:

$ drush dl cck zen

However, if you try to enable cck by typing ‘drush en cck’ you’ll get an error.

Drush enable

It happens because there’s no such module called ‘cck’ as it’s a package of several modules. For help, use

$ drush sm

This command shows all modules and themes, including submodules.

drush sm

To see modules by package, you can use

$ drush sm –package=cck

To see only enabled modules or themes:

$ drush sm –status=enabled

After you’ve looked up modules, you can enable them using the machine readable name:

$ drush en content text zen

Drush enable multiple projects

By default, Drush downloads current stable release (if any), but sometimes you need to get a different release or a development version of the project. First, you want to check available release:

$ drush pm-releases panels

Drush pm-releases

Now you can choose the release you need:

$ drush dl panels-6.x-3.x-dev

To disable the module, us "dis", for example:

$ drush dis devel

Then you can choose to uninstall it, which means deleting all the database tables created by this module:

$ drush uninstall devel

Drush uninstall

Drush can also update core Drupal, modules and themes. To run all available updates you can use

$ drush up

Drush will ask for confirmation and will print out any other information or warnings.

drush update

Instead of Drush update, you can use separate commands to update the codebase (drush upc) and database (drush updb).

drush upc, drush updb