Upgrade Your Drupal Skills
We trained 1,000+ Drupal Developers over the last decade.
See Advanced Courses NAH, I know EnoughDrush commands for every day usage
Parent Feed:
Drush stands for "Drupal shell" which means a powerful tool for managing Drupal installation from command line interface. Drush provides a lot of useful commands for dealing with a cache, modules, cron, database etc. But some of contrib modules also provide some extra drush commands for specific functionality (like features module comes with commands for managing features). Here's a bunch of a useful drush commands which I use every day.
Cache
# Clear all caches. drush cc all # Clear menu cache. drush cc menu # Select cache bin for clearing. drush cc
Modules
# Download module by name. You can grab module # name from module's page on drupal.org. drush dl module_name # Download module by name. # into sites/default/modules/custom # directory. drush dl module_name --destination=sites/default/modules/custom # Enable module by name. drush en module_name # Disable module by name. drush dis module_name # Uninstall module by name. # This commands will call hook_name_uninstall(). drush pmu module_name # Get list of available modules # in your Drupal installation. drush pml # Check if module module_name # is available in your Drupal # installation. drush pml | grep module_name
User
# Get an one-time login link # for user by his/her uid. drush uli uid # Get an one-time login link # for user by his/her email. drush uli [email protected] # Block user by his/her username. drush ublk test_user # Unblock user by his/her username. drush uublk test_user # Change password for user by his/her name. drush upwd --password="password" user_name
Pending database updates
# Run all available database updates # implemented in hook_update_N() in # *.install files. drush updb
Cron
# Run cron.php. It will call all hook_cron() # defined in modules and process cron queues. drush cron
Variables
# Get variable value by name. drush vget variable_name # Set variable value by name. drush vset variable_name "Test value" # Delete variable by name. drush vdel variable_name
Registry
# Install registry_rebuild drush extension. drush dl registry_rebuild # Rebuild Drupal registry. Usefull when some of # modules was moved into another folder. drush rr
Features
# Get list of available features. drush fl # Get list of overridden features. Please # note if you have multilingual site and # site active language is not english then # you have to replace word "Overridden" by # it's translation. drush fl | grep Overridden # Show diff of overridden feature by name. drush fd feature_name # Update feature by name. Put changes from # database into a code. drush fu feature_name # Revert feature by name. Restore database # state from a code. drush fr feature_name
Sql interface
# Show information about current database connection # that defined in settings.php file. drush sql-connect # Login into sql console interface. drush sqlc # Execute a query. drush sqlq "SELECT * from node;" # Restore database dump from dump_name.sql file. drush sqlc < dump_name.sql # Save database dump into dump_name.sql.gz file. drush sql-dump --gzip --result-file=dump_name.sql.gz
Other
# Run custom php code. drush eval "variable_set('site_name', 'Test site name');" # Get all dblog messages in realtime (tail style). # Useful when you want to debug a remote Drupal # installation where you have ssh access. drush ws --tail
Key notes:
About Drupal Sun
Drupal Sun is an Evolving Web project. It allows you to:
- Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
- Facet based on tags, author, or feed
- Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
- View the entire article text inline, or in the context of the site where it was created
See the blog post at Evolving Web