How to fix Alpine Linux -ash: sudo: not found

Many users who are used to classical Linux distributions will see the following error message when using sudo on Alpine Linux:

-ash: sudo: not found

You don’t need sudo in many use cases!

The easiest way to fix that is to just run the command as root.

In order to get into a root shell (if you are not already logged in as root), use

su

which expects you to enter the root password.

Now just run the original command without sudo.

Still want to install sudo?

If you still want to install sudo, just run

apk add sudo

This is often the best approach if you have e.g. scripts that are running sudo commands.