Drush (Drupal shell) is a program that you can install on your computer and/or on your web-hosting server, which allows you to easily build and maintain all aspects of your Drupal installation, whether that be a 'Local' site on your computer, or an online site.

It is a program with which you use your keyboard to issue Drupal 'text' commands in the Unix language, as opposed to your using the mouse in a visual user interface.

"Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt." [Quotation from the Drush home-page]

NOTE: This Drush documentation page as well as most of other documentation pages on Drupal.org are deprecated or are out of date. For current Drush documentation, visit the Drush repository on Github

Available Drush Commands:

For a list of available commands either visit http://drushcommands.com or in the Drush program interface, type drush help and press [Enter].

Extensions

Other modules provide new drush commands! These become available automatically and are listed when you run drush help.

Tips

Drush autodetects the appropriate site from directory context, and read its configs from there, so if your command shell is in {drupaldir}/sites/all or anywhere under {drupaldir} then drush commands will apply to your default install. If you move your shell session into {drupaldir}/sites/mysite, then drush commands will be run in the context of the mysite multisite instance. You can always run drush status to check the currently active context.

When updating with Drush, it is not necessary to put the site in maintenance mode. See Moshe's statement

Example Commands

drush dl cck zen
Download current recommended versions of CCK module and Zen theme.
drush en content
Enable the content (cck) module.
drush vset theme_default theme_name
make theme_name theme default theme
drush --uri=http://example.com status
Show status command for the example.com multi-site.
drush pm-releases backup_migrate
Get info on all available releases for backup_migrate.module, e.g.
 Project         Release      Date        
 backup_migrate  6.x-2.x-dev  2009-Apr-07 
 backup_migrate  6.x-1.2      2009-Jan-18 
 backup_migrate  6.x-1.0      2008-Aug-14 
 backup_migrate  6.x-1.x-dev  2009-Feb-19 
drush -v dl backup_migrate-6.x-1 --package-handler=git_drupalorg
Checkout via git, the current stable version of the backup_migrate module on the DRUPAL-6--1 branch into your sites/{active.site}/modules/ directory. In this case the result is identical with just drush dl backup_migrate --package-handler=git_drupalorg as the requested version is the recommended version.
drush -v dl backup_migrate-6.x-2.x-dev --package-handler=git_drupalorg
Checkout via git, the unstable dev version of the backup_migrate module on the DRUPAL-6--2 branch into your sites/{active.site}/modules/ directory.
drush -v dl backup_migrate-6.x-2.x-dev
Without specifying a --package-handler, (the default) the project bundle is retrieved via wget, and unpacked locally without the git information. This may overwrite any local changes.
drush pm-update devel
Update the devel module to the latest recommended release and apply any database updates
drush pm-update drupal
To update only Drupal core (in case of a security update)

See also: Offsite blog tutorial (with pictures) on Installing and running drush on OSX by morten

Drupalize.Me has a free video on installing Drush on all Unix systems, including OSX...Installing Drush on Unix Systems

Windows' Drush Make command working in Drush 5.8

Being a lazy programmer, I was so excited when I discovered drush. Then, my excitement was dulled when I discovered that the drush make command did not work in Windows XP or 7. Thankfully, drush make is now working in drush 5.8.

Upgrading to dev versions of Drush using Windows

If you have a need, this article provides detailed instructions for manually upgrading to the latest development version of drush. Do worry, it's pretty easy.

AttachmentSize
Drush Commands (5.11-dev)133.83 KB
drushguide2012.pdf122.6 KB
drush-cheat-sheet.pdf55.46 KB

Comments

pokadan’s picture

If you regularly use drush to deploy drupal applications you may want to check out www.drupalmashup.interestsphere.com. The site will allow you to choose which projects(modules,themes) to generate drush commands for, option to generate enable commands and to specify --destination parameter.

List of drupal projects is updated regularly from drupal.org

Mixologic’s picture

The cheat sheet is out of date now that the commands have changed...

Timotheus’s picture

The cheat sheet and the info here on the page. Many of the commands are depreciated.

etxaleku’s picture

Is there a drush version command to determine which version of drush you're running? Something like "drush --version" or "drush version". I'm trying to determine if I'm on the current version of drush.

dman’s picture

drush help status
tells us
drush status drush-version

dgorton’s picture

If you have multiple versions of PHP on your system (e.g. 5.2.x and 5.3.x) you can specify which version to use with a --php switch:

drush command --php="/Path/to/php"

Alternatively, you can specify a different default in your drushrc.php file:

$options['php'] = '/Path/to/php';

Took me a while to figure out - hope it helps someone else!

greg.1.anderson’s picture

Unfortunately, the advice above does not work. Set DRUSH_PHP as explained in the README.

datarazor’s picture

Hello, does anyone know how I would compare my local version to the remote files before I update?

I want to first check if anything has been hacked/patched/changed on my files before I just blindly update my modules or core; as I know that even though people are not supposed to hack modules, it DOES happen.

Basically what I am looking for is something that would combine diff -r with a remote check, or even dl the current version to a diff folder to compare, maybe a command like:

drush diff images

Which would return any changes to the module [CURRENT version] to the remote one?

Otherwise, does anyone know how else to check this? How are other drupal people checking for changes before doing updates? Thanks,

dman’s picture

Have you tried drush sync --simulate @dev @stage
It's not quite as informative as a full rdiff, but it will give you an idea of what will change.

If you run drush sync with -v, you'll see the rsync command it's actually running. You can copy that and tweak its options a little until you get the answer you want.

Running hacked on your target site may tell you about modified modules - I think they almost had drush integration for it.

And, moving forward ... the way other people do it is to use a version control system.

olmeta.david’s picture

Hi,

I tried to get the core there a few months and all was OK.
I tried to get the core today and it was impossible. The error :

Source directory /tmp/drush_tmp_1299352966/drupal is not readable or does not exist. [12.78 sec, 3.07 MB]
Project drupal (6.x-dev) could not be downloaded to /Users/david/www/drush_test/drupal. [12.78 sec, 3.07 MB

The command line in both cases :

drush dl drupal-6.x

It's strange because the error message specify a Users/david/www/drush_test/drupal path whereas the archive downloaded and uncompressed is drupal-6.x-dev.tar.gz...

I looked at the drush code and I found this (in commands/pm/package-handlerwget.inc, line 88) :

if (($request['project_type'] == 'core') || (($request['project_type'] == 'profile') && (drush_get_option('variant', 'core') == 'core'))) {

When I displayed the $request['project_type'] value, I get 'module' value (I don't understand because for me, it must be 'core' value...), and when I displayed the drush_get_option('variant', 'core') value, I get 'core' (that's normal I think).

Is there someone who knows why this problem occurs ?
Is it because the Git migration ?

Thanks !

Jumoke’s picture

Great cheatsheet

Pedja Grujić’s picture

.PDF od Drush guide added, info has been collected for our internal use over last few months, it has been very useful so putting it out there and hopefully somebody can use it as a reference.

If part of your blog/writing is in the guide please let me know and I will add credits. Sorry for lack of credits as it has been pieced together from so many great sources and README.

Pedja
Drupal Geek at New Target Inc.
http://www.newtarget.com

doublejosh’s picture

Guess this is needed anymore: https://github.com/doublejosh/Drupal-Spinup

troylindholm’s picture

Where am I able to modify the below settings after doing a 'drush status'?

/var/www# drush status

Drupal version : 7.17
Site URI : http://default
Database driver : mysql
Database hostname : localhost
Database username : drupaldefault
Database name : drupaldefault
Default theme : garland
Administration theme : garland
PHP configuration : /etc/php5/cli/php.ini
Drush version : 4.5
Drush configuration :
Drush alias files :
Drupal root : /var/www
Site path : sites/default
File directory path : sites/default/files

Pedja Grujić’s picture

What exactly do you need to modify? That shows you status of your Drupal install.... version, what db and other options it has.

If you need to change db username or anything like that do it in /sites/default/settings.php and it will show in status.

Pedja
Drupal Geek at New Target Inc.
http://www.newtarget.com

somik’s picture

Is there anyone who added drush in his/her godaddy hosting if yes plz share steps

Thanks in advance
Somik

Pedja Grujić’s picture

rajmataj’s picture

This site outlines steps for installing Drush on shared hosting using Composer, which can then be used later on to update Drush or even remove it: How to Setup Drush 7 on Shared Hosting

joshjalopy’s picture

I created a new 'cheatsheet' of Drupal commands based on Drush version 5.11-Dev. See above attachment. It's basically 'drush help --html' that I cleaned up and made into a pdf. This is the latest guide and also the most complete as far as I've seen. Hope others find it useful too.

krknth’s picture

Check some basic commands which you always using Drush basic commands.