Using drush

"drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt."

The drupal project page of drush
The official site of the project is http://drush.ws with version 4.5 the latest stable release and 5.x under development.

With the tremendous UX improvements in the drupal 7 admin interface you might ask why would I want to use a command line tool? Well, firstly drush can not do everything. For instance, managing nodes (adding, editing, deleting) with drush is not currently supported. However, for many tasks, drush offers several advantages over the GUI. These are:

  • speed
  • power
  • custom scripting - repeatability of tasks
  • easy aliased multisite support

The biggest reasons to use drush are its speed and power. To download and enable the views module for example, you would run the drush commands:

    
    drush pm-download views
    drush pm-enable views
These two lines first call the project manager (pm) download method followed by the enable method. There are also shorthand versions of most commands. So the following is equivalent:
    drush dl views
    drush en views
With drush, you do not have the overhead of running requests through a browser, or going between pages of the admin interface. The time savings can significantly add up.

Other pm commands

Shortcut in brackets.

    pm-disable (dis)
    pm-list                 //list projects and their statuses         
    pm-uninstall            //uninstall a project
    pm-disable (dis)        //disable a project
    pm-info                 //Release information for a project

    pm-statusmodules (sm)   //Show module enabled/disabled status
    pm-refresh (rf)         //Refresh update status information

    pm-updatecode (upc)	    //update project code
    updatedb                //call update.php
    pm-update (up)	    //implicitly call pm-updatecode and updatedb

Getting help information

drush status  //information about drush installation
Commands are of the form:
drush [options] <command>
Some optional arguments are:
    -v verbose
    -d debug
    -y answer yes to all prompts
    -s simulate
    -u user to login with
Help pages:
    drush help --pipe  space delimited list of commands
    drush help | grep "your_search_term"

Keeping drupal up to date

With drush, you can install drupal:

    drush dl drupal-7
    drush site-install
or upgrade between major versions:
    drupal site-upgrade 
or stay up to date with minor core version changes, module and theme updates:
    drupal update -y

Keeping drush up to date

   drush self-update

Backing up and using the watchdog

    drush  bam-backup               //backup
    drush watchdog-show (ws)        //show recent watchdog messages
    drush watchdog-delete (wd-del)  //delete watchdog messages
    drush watchdog-list             //show available types and levels
    
    #list php warnings in the watchdog
    drush ws --type=php --severity=warning

Querying the database

    drush sql-query "SELECT type FROM node GROUP BY type"
    drush sql-query "SELECT nid, type, title FROM node ORDER BY type, title" > nodes.txt
    drush sql-query "SELECT nid, title FROM node WHERE type='audio' ORDER BY title"

Targeting a specific site in a multisite setup

    drush site-alias (sa)           //list site aliases

    #list the enabled modules of a specific site
    drush siteA pm-list --status=enabled

    #compare two sites enabled modules
    diff <(drush siteA pm-list --status=enabled) <(drush siteB pm-list --status=enabled --pipe) | grep '<'

Clearing the cache

    drush cc all		//clear all caches
    drush cc theme		//clear theme cache
    drush cache-clear (cc)      //clear caches (no argument will bring up selection menu)

running cron, manipulating variables, setting up an omega subtheme

    drush vset preprocess_css 0 --yes	Turn off CSS caching
    drush vset preprocess_js 0 --yes	Turn off JavaScript caching
    drush vget %var 			List of all variable names beginning with %var and their values
    drush vset %var %val 		Set all variables beginning with %var to %val

    drush cron                          run a cron job
    omega-subtheme                      omega easy subtheme creation

Type: 

Drupal

Comments

Coach Factory Outlet Shops

That generated an abundance of coach sunglasses area regarding wine bottles, diapers, pacifiers, and also bathroom towels. While I feel knowledgeable about the particular identify with the coach bags, it is possible to find out about the merchandise relative to the head wear, sun shades, in addition to hand bags. Move away the actual red-colored carpeting, this is a brand new add-on towards the developing loved ones is actually coach outlet store 2012 Ergo. The actual cheap coach boots are made along with extremely light-weight leather-based which fits the actual silhouette towards the curves from the entire body. The particular coach wallets 2012 includes several features, yet you will buy this kind of circumstance, specifically as you execute a a lot more sophisticated physical appearance.

Add new comment