Drush Tutorial: Installation and Main Commands
When it comes to Drupal administration and development tasks, Drush is the number one tool everyone should have in their arsenal. Drush can assist with variety of common tasks, from installing and updating Drupal core and contributed projects to running specific commands like clearing cache to synching between staging and live servers. And any of these tasks is accomplished with just a single command (with maybe some adjustment of the configuration settings for more advanced stuff).
In this video tutorial, we're going to quickly install Drush on Ubuntu (using the development setup from the previous tutorials) and then run through some of the most useful commands intended to simplify management of your Drupal sites.
Watch the Screencast
Tutorial In a Nutshell
Drush Installation on Ubuntu
Download Drush from the project webpage(http://drupal.org/project/drush). Drush works with any Drupal release. In command line you can use wget command:
$ wget [link to latest release]
Then unpack it:
$ tar -xvzf<archive file>
You should now have a Drush directory under /home/your_username/ Cd to this directory.
You can see the full set of instructions on the readme file (in the module directory or online). We’re done with step 1 (unpacking), now let’s make drush executable:
$ chmod u+x drush
Then create a symlink:
$ sudo ln –s /home/<username>/drush/drush /usr/bin/drush
Basic Drush commands
Change to your Drupal directory to run Drush commands (go to the documentation to see full list of Drush commands).
$drush status
Lets you see the status of your Drush installation.
$ drush cron
Runs cron, as you might gess. Shows success if everything is ok.
$ drush help
Shows all available commands, with short aliases.
Specific commands can also have a help menu:
$ drush command --help
Other modules can also add their own commands - don't forget to check when you install them.
To download a module or a theme type:
$ drush dl project_name
To enable a project, type
$ drush en <project name>
Then choose “y” to continue.
You can also download and install several projects at once:
$ drush dl cck zen
However, if you try to enable cck by typing ‘drush en cck’ you’ll get an error.
It happens because there’s no such module called ‘cck’ as it’s a package of several modules. For help, use
$ drush sm
This command shows all modules and themes, including submodules.

To see modules by package, you can use
$ drush sm –package=cck
To see only enabled modules or themes:
$ drush sm –status=enabled
After you’ve looked up modules, you can enable them using the machine readable name:
$ drush en content text zen
By default, Drush downloads current stable release (if any), but sometimes you need to get a different release or a development version of the project. First, you want to check available release:
$ drush pm-releases panels
Now you can choose the release you need:
$ drush dl panels-6.x-3.x-dev
To disable the module, us "dis", for example:
$ drush dis devel
Then you can choose to uninstall it, which means deleting all the database tables created by this module:
$ drush uninstall devel
Drush can also update core Drupal, modules and themes. To run all available updates you can use
$ drush up
Drush will ask for confirmation and will print out any other information or warnings.
Instead of Drush update, you can use separate commands to update the codebase (drush upc) and database (drush updb).
If you liked it this story, you might like the following:













Comments
Dear Natalie,
your screencasts are amazing! Easy to understand, informative!
Always glad to see you keep adding great screencasts to your list :)
Thanks a lot for your work :)
Greetings from Munich, Germany
Maria
Thank you for your kind words!
Awesome tutorial. Perfectly clear. I wish the documentation on drupal.org could be as clear as this!
Thanks again! Seems like the drush tutorial is very popular, I should probably do more about it.
Yes please - Drush and Git!
Excellent tutorial. Makes me eager to use Drush immediately. Very clear with great examples.
Try it, you won't regret it. I wouldn't even be a Drupal developer without Drush.
I get to the part where the symlink is made but when I run that command it I get the error below...any ideas?
greg@greg-vbox:~/drush$ sudo ln –s /home/greg/drush/drush /usr/bin/drush
[sudo] password for greg:
ln: target `/usr/bin/drush' is not a directory
Try
sudo ln –s /home/greg/drush/drush /usr/bin/drushOr you can add drush to your $PATH
echo 'export PATH=$PATH:/path/to-drush' >> ~/.bashrc
The above did not work for me and as a linux newb I dont know why, maybe because I am using 10.04 x64 the file structure is different or maybe permissions on the target folder ?
After a whole day what did work and makes sense but may come back to bite me in the ass is
cd /usr/local/lib/
wget http://ftp.drupal.org/files/projects/drush-7.x-4.5.tar.gz
tar -vzxf drush-7.x-4.5.tar.gz
cd drush
chmod u+x drush
cd /usr/local/bin
sudo ln -s /usr/local/lib/drush/drush drush
gksudo gedit /etc/php5/conf.d/mcrypt.ini swap # for ;
Hope this helps someone.
P.S. Thanks for the vids natalie.
This is really good!
Who wrote it?
Please and thank you :)
Thanks for this, I've just been introduced to Drush v4.x to help manage my Drupal v7 sites, your work here has helped enlighten me some what to update my D7 core as required; so good karma to you!
Peace.
PB
Leave a comment