Some basic drush commands

Submitted by phannphong on 21 February, 2019
basic drush commands

Drush is a supporting tool, which is important for any Drupal developers. It helps executing a task with many steps simpler through one command. It's also really helpful in deployment process through integrating it in script.

I will share some basic Drush commands that I usually use:

1. Clear cache / Cache rebuild.

For Drupal 7

drush cc all

For Drupal 8/9

drush cr

2. Delete all tables in the database (available on Drupal 7/8/9).

drush sql-drop

3. Set password for the account which you know the username(available on Drupal 7/8/9).

drush upwd <username> --password="<password_you_want>"


drush upwd admin --password="admin"

By executing the above command line, the password of admin (account with "admin" is username) is admin.

This is a useful command line when you don't know or forget the password of the account.

4. View list the core and the contributed modules have a new version (available only Drupal 7).

drush ups

5. Update core and contributed module with the latest version (available only Drupal 7).

drush up

This command line will update both core and contributed modules at the same time.

If you just want to update for core or individual contributed modules, you'll use:

drush up drupal

(for core)

drush up <module_machine_name_1>, <module_machine_name_2>, <module_machine_name_3>

(Note: module_machine_name_n is the last path of the url link to the contributed module)

You should backup source code and database before running this command line.

6. Revert schema version of core or contributed modules.

drush ev "drupal_set_installed_schema_version('<module_machine_name>', <number_version>)"


drush ev "drupal_set_installed_schema_version('entityreference', 7002)"

You can find more Drush commands at