Most used Drush commands in drupal 7

If you are into Drupal development and a vivid user of GNU/ Linux (or *nix) for a while, then Drush is a must learn tool for you. As a part of Drupal development project, we extensively use drush. A few commands that help us develop sites at the phase of clients expectation are briefed below,

1. drush cc [type] :- Clears a specific cache, or all Drupal caches.

Example

$ drush cc all

or if you want to rebuild only the menu

$ drush cc menu

2. drush sql-sync :- Copy and import source database to target database. Transfers via rsync

Example

$ drush sql-sync @dev.mysite @local.mysite

3. drush sql-dump :- Exports the Drupal DB as SQL using mysqldump

Example

$ drush sql-dump > /path/to/backup_dir/database-backup.sql

4. drush sql-connect :- Gives string for connecting to DB

Example

$ drush sql-connect

To get directly dropped into the MySQL prompt use

$ `drush sql-connect`

5. drush rsycn :- Rsync the Drupal tree to/from another server using ssh

Example

To rsync the entire site

$ drush rsync @dev @stage

To rsync ony the files folder

$ drush rsync @dev:%files @stage:%files

6. drush pm-list :- Lists the complete set of modules installed in the site.

Example

$ drush pm-list

7. drush dl module-name :- Download the latest recommended release of drupal core, specified module or theme.

Example

$ drush dl views

8. drush en/dis – Enable or disables a drupal module.

Example

$ drush dis overlay

Disalbe overlay module

$ drush en -y views

Using -y will make automatically download & enable the dependencies as well.

9. drush scr :- Executes PHP files.

Example

$ drush scr filename.php

Provides the drupal environment in the script runtime. Ideal for testing a snippet of module code.

10. drush features-list :- List all the available features for your site.

Example

$ drush features-list

11. drush features-revert:- Reverts the specific features

Example

$ drush features-revert frontpage

12. drush sql-drop :- Drops all the tables in the given database

Example

$ drush sql-drop

Output

Do you really want to drop all tables(y/n) :

13. drush status :- Provides all the details about the site.

Drupal version : 7.12
Site URI : http://default
Database driver : mysql
Database hostname : localhost
Database username : root
Database name : example
Database : Connected
Drupal bootstrap : Successful
Drupal user : Anonymous
Default theme : custom
Administration theme : seven
PHP configuration : /etc/php5/cli/php.ini
Drush version : 4.5
Drush configuration :
Drush alias files : /home/user/.drush/example.alias.drushrc.php
Drupal root : /home/user/Public/project
Site path : sites/default
File directory path : sites/default/files

14. drush cron :- Triggers drupal cron run.

Example

$ drush cron

Output
Cron run successfully.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

WordPress.com.

Up ↑

%d bloggers like this: