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.
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
composer global require drush/drush
To install a specific version:
composer require drush/drush:10.4.3
After Drush installation, check its version using the command:
drush --version
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"
Confirm the Drush version and other information using the command:
drush status
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.