I see people talking about doas saying it's just like sudo but with less features. I'm just wondering if there is any situation where you should use doas or if it's just personal preference.
On the one hand, doas is simpler. Less code means less bugs, and lower chance someone manages to hack it and gain admin rights. On the other hand, sudo is more popular, and so has a lot more people double-checking its security. Ultimately, I don't think it matters - when someone unauthorized gains admin rights, usually it's not due to bug in sudo or doas, but other problems.
I use doas just because. It's not necessary at all, but it can't hurt either (I think). It might be a bit more secure (fewer features -> fewer code -> fewer bugs -> fewer vulnerabilities, need to give password more often). Kinda cool if you want more minimalism for fun (I replaced startx with sx...)
Doas is more secure, sudo has had a few critical vulnerabilities in the past, because the codebase is much larger. Sudo has like a million features that most people don't need, but they significantly increase attack surface.
doas, afaik, was originally made for FreeBSD, so some of its features aren't compatible with/haven't been implemented for Linux. That may or may not be an important issue for you to consider.
When I thought about this question, I decided to ditch both sudo and doas entirely. I am certain this is an unpopular opinion, but I preferred setting up a granular permission + user system instead, and keeping root privileges for only a handful of use cases (primarily for system updates and package installations).
For anything else, a dedicated user is created, and given only permissions to do that exact thing only. Many of these users have no shell access at all, and for the ones that do, I use a password manager so I don't have to memorize passwords for all of these users.
Yes I did, and that's a very good point. What sudo does not allow me to do is grant a user access to modify or read specific files or directories. I can get both that and access to executing specific programs using a users/groups permission system.
Another thing I don't like about sudo is that you end up using the same password for everything, which is also the password for logging in. Putting higher privileges behind my same login password opens me to a single point of failure.
I mean, that's one of the things that definitely needs permissions, right? You're overwriting system config and executables for all users on your system. Otherwise a malicious actor could just replace firewall configs, or embed malicious code into your executables. If not /bin and /etc what else should need privileges?
The short answer is that my distro did not let me do this easily. But that was for good reason.
A system update would require too many privileges that it would be almost indistinguishable from root.
Currently, every user I have is restricted in what files it has access to. A system update user would need access to so many files, including install locations of all binaries, and non-binary installation paths of all current and future programs I install (some package installs modify /var, many modify /etc, and so on).
This user will also have access to all these programs, down to system applications. It can trivially break a permission system I come up with.
It may be possible to restrict system updates to a user, but it would be such a powerful user that its not really worth it.
What is the privileged action in pulling and applying updates your distro ships
Tell me again how you want to write system files with a non-admin account, and I'm going to show you my friend Lumpy, who will walk all over your machine so fucking fast. Fuck that, Lumpy's a genius. One of his underlings (he manages now) will do it on a lunch break.
It's really only more secure in the sense that in general more complicated programs have more things that can go wrong with them. Either bugs, or just user error.
That is a valid concern, and most people don't need or use any of sudo's extra features, so it's completely reasonable to switch to doas because of that, but it's not like there's some glaring security flaw in sudo that most people really need to worry about. Especially if they're not doing weird things in the config, which would mostly be the same people who could easily switch to doas anyway.
Well, i believe in all showcased cases from people here, they are NOT replacing sudo entirely (Except if some are from BSD or if I'm incorrect with this assumption).
They are just replacing their user habit with doas and use that command instead. In the end, all unix scripts or apps expect using sudo (If not, su) so... ### What's even the need to ?
Size : Installed on top of the already system present sudo.
Security : Only perhaps if you made a sudo alias to doas (But since it isn't entirely 1:1 identical, if anyone have a cleaner way of implementing that, I'm all hear)
Simplicity : You now have two tools. A easy to use keycard, and a key. The second is more complicated to use, so you use it rarely but it's still two tools instead of one.
Less dependencies : Again, unless you can actually replace it ENTIRELY, it's just an added tool (Still almost dependency free)