Su = Switch User / Substitute User; it allows you to run a full shell as another user. It can be any user, but if you don’t specify then it’ll open a shell as the root user with its elevated privileges. It allows you to do everything the root user can while that shell is still open, until you exit.
Sudo = SuperUser Do; it allows you to run one command with elevated privileges as the root user. Once it’s done the command it usually then ends. You can actually also launch a full interactive shell with sudo -i but it’s not really used much as it’s easier to just type su and use that tool instead.
Doas = Dedicated Openbsd Application Subexecutor (seriously). It’s an alternative to Sudo that originated in Openbsd that also allows users to run a command with elevated privileges as the root user. Doas can also be used to open a full shell like Su (e.g. doas -su Username). Its code is smaller and tighter, and is seen as more secure than Sudo. It also has much more straight forward configuration. It’s newer than Sudo, so although Doas is in theory better, Sudo is the default widely used tool across the vast majority of Linux.
Yeah, Sudo has been around for ages and is in pretty much every distro. So Doas just hasn’t really taken off due to inertia. You can install it yourself in many distros, but people tend to default to what they know. I’m not sure if any linux distros default to it. Also tutorials all over the internet use “sudo” so it kinda embeds it more as THE tool.
It’s similar with a lot of the core GNU utilities. For example “ls” lists directories and it’s everywhere, but there are actually better written newer alternatives. They just aren’t as widespread because people tend to use the GNU utilities together. I personally like eza for example.
EDIT: Just to be clear; Sudo is NOT one of the GNU Core Utilities, but Sudo originated in 1980 according to wikipedia. Doas was released in 2015.
Su = Switch User / Substitute User; it allows you to run a full shell as another user. It can be any user, but if you don’t specify then it’ll open a shell as the root user with its elevated privileges. It allows you to do everything the root user can while that shell is still open, until you exit.
Sudo = SuperUser Do; it allows you to run one command with elevated privileges as the root user. Once it’s done the command it usually then ends. You can actually also launch a full interactive shell with sudo -i but it’s not really used much as it’s easier to just type su and use that tool instead.
Doas = Dedicated Openbsd Application Subexecutor (seriously). It’s an alternative to Sudo that originated in Openbsd that also allows users to run a command with elevated privileges as the root user. Doas can also be used to open a full shell like Su (e.g. doas -su Username). Its code is smaller and tighter, and is seen as more secure than Sudo. It also has much more straight forward configuration. It’s newer than Sudo, so although Doas is in theory better, Sudo is the default widely used tool across the vast majority of Linux.
Sudo is widely used, while Doas is in theory better ??
Yeah, Sudo has been around for ages and is in pretty much every distro. So Doas just hasn’t really taken off due to inertia. You can install it yourself in many distros, but people tend to default to what they know. I’m not sure if any linux distros default to it. Also tutorials all over the internet use “sudo” so it kinda embeds it more as THE tool.
It’s similar with a lot of the core GNU utilities. For example “ls” lists directories and it’s everywhere, but there are actually better written newer alternatives. They just aren’t as widespread because people tend to use the GNU utilities together. I personally like eza for example.
EDIT: Just to be clear; Sudo is NOT one of the GNU Core Utilities, but Sudo originated in 1980 according to wikipedia. Doas was released in 2015.