![drush-vagrant]()
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.
![commonly used Drush commands]()
Using
si command you can install new Drupal application in your server by configuring/supplying the BLOCK WORD parameters in below Drush command.
drush site-install YOUR_PROFILE_NAME
--site-name="YOUR_SITE_NAME"
--db-url="mysql://DATABASE_USER:DATABASE_PASSWORD@HOST:PORT_NUMBER/DATABASE_NAME"
--account-name="SITE_ADMIN_USER"
--account-pass="SITE_ADMIN_PASSWORD"
--account-mail="SOMEONE@EXAMPLE.COM"
--yes
Example:-
drush si standard
--site-name="Test Drush with Drupal"
--db-url="mysql://root:test123@127.0.0.1:3306/drupalbydrush"
--account-name="admin"
--account-pass="admin"
--account-mail="test@test.com"
--yes
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.
![commonly used Drush commands]()
Using this command you can download module, drupal & theme from drupal.org repository by its name. Which will download and install to your application.
drush dl MODULE_NAME
drush dl THEME_NAME
For eg:-
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.
![commonly used Drush commands]()
Using
en/dis Drush command enabling or disabling modules can be achieved easily.
drush en MODULE_NAME
drush dis MODULE_NAME
Example:-
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.
![commonly used Drush commands]()
Using this command you can clear cache for menu,theme-registry,Css-Js,blocks,modules and theme & registry in your application.
drush cc
For eg:-
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.