Drush the Ultimate Drupal Productivity Tool | 3 Waves Agency

Drush the Ultimate Drupal Productivity Tool

Drush the Ultimate Drupal Productivity Tool

Drush the Ultimate Drupal Productivity Tool

The average computer user doesn't have experience with command line utilities. You might be asking yourself what is a command line utility? This post will answer that question on a small scale. The three main goals in the post are:

  1. Brief description of command line utilities
  2. How this utility can help your Drupal site
  3. Help you get started with Drush

A command line utility is the alternative to a graphic user interface, which basically means instead of seeing icons or folders everything is code. Now that you have the basic definition of a command line utility it's time to move on to Drush.

What is Drush and why use it?

Drush simply put is a command line utility specifically for Drupal. It can help you install modules, download modules, uninstall modules and much more all without even opening a web browser. It also cuts down on development/upgrade time significantly. Imagine being able to update 15-20 modules in a matter of seconds. Updating Drupal core in less than 15 seconds with a complete backup done automatically. Now you can see just how much time this will save you.

When I first started learning Drupal I heard about Drush on many occasions, but I was never brave enough to tackle it. Themers in the Drupal community have said that it's a step you must take as a Drupal themer in order to take advantage of everything Drupal offers.

Can I use Drush?

Drush needs to be running on your server in order to use it. Most shared hosting accounts do not have Drush installed out of the box, but some do. Be sure to do your research on the host if you want to take advantage of Drush. That being said you can install Drush on a shared hosting account that does not have it already installed as long as you have SSH Access. That's a fancy term to say that you can access your website from a command line utility. If your hosting company does not allow SSH access, then you cannot use Drush.

Connecting to your site via SSH

Before installing Drush, we need to connect to our sites server. Open up your command line utility, which in my case, is Terminal (MacOS X) and type the following.

ssh username@mydomain.com

IMPORTANT: This syntax may change depending upon your host. Always check with your host for the correct syntax to connect via SSH.

Once you hit enter and you have entered the information correctly, it will prompt you for a password. Enter the password for the user you are trying to connect to.

You're in!

Installing Drush on Shared Hosting

Installing Drush on a shared host is not difficult, but it may seem so if you've never used command line before. Here are the steps to begin your life as a drupal productivity master. You can also view the steps detailed out here.

1.  Navigate to the root of your server. This is normally where you are as soon as you login.

2.  Create a directory named bin.

{syntaxhighlighter brush: php;light: true; fontsize: 100; first-line: 1; }cd ~ /* This Command takes you to the root */ mkdir bin /* Creates directory called bin */{/syntaxhighlighter}

3. Now we need to go inside that new folder so we would type cd bin

4. Now that we are inside the bin directory, it's time to download drush.

wget http://ftp.drupal.org/files/projects/drush-All-versions-4.2.zip

5. Drush is now downloaded as a zip file so unzipping it is the next step

unzip drush-All-versions-4.2.zip

6. We need to create an alias for Drush so that we don't always have to type the full path to run a drush command. Instead, we will just be able to type drush
Still in the bin directory type pwd which should return something like this /home/username/bin/ and since we know there is a directory in bin called drush, the full path is /home/username/bin/drush Now we can type this piece of code to make executing drush easy

export PATH=$PATH:/home/username/bin/drush

7. Almost done! We have to make sure that the drush file is executable, so here is how. You should still be in the bin directory we need to move inside the drush directory.

cd drush

Once inside the drush directory type:

chmod u+x drush

Congratulations Drush is Installed

Some great Drush commands.

  • drush pm-download cck views (Downloads specified modules with a space between each one.)
  • drush pm-enable cck views (Enables specified modules. No more checking boxes!)
  • drush pm-disable cck views (Disables specified modules)
  • drush pm-uninstall cck views (Uninstalls specified modules)
  • drush status (Shows the status of your Drupal Install)
  • drush pm-update (Updates all Modules and Drupal Core)
  • drush cache-clear (Clear all Cache)

These are just a few simple commands that can dramatically increase your productivity. Check out Drush.ws for more information on how to tame Drush.

Hopefully this has helped you come to a better understanding of command line utilities and how Drush can help you become a more productive Drupal developer. Please leave a comment with any questions.