Commonly used Drush commands Drupal Developers must know

What is Drush ?

Drush is a command line utility tool for Drupal. It is a Drupal Shell which allows us to manage our site remotely through command line.

Why do we need Drush ?

It Saves Lots of Time by doing many Drupal operations in a faster and efficient way. Although Drupal is Awesome there are many point and click operations required to do a particular operation. For Example: To install a module you need to navigate 3 or more pages by clicking the link and reach the module page. From there you may need to upload the module zip file or find the module name from Drupal projects page and paste the link.

Drush comes in handy during site maintenance. Example:while updating the core modules and themes, we may need to take a backup of database. Drush does everything for us and saves our time and effort.

What are the commonly used Drush commands in Drupal ?

Drush has lot of uses in Drupal and here we will see commonly used Drush commands,

Site Installation

Download Drupal, Modules & Theme

Enable/Disable Modules & Themes

Clear all Site cache.

You must change your directory to Drupal root directory before trying these below commands. Let’s see each command with example.

1. Site Installation : si (Aliases)

The Drupal web interface will take time to load and install core modules but if you use Drush for installing you can save lot of time.

Using si command you can install new Drupal application in your server by configuring/supplying the BLOCK WORD parameters in below Drush command.

2.Download Drupal, Modules & Theme : dl (Aliases)

Installing modules or themes in Drupal web interface you need to know the FTP URL of the modules or archive of the modules, if you use Drush you can do this in one line of command by passing the module or theme name alone.

Using this command you can download module, drupal & theme from drupal.org repository by its name. Which will download and install to your application.

1

2

drush dl MODULE_NAME

drush dl THEME_NAME

For eg:-

1

2

3

drush dl heart-beat// module

drush dl mydons// theme

drush dl drupal// drupal app

3. Enable/Disable Modules : en/dis (Aliases)

Managing modules in Drupal web interface from Admin end (Administration ->Modules) need couple of actions for enabling or disabling but Drush can do it in much more simpler way.

Using en/dis Drush command enabling or disabling modules can be achieved easily.

1

2

drush en MODULE_NAME

drush dis MODULE_NAME

Example:-

1

2

drush en blog

drush dis blog

4.Clear all Site cache : cc (Aliases)

Clearing cache in Drupal web interface will take time to clear menu,theme-registry,Css-Js,blocks,modules and theme & registry but using Drush cc command you can achieve this action quickly.

Using this command you can clear cache for menu,theme-registry,Css-Js,blocks,modules and theme & registry in your application.

1

drush cc

For eg:-

1

drush cc all

By using all these command you can control your Drupal web application from your command line. Drush is available for Windows, Unix & Mac platforms. Its easy to use and most helpful contribution to Drupal.