Tag: sudo

  • sudo: command not found

    sudo: command not found

    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
    

    adding user to sudo group

    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.

  • sudo

    Linux Run Command as another user
    usermod
    sudo: command not found

    To allow a user to run sudo commands without a password, run

    visudo

    Find

    %sudo   ALL=(ALL:ALL) ALL

    Add below

    USERNAME_HERE    ALL=(ALL:ALL) NOPASSWD:ALL

    This needs to be added after generic rules.

    Example

    boby    ALL=(ALL:ALL) NOPASSWD:ALL