Last updated January 20, 2012. Created by dman on May 31, 2009.
Edited by Aham, pferlito, cookiesunshinex, clemens.tolboom. Log in to edit this page.
Drush or drupal shell is a command-line utility to help the site building and maintenance workflows.
Available Drush Commands:
For a list of available commands either visit http://drush.ws or type drush help.
For a printable version use drush help --html
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 enable content- Enable the content (cck) module.
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 justdrush dl backup_migrate --package-handler=git_drupalorgas 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
| Attachment | Size |
|---|---|
| drush-cheat-sheet.pdf | 55.46 KB |
Comments
Could someone add "drush
Could someone add "drush provision" as I have no idea what it does.
Thanks
That's provided by Aegir.
That's provided by Aegir.
---
Cameron Eagans
http://cweagans.com
If you regularly use drush to deploy drupal apps
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
http://drupalwork.interestsphere.com/
http://drupalmashup.interestsphere.com/
Cheat Sheet
The cheat sheet is out of date now that the commands have changed...
The cheat sheet and the info
The cheat sheet and the info here on the page. Many of the commands are depreciated.
Drush Project Page
For those like me that don't frequent the Drupal pages, and so forget the url conventions, the main Drush page can be found here:
http://drupal.org/project/drush
Drush site
Commands can also be found at the official site: http://drush.ws/
Drush version display
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.
drush help status tells
drush help statustells us
drush status drush-version.dan. is the New Zealand Drupal Developer working on Government Web Standards
Choose version of PHP
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!
drush compare before update?
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 imagesWhich 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,
Merging Technology with Creativity
Fountain City Productions
http://fountain-city.com
Have you tried drush sync
Have you tried
drush sync --simulate @dev @stageIt'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.
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Impossible to download the core...
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.xIt'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 !
David OLMETA
Great cheatsheet
Great cheatsheet