Post

Drush Cheatsheet

With a new Drupal install either locally or on a remote server Drush is probably one of the first modules you will want to install. It will help you do lots of other things that would otherwise be too complex to accomplish without Drush.

Get version of Drupal and PHP you are running.

1
drush status

Update sync database

The updatedb command is used to update the locate database on Unix-like systems. This database is used by the locate command to quickly find files on the filesystem.

What Does updatedb Do?

  • Scans the Filesystem: It scans directories in the filesystem to create an index of file names and their locations.
  • Updates the Database: The collected information is stored in a database file, usually located at /var/lib/mlocate/mlocate.db or a similar path.
  • Optimizes Search Performance: By maintaining an indexed list of files, it allows the locate command to retrieve results much faster than using find.

When Should You Run updatedb?

You should run drush updatedb:

  • After Adding or Deleting Many Files: If you’ve recently made significant changes to your filesystem (e.g., installed new software, moved directories, or deleted files), you may want to update the database to reflect these changes.
  • If locate Results Are Outdated: If the locate command isn’t finding files that exist or is showing files that have been deleted, running updatedb will refresh the index.
1
drush updatedb

List installed modules

1
drush pm:list --status=enabled

Remove flag to get all installed modules, regardless of status

Enable Module

1
ddev drush en paragraphs

List Themes

1
drush pm-list --type=theme

Enable Theme

1
ddev drush theme-enable bootstrap5

Set theme as default

1
2
ddev drush cset system.theme default bootstrap5 --yes
ddev drush cr
1
cd /your/drupal/site/
1
drush uli --uri example.com

Trouble Shooting

The Drush launcher could not find a local Drush in your Drupal site.

1
vendor/bin/drush uli --uri http://your-site-url

Find Drush version

1
drush --version

Update Drush

You might need to add the ^ to the beginning of the version number ie ^12.0.2 in the composer.json file.

1
composer update drush/drush

Uninstall Drupal Module

1
drush pm:uninstall module_name

Remove the Module:

1
composer remove drupal/module_name

** same command but with ddev **

Uninstall the Module:

1
ddev drush pm:uninstall module_name

Remove the Module:

1
ddev composer remove drupal/module_name
This post is licensed under CC BY 4.0 by the author.