I have shared hosting at Hot Drupal with SSH access. I have a couple of sites in subdirectories of my HTML root.

This is what worked for me.

I could not install Drush to /usr/bin/lib so I put it in my home directory ~/drush/drush

Then with PuTTY I navigated to the subdirectory where I want to use Drush. I created an alias with alias drush="~/whereyouputdrush/drush" where the ~/ is my home directory.

then I was able to use right there eg myusername@mydomain.com [~/public_html/meier]# drush help

(this is repeated from http://drupal.org/node/513896#comment-2346908 b/c I think this method should be added to the documentation, which currently says $ alias drush='/path/to/drush/drush' but not how to set path to your home dir with ~/)



moshe weitzman’s picture

thanks ... You could help even more by preparing text exactly as you propose it appears in readme.

decibel.places’s picture

proposed additions to README.TXT:

For Linux/Unix/Mac:
1. Untar the tarball into a folder outside of your web site (/path/to/drush)
- on shared hosting with SSH you can place Drush in your home directory ~/drush since you will not have access to usr/bin/
2. Make the 'drush' command executable:
$ chmod u+x /path/to/drush/drush
3. (Optional, but recommended:) To ease the use of drush,
- create a link to drush in a directory that is in your $PATH, e.g.:
$ ln -s /path/to/drush/drush /usr/bin/drush
- create an alias to drush:
$ alias drush='/path/to/drush/drush'
(this goes into .profile or .bash_aliases in your home folder)
- on shared hosting with SSH you can also create an alias with bash from the command line
navigate to the directory where you want to use drush (could be root public_html or a subdirectory)
create alias with '# alias drush="~/drush/drush"'

moshe weitzman’s picture

Status:Active» Needs work


Your last bullet may not be a good idea. The alias disappears after user terminates ssh session. The files .profile and .bashrc are needed in order to persist aliases across sessions.

decibel.places’s picture

thanks for that info about persistence - shows why a little knowledge is dangerous at the command line~!

adding alias drush="/drush/drush" or alias drush="~/drush/drush"to .bashrc creates an alias in the ~/ home directory, how do I put the aliases in subdirectories eg public_html/faith ?

I get No such file or directory error:

user@domain.com [~/public_html/faith]# drush help
-jailshell: drush/drush: No such file or directory
greg.1.anderson’s picture

Not familiar with jailshell, but try using a full path rather than ~/drush/drush. (From the error message, it looks like you used alias drush="drush/drush", but that might be an artefact of how the jail works.)

decibel.places’s picture

Title:adding a Drush alias in shared hosting» adding a Drush alias from bash command line

I forgot you need to exit and start a new session [retarded at the command line]

putting alias drush="~/drush/drush" in .bashrc

THEN EXITING AND RESTARTING is now working in subdirectories


so I would revise my proposed addition:
(note: I think the prompts $ and # are confusing, look like part of the code - guess it's part of the normal syntax/style)

- create an alias to drush:
$ alias drush='/path/to/drush/drush'
(this goes into .profile or .bash_aliases in your home folder)
- on shared hosting add a permanent alias with
alias drush='~/drush/drush' in .bashrc and/or .profile and/or .bash_aliases
where ~/ is your home/username directory and drush/drush is where you have installed drush relative to that directory
* You may need to exit your SSH session and log in again for the changes to take place!!!!!!!!!!!
- you can also create a temporary alias just for the session: navigate to the directory where you want to use drush
create the temporary alias with $ alias drush="~/drush/drush"

decibel.places’s picture

Title:adding a Drush alias from bash command line» adding a Drush alias in shared hosting

changing title to reflect emphasis on shared hosting and de-emphasis on temporary alias from command line

greg.1.anderson’s picture

Title:adding a Drush alias from bash command line» adding a Drush alias in shared hosting
Status:Needs work» Needs review
new853 bytes

I'm working on a change README.txt that depends on #654680: Simplify canonical site aliases, so I just went ahead and rolled a patch for you so that we can get this committed and not make conflicting patches.

The only change that I think is really necessary to the existing readme is to (a) add .bashrc to the list of config locations, and (b) add a warning that changes to bash settings files do not take effect until you exit and restart. (You can usually execute source .bashrc to apply the settings.) I don't know how many different bash config files we need to list (should we add .bash_customizations and /etc/bash.bashrc), but here's my stab at a minimal change. I assert that the note about ~ being your home directory is not notworthy, as most users should know that they can convert '/path/to/drush/drush' to '~/drush/drush' if the later works better for them.

Hopefully this will make things clearer and help some people without being too verbose.

decibel.places’s picture

As a Drush novice, I found the ~ confusing when following the DrupalCampNYC seminar. It did not look like the path given '/path/to/drush/drush'

Although many shared hosts do not allow shell access at all, I think some specifics about placing Drush in an atypical position below the usr/bin path AND how to alias it would be helpful.

I know that it would have saved me a couple of hours of trial and error.

And for the truly novice SSHer, a reminder to exit and restart to use the new settings would also be helpful! (but thanks for the source .bashrc tip)

Maybe this thread will be helpful to those struggling with these issues.

greg.1.anderson’s picture

I am torn between my genuine desire to help novices, and my personal opinions about how much information is too much in a readme file. Overall, I think that if you're at the point where you don't understand ~, then it would be better to look to outside information on the shell rather than expecting enlightenment from the drush readme file, as there are other important and useful concepts you would likely discover in the process. Therefore, were I to add more to what I already put in the message in my suggested patch above, I think it would be "man bash" or "google 'bash tutorial'". The first hit I got for the later was Getting Started with BASH, A Bash Tutorial" on hypexr.org. Reading this page would take less than two hours--reading all of "man bash" would take less than two hours. You might not understand it all as a novice, but it sure would be helpful.

No disrespect intended; the bottom line is, I stand by my initial recommendation from #8 above.

decibel.places’s picture

greg, I understand and basically agree - that is why I closed with "Maybe this thread will be helpful to those struggling with these issues."

very often I struggle with and solve a problem on a d.o. thread - and then later on a few people find the info useful enough to post thank yous

from the POV that someone looking to use Drush may know a thing or two about SSH - that is a point well-taken

as a former teacher, I also realize that the student may not grasp the content well enough to formulate a meaningful question (or Google search)

I am not lobbying for inclusion of every detail in README.TXT - but enough to provide info for addional learning, perhaps the hypexr.org manual you suggested.

my OP was a result of "discovering" a technique for a (turned out to be temporary) alias that was not specified in README or the DrupalCamp session - this thread has drifted a bit but it should be helpful for Drush noobs on shared hosting...

greg.1.anderson’s picture

Status:Needs review» Needs work

@moshe: I'm going to take one more pass on my patch to make it a little clearer for novices.

greg.1.anderson’s picture

Status:Needs work» Needs review
new1.76 KB

@decibel.places: Thank you for your patience. When you've been using bash for a while, it's sometimes easy to loose perspective about what "everybody should be expected to know", and you're right, the point of your OP was that quite a few people don't realise that ~ is your home directory.

Here is one more attempt at adding hints and pointers to help people get started without being too verbose about it. Let me know if you think it's clear enough.

decibel.places’s picture


thanks for your consideration

I think it is pretty clear.

I'm not sure that it's clear where you can install drush for someone trying to install drush in usr/lib but without permissions (as was my case - I could look but not touch)

where the "home" directory is (in my case ~/ points to home/myusername/ so it's actually a subdirectory of "home")

I wouldn't fret too much, I was able to figure it out so let's hope others will with a bit more info than I started with.

greg.1.anderson’s picture

@decibel.places: /home/myusername is, in Unix parlance, known as your "home directory", despite the fact that its parent directory is usually called "home" and is not, in fact, anyone's home directory. Most of the time users without root access will not be able to write to /usr/lib or /usr/local, but I think it is beyond the scope of the drush readme to go into that.

@moshe: I leave it up to you to take either #8 or #13 per your preference. I'll also roll it again if you'd like to see any changes.

greg.1.anderson’s picture

Status:Needs review» Fixed

Committed a slight variant of #13 to help out beginners. Just let me know if you'd like any further adjustments or additions.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.