Installing Drush on *nix

Drupal: 16m
Video Series
Information

In this video we walk through the steps to install Drush on *nix system (i.e. Linux, Unix, or Mac OS X). Drush is not a normal Drupal project and the installation and set up is quite different than for a module. We cover requirements and downloading, then make sure Drush is executable and in our system $PATH variable so we can use Drush from any directory.

Discussion

Comments on this video

You need to be an active subscriber to comment. or .

Another great Tutorial!!! THANK YOU!!

I sometimes look for when the videos were created and the versions of the software being used and can't find that information. But that is hardly relevant to this one. This is funtastic information for any time!

I don't know why but I ran into a glitch for a while making my link... then it worked after some fiddling and honestly I don't know what I did. Somehow it was linking to the PHP file at first or something. I got it to work. But then I got to the part in the video making the PATH in the bash profile.... I got a little side tracked I guess, because I was recently fiddling with adding an ever changing quote of my own to my terminal (new computer needed some hood popping and I had to play with it to make it mine).
It is a System76 64Bit Ubuntu 11.04 Leopard Extreme box that I had completely pimped out so that it could make Tim Allen from Tool Time grunt like a primitive man...

  • Core i7 980X Extreme 3.33 GHz L2 12 MB QPI 6.4 GTs - 6 Cores with Hyperthreading
  • 24 GB - 6 x 4 GB - Corsair Vengeance Triple Channel DDR3 - 1600 MHz
  • 3 GB nVidia GeForce GTX 590 Classified

Pardon me, I just grunted and drooled all over my keyboard. If any of you have friends or family who care about you, ask them for the money to buy this box... it's not that cold in here but my turkey is done just thinking about it. Also I am not listing this to advertise or brag, I wanted to demo out the allowed HTML tags a little bit, and I strongly support people and companies who strongly support end user freedom such as Drupalize.me, github, hosts, and system76. I hope others will do the same. The money I've saved by not purchasing tools and software that handcuff me is much better spent on things that give not only me, but everyone else freedom and empowerment instead. I'll get off my soapbox now.

So I greatly appreciated seeing your other things like aliases in your bash profile!!!
Nice ones!

The git one looks perplexing to me.
You got me thinking maybe I'll play with mine for a little while in the near future in that regard. I just got a github account (paid) and just registered with Drupal.org and provided them with my public SSH key. I look forward to messing things up (err) learning how to do things properly and efficiently. ;-)

Please note that unless the reader of my comment is interested in playing with their .bash_profile(s) and related things, there is not much to see here, move along. I'm biding my time waiting to learn from the Professionals here at Drupalize.me to see how to use the combination of Drush and git to deploy a local development environment, and how to then use these tools, likely with SSH/SCP to put it on a remote host for a production site or two. The power of these tutorials and the work that is the result of Drupal is very impressive and I can't wait to learn and master as much of it as I can. I have some big ideas and hope to not just be a user who never gives back, but a contributor who profits by the fact that everyone who uses Drupal is literally standing on the shoulders of giants with really big hearts and work ethics. The least I can do is give something back, and right now I am fairly noob (new) so my contributions if any are very minor, but may appeal to other users at a similar level as me. Read on if this appeals to you.

I created my own bash profile changes initially a little while ago per my comments above ... maybe this post will be interesting to someone?
I welcome any constructive criticism as feedback on the code and how to do it differently. I'm not looking for an online debate about economics, honest money &/or politics, well at least not here... thank you.

$ gksu gedit /etc/bash.bashrc

I added the following code (the comments aren't in my file but are here for clarification and for fun here, this allowed html code quote feature is nice, I'll use it on my website but doubt my future potential audience (users) would appreciate the uber noob to end user superpowers ala GNU/Linux like we all do but maybe I'll plant a few seeds anyway and see what grows:

My terminal Ludwig von Mises Quote generator and quote logger

# I use curl to grab an auto generated Ludwig von Mises quote from mise.org:
curl http://mises.org/quote.aspx >quote.html
# Note: the above will show a transfer in the terminal
# I don't mind it showing but if I knew how to hide it I probably would.
# However, pragmatically speaking I like to know I'm connected to the internet(s)
# If the government shuts down free market economic sites with their kill switch
# I might have to get my non-virtual "bash" outta here!!! ;-)
#
# The following uses html2text on the file that I downloaded and wrote
# I pipe it into sed and do some magic to clean up the formatting a little bit
# It might not be perfect because sometimes the formatting on the original is not perfect
# neither am I, we are all a work in progress... but
#"the wise heart" always seeks knowledge
## - The wise heart is a reference to Emory University's Motto from Proverbs 18:15
#
# All of these files including the next one get over written each time I open a terminal
# I am sure one could do this differently, but I kinda was using these files to stage things
# I can then see what is going on and tweak my sed commands
# I decided to just leave them for reference purposes
html2text quote.html | sed -e "s/document.write(//g" -e "s/_/ /g" -e "s/[\;)\"]//g">lvmquote.txt
# To display the latest quote I run a simple cat command, actually twice
# I wanted to make a running log of Ludwig von Mises Quotes for future reference
cat lvmquote.txt >>lvmquotes.txt
# The above cat command makes the log file and is not shown in the terminal
# The next cat command is displayed
cat lvmquote.txt
# Lastly I call up cal to display the current calendar with today's date highlighted
cal

A nice resource is flossmanuals.net where one can learn the power of the CLI (command line interface, or terminal). Their description about manipulating images and resizing them ought to push anyone within 10 feet to dive right in and start hacking, tweaking, playing, and learning.
Reference: Flossmanuals.net

My advice, throw up an emacs or gedit and write some commands that your using with comments so you can reference them later, of course you can always fall back on the manuals (and ought to check them out) but it is nice to have your own custom cheat sheets. BTW, vivivi is the editor of the beast ;-)

Fiddling around after seeing this tutorial I found in my home directory a file that mentioned using a separate .bash_aliases and thought great idea!
So I made a file called .bash_aliases
~$ gedit .bash_aliases

#My Aliases
#note when using the allowed html <code> command on here you need to # on any emptylines between your <code> and </code> and to get > and < use the html code for these with the "& l t ;" and "& g t ;" without the spaces. Thanks for being patient with me learning this and sharing it here instead of playing around with it and not sharing that knowledge.
#
alias ll="ls -la"
alias clr="clear"
alias sites="cd /home/drgnu/Sites"

The above was truly inspired by seeing this tutorial, THANK YOU!!!

I noticed that I had the file in my home directory called .bashrc and it also tweaks some aliases, apparently it doesn't override my aliases and they both seem to work? Interesting, thought I'd share this for others to reference and perhaps comment on.

Here's what I see in my "virgin?" Ubuntu 11.04 64Bit .bashrc file:

gedit .bashrc
.bashrc:

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
#
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
#
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
#
# append to the history file, don't overwrite it
shopt -s histappend
#
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
#
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
#
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
#
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
#
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
#
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
#
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
#
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
#
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
#
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
#
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
#
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
#
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
#
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
#
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
#
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi

OH NO! The preview and comment pane hides really long bottom portions of posts so they can't be edited online. What to do? I just ctrl+a and ctrl+x then opened gedit and ctrl+v and finished my edits down here then ctrl+a ctrl+c and came back to the comment box here and ctrl+v

So this is a long comment, I will do my best not to do this again. For the tweaker/hacker in any of us, we can have lots of fun it appears.

A nice way to bide some time while we wait... now we can start to use DRUSH to make a local development site or two or more? Then I hope we get to see how to use git to put it all up on github and then follow the excellent SSH tutorial and use git to pull everything down onto our production site(s). I hope there is a tutorial on how to get it working on my host and with my mysql database. Needless to say I can't wait.

Earlier today, I found the wonderful work of quickstart and created a virtualbox that has a shared folder to where I have my sites (for development/sandbox) but will be using that drush and environment to play around and tweak with things as I learn about Drupal and brainstorm my genious noob ideas like implementing GNU PG with my future Drupal site! :-) Muahahaha!!! Drupalize.me.... what a Drush!!

I really am now think I'm going to become a part time hacker and developer to get pretty much exactly what I want to do done!

THANK YOU!!!

Steve, a.k.a. DrGNU

For whatever it is worth... I'm raving about Drupalize.me on my own personal website (not sure if many people are watching it, but I have a screen shot of my Terminal tweak results for anyone interested) it's over here.

Thank you again for all of the hard work your doing to teach noobs like me how to do all of this exciting stuff!!!

Best regards,

Steve

Wow Steve! Thanks for the great comments! I'm stoked to see you playing with the power. Enjoy! :-)

I had an issue with OSX Lion and the new drush 5.0... When using the drush command the following error occurred:

/usr/bin/env: bad interpreter: Operation not permitted

This is due to Lion Quarantining the files as they are from the internet. You can check if drush is quarantined by using the following code in your drush directory:

xattr -d com.apple.quarantine drush

Remove the quarantine attribute with:

xattr -d com.apple.quarantine drush

The Drush command should work now! I hope I saved someone the 2 hours of anguish this caused me.

Lullabot logo

Lullabot has trained thousands of Drupal developers & guided the development of some of the largest Drupal websites.