By default sudo is not installed on Debian, but you can install it. First enable su-mode:
su -
Install sudo by running:
apt-get install sudo -y
After that you would need to play around with users and permissions. Give sudo right to your own user.
usermod -aG sudo yourusername
Make sure your sudoers file have sudo group added. Run:
visudo to modify sudoers file
and add following line into it (if it is missing):
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
You need to relogin or reboot device completely for changes to take effect.
Answer from Maksim Luzik on Stack ExchangeBy default sudo is not installed on Debian, but you can install it. First enable su-mode:
su -
Install sudo by running:
apt-get install sudo -y
After that you would need to play around with users and permissions. Give sudo right to your own user.
usermod -aG sudo yourusername
Make sure your sudoers file have sudo group added. Run:
visudo to modify sudoers file
and add following line into it (if it is missing):
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
You need to relogin or reboot device completely for changes to take effect.
su and sudo are two different, but related commands. It is unusual for sudo not to be installed, but it may simply not be in your Path. Try /usr/bin/sudo command.
If indeed sudo is not available, you need as you surmised to use su, but it does not work in the same way as sudo. The simplest way to use it is to simply run:
su -
This will ask you for the root user's password, at which point you should probably apt install sudo, log out of the root shell, and then proceed as normal.
Mind that unlike sudo, which asks you for your password, su will ask you for root's password.
Sudo is probably not installed or not in your path
check to see if you are
rootin 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/composerSee if sudo is your path by running
which sudoorecho $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/sudoor runninglocate sudo | grep binto 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
rootand 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 withsuIf 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 sudosince you are using Ubuntu.Verify the the name of your sudoers group with
visudoand 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
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.
sudo: command not found - Apple Community
sudo: command not found - Raspberry Pi Stack Exchange
Linux Terminal Error: Sudo command not found
Command sudo not found
Videos
Hiya, I'm trying to input sudo commands on the linux terminal but all I get is
-bash: sudo: command not found
any fix for this?
In a terminal type:
which sudo
That should give you an output of something like:
/usr/bin/sudo
If that doesn't, then it's not installed on the machine. The only way to use the superuser account in that case is:
su -
It will ask for a password, but if you don't know the password for the root account you're not getting into the machine at that point.
You have to use su - command to log in as the root to install sudo tool. This will ask you to give the admin password. In Ubuntu, this is a random string that was generated by the OS during the installation. So you don't have a way to know it. There is a way to change the root password. But unfortunately, you need sudo command for that also.
So you have to reinstall Ubuntu on your machine.
$PATH is evaluated by your shell, so your check doesn't work as you expect it to.
/etc/sudoers is configured to replace your PATH with a default one.
sudo does not load a login shell environment before executing the command, so the default PATH from /etc/sudoers is used. su - does open a login shell, which involves loading /etc/profile. See man bash, section INVOCATION.
Just remove the PATH reset in /etc/sudoers. It's likely a rule called secure_path.
CentOS
In CentOS you can add PATH to the Defaults env_keep section:
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \
LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \
LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \
_XKB_CHARSET XAUTHORITY PATH"
Give sudo your current PATH with:
sudo env "PATH=$PATH" your_command