I tried to install drush with composer from a script that is runing with sudo

$nameofuser `logname`
#drush installation
# Composer Global installation
curl -sS https://getcomposer.org/installer | php > /dev/null 2>&1
mv composer.phar /usr/local/bin/composer > /dev/null 2>&1
sed -i '1i export PATH="/home/"$nameofuser"/.composer/vendor/bin:$PATH"' /home/"$nameofuser"/.bashrc > /dev/null 2>&1
source /home/"$nameofuser"/.bashrc
composer global require drush/drush:dev-master > /dev/null 2>&1
if [ -f /usr/bin/drush ]; then
rm "/usr/bin/drush"
ln -s  /home/"$nameofuser"/.comoser/vendor/drush/drush/drush /bin/drush
ln -s  /home/"$nameofuser"/.comoser/vendor/drush/drush/drush /bin/drsuh

The restult is

lrwxrwxrwx 1 root root Dec 28 14:55 drush --> /home/user/.comoser/vendor/drush/drush/drush

drush command is not working instead ubuntu displays

 The programm drush ist corrently not installed you can install it by typing: 
 sudo apt-get install drush 

The result of

echo $PATH is


What is wrong here? how to get the $namefuser variable in to the $PATH, correctly, Why is the symbolic link to drush not working?

  • Logname is not defined. Try changing that to your user.
    – AWippler
    Dec 28, 2014 at 15:39
  • thats strange because it works for teh rest of the script but it workjs by replaceing /home/$nameofuser with ~ I have to test if this also works when there is already an user on a seted up system
    – Josh
    Dec 28, 2014 at 16:03
  • in your script, you mixed ".../.composer" and ".../.comoser"
    – JJoao
    Dec 28, 2014 at 19:17

1 Answer 1


The first line looks wrong. That should probably be


What you posted doesn't assign anything to nameofuser, and then you try to use it and it evaluates to an empty string.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .