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
103k103 gold badges443 silver badges945 bronze badges
asked Jun 8, 2017 at 18:35
Suraj JeswaraSuraj Jeswara
4662 gold badges10 silver badges23 bronze badges
9
Sudo is probably not installed or not in your path
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 sudomv composer.phar /usr/local/bin/composer
See if sudo is your path by running
which sudo
orecho $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 runninglocate sudo | grep bin
to attempt to find its location.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)
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 withsu
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
After you manage to login as root install sudo with
apt-get update; apt-get install sudo
since you are using Ubuntu.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-centosif 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
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.
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
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
$@
Explore related questions
See similar questions with these tags.