On a Debian server, when running a command with sudo, I got the error
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
su -
Enter the root password when it prompt for the password.
Once logged in as user root, you can install sudo with the command
apt install sudo
To add a user to sudo group, run the command
usermod -aG sudo USER_NAME
Or
adduser USER_NAME sudo
If you don’t have a user, you can create a user with the command
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.