sudo: command not found
On a Debian server, when running a command with sudo, I got the error
1 |
sudo: command not found |
To fix this, you need to install “sudo” package. If you are logged in as non-root user, then you need to become root, for this, you can use the command
1 |
su - |
Enter the root password when it prompt for the password.
Once logged in as user root, you can install sudo with the command
1 |
apt install sudo |
To add a user to sudo group, run the command
1 |
usermod -aG sudo USER_NAME |
Or
1 |
adduser USER_NAME sudo |
If you don’t have a user, you can create a user with the command
1 |
useradd -m --shell /bin/bash USER_NAME |
To verify if the user has sudo rights, you can use the command “sudo -v”. You can also use “id” or “groups” command, which lists all groups the current user is in, you can verify if the user is part of sudo group.