bash – sudo: command not found | git base

sudo: command not found: 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.


Since it’s a commercial server you won’t have access to root account nor be able to operate with root privileges. This means you won’t be able to run sudo nor install packages. What you can try to do is:

  • Check if you have access to a compiler and compile what you want for yourself and in your home space.
  • Check if you can run a virtual machine. This might let you run your private instance of an OS, on which you would install packages.

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.


In a new Debian server install I too found out that sudo is not installed by default, but it can be done as root:

$ su root
# apt install sudo

What puzzled me is that I still got errors with visudo and usermod:

# visudo
bash: visudo: command not found

# apt install visudo
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package visudo

Actually, visudo is included with the sudo package, it was just not in the PATH for root:

# dpkg -S visudo
sudo: /usr/sbin/visudo
sudo: /usr/share/man/man8/visudo.8.gz

So I added it to the root’s ~/.bashrc.

PATH=$PATH:/usr/sbin

Now it can find visudo and usermod which can be used to setup sudo access.


Leave a Comment