Skip to main content

Drush and Drush Commands

Hülya Küçük
Hülya Küçük Front-end Developer

 

Drush is a powerful tool created by combining the words Drupal and Shell, used to manage Drupal projects via the command line. It encompasses essential functionalities for site administration and maintenance. One of the significant advantages for Drupal developers is Drush's speed, enabling tasks to be executed within seconds.

Installation of Drush:

1. Install Composer:

For Linux, use the following command:

curl -sS https://getcomposer.org/installer | php

For Windows, download and install Composer from Composer-Setup.exe.

After installation, ensure Composer is available globally using the command:

mv composer.phar /usr/local/bin/composer

 2. Install Drush:

  1.  After installing Composer, use the following command to install Drush:

    composer global require drush/drush

    To install a specific version:

    composer require drush/drush:10.4.3

  2. Check Installed Drush Version:

     After Drush installation, check its version using the command:

    drush --version

  3. Make Drush Available: 

    Add the Drush commands to your system's PATH variable for direct access. Open ~/.bashrc or ~/.bash_profile and add the following line:

    export PATH="$PATH:$HOME/.composer/vendor/bin"

  4. Verify Drush Installation: 

    Confirm the Drush version and other information using the command:

    drush status

Basic Tasks:

  1. Module/Theme Management: Activate or deactivate modules or themes within seconds.
  2. Custom Tasks: Create and execute custom commands for tailored workflows or automation scenarios.
  3. Cleaning: Easily perform tasks like cache clearing through the command line.
  4. Configurations: Quickly edit site configurations, especially useful for synchronizing settings across different environments.
  5. Database Backup: Backup the database and take a snapshot of the site, preventing potential data loss.
  6. Access to Help and Documentation: Use Drush for accessing help and documentation on commands. For example, drush help or drush help <command>.

Sample Commands:

drush status: Displays the overall status of the site.

drush pm-list: Lists available modules and themes.

drush en module_name: Enables a specified module.

drush dis module_name: Disables a module.

drush uli: Initiates a user session.

drush sql-cli: Provides command-line access to the database.

drush cex: Exports module or theme configuration.

drush cim: Imports configuration from another environment.

drush up: Updates modules, themes, and the Drupal core.

drush updb: Updates the database.

drush sql-dump: Backs up the database.

drush cr: Rebuilds Drupal's cache for performance enhancement.

drush dl: Short for download, used to download plugins, modules, themes, or projects.

These Drush commands cover fundamental functionalities for managing Drupal projects, allowing you to effectively handle your Drupal site based on project requirements and needs.

Our Offices

Drupart Locations

Our Officess

London

151 West Green Road, London, England

442038156478

[email protected]

Drupart R&D

GOSB Teknopark Hi-Tech Bina 3.Kat B3 Gebze - KOCAELİ

+90 262 678 8872

[email protected]

Newark

112 Capitol Trail Suite, A437 Newark DE, 19711

+17406666255

[email protected]

Wiesbaden

Hinterbergstraße 27
65207 Wiesbaden
Deutschland

+49 (0) 6151 – 492 70 23

[email protected]