Drush commands for performing basic things

Ready for review -- AWAITING PEER REVIEW
This tutorial will teach you to do some basic things on your Drupal site using Drush

There are many things you do on your site using the UI such as running cron, clearing cache, adding users etc. In this guide, we'll cover some of the basic stuff which you can do.


1. Open the command Prompt and in your site directory type:

drush cc

Choose an option and press enter. cc stands for cache-clear.

Cache-clear command

We just cleared our cache!

You can also use something like drush cc all, which also clears the cache but doesn't show the interactive menu as shown above.

Note that in Drupal 8, the "cc" command was replaced with the "cache-rebuild" command (alias is "cr").

2. We can now try to run the cron using the following command: drush cron

Running Cron

3. Now something important. To download Drupal core or a project (modules, themes or profiles), use the 'pm-download' or 'dl' command.

drush dl devel

The above code would download the latest recommended release of the devel module and save it in the appropriate directory. Go to this link to see various examples. It is time to enable the module:

drush en devel

The above command would enable the devel module. The 'en' command would enable dependant extensions as well.

To disable a module, the available command is 'dis'. You can type:

drush dis devel

Installing and enabling modules

To uninstall a module, you can use:

drush pm-uninstall devel

To see the list of available extensions (modules and themes), type: drush pm-list

List of extensions

To see this list in a compact format, you can use: drush pm-list --pipe

Using the pipe option

To see the list of module, use drush pm-list --type="module" --pipe

To see the list of extensions which are installed, use drush pm-list --status="installed" --pipe

4. To add a new user you can try out the command:
drush user-create sampleusername --mail="email@example.com" --password="password"

Adding new User

You can now try to change the password of the user using drush user-password sampleusername --password="newPass"

To see the information of any user, you can try drush user-information sampleusername --full

Changing password

To cancel a user account user the user-cancel command, like drush user-cancel sampleusername

Lesson tags: