6

I am a newbie with server handling and Linux. I am trying to install composer on my server so that i can host my Laravel project onto it as mentioned in the tutorial in Ultimate Guide: Deploy Laravel 5.3 App on LEMP Stack. I ssh into the server and after installation of composer when I run sudo mv composer.phar /usr/local/bin/composer I am getting a message in the terminal:

-bash: sudo: command not found

I desperately need some deliberate help

9
  • Are you sshing into the server as root per chance?
    – Gillespie
    Commented Jun 8, 2017 at 18:37
  • If not, have you tried googling it? Seems like this is a very common problem.
    – Gillespie
    Commented Jun 8, 2017 at 18:39
  • no i am not sshin into the server as root.. I tried googling but not able to figure out a correct solution Commented Jun 8, 2017 at 18:48
  • It looks like sudo is just not installed or not in your path.
    – nsilent22
    Commented Jun 8, 2017 at 19:05
  • what shal i do @nsilent22 ?? Commented Jun 8, 2017 at 19:10

4 Answers 4

7

Sudo is probably not installed or not in your path

  1. check to see if you are root in this case sudo is not needed unless you are trying to impersonate another user. just run your command without sudo mv composer.phar /usr/local/bin/composer

  2. See if sudo is your path by running which sudo or echo $PATH. If sudo is not in your path, your path variable might be broken. You can try testing this by executing a common location for sudo /usr/bin/sudo or running locate sudo | grep bin to attempt to find its location.

  3. If you know that sudo was installed, or your path looks broken, try fixing your path. Check your distribution's env file (/etc/environment in ubuntu) to make sure that it is formatted correctly (script commands are illegal in this file)

  4. If you are not root and you want to run a command with root prvileges then you must install sudo. But if you don't have sudo and you are not root then you can't install it. In this case I recommend switching to the root user with su

  5. If you do not have the root password and you own the machine, you can reset the root password with a tutorial such as https://askubuntu.com/questions/24006/how-do-i-reset-a-lost-administrative-password

  6. After you manage to login as root install sudo with apt-get update; apt-get install sudosince you are using Ubuntu.

  7. Verify the the name of your sudoers group with visudo and modify your sudoers file if you need to. https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file-on-ubuntu-and-centos

  8. if you have an existing sudoers group or you create one you can add yourself to the group. For example if your sudoers group is called sudo run usermod -aG sudo myuser. The sudoers group by default in Ubuntu based Linux is sudo. A sudoers group entry looks like this: %sudo ALL=(ALL:ALL) ALL

If you are trying to impersonate another user and cannot install sudo, you can still use su if it is installed and you have permission / password for the other user.

e.g. su someuser

2
  • when i am using mv composer.phar /usr/local/bin/composer without sudo i get a message as permission not available Commented Jun 9, 2017 at 12:05
  • @SurajJeswara what is the exact comand you are using to connect with ssh? which login are you using?
    – yosefrow
    Commented Jun 9, 2017 at 14:28
5

As suggested in this post, you may have to install sudo in your server.

To do that, log in as root with the following command: su -. Then install sudo with your package manager (if you're in Ubuntu: apt-get install sudo).

Then add your user to the sudo group: usermod -aG sudo <username>.

Finally type exit to log out of the root account and go back to your user.

1

try to install your sudo using by first logging in as a root(su - ) and then try to install **apt-get or yum sudo **. Make sure your path variable is set so that you would be able to get binary.

which sudo

echo $PATH

0

If you already have root privilages and need sudo only to run existing code using sudo, then alias can be used as below:

alias sudo="$($@)"

Other option is to create a file with name sudo having below content and save it at system/user path:

#!/bin/bash
$@

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.