Skip to main content
knackforge blog knowledge base

The most frequently used drush commands

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.


$ 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


$ drush sql-sync @dev.mysite @local.mysite
Note : use --no-ordered-dump to make the restore faster. Also check levelten's blog, if you wish to know the configurations needed for this.


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


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


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


$ 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


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.
$ drush pm-list 
7. drush dl module-name :-  Download the latest recommended release of drupal core, specified module or theme.
$ drush dl views  
8. drush en/dis - Enable or disables a drupal module. 
$ 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.
$ 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.


$ drush features-list
11. drush features-revert:- Reverts the specific features
$ drush features-revert frontpage
12. drush sql-drop :- Drops all the tables in the given database
$ drush sql-drop
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               : https://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.


$ drush cron
Cron run successfully.                                                               [success]