-1

From my limited understanding, the doas utility allows you to run any command as root but, by default, requires you to enter your own password instead of the root user's password.

How do I make it require root password instead?

4
  • You don't. Shared passwords - as you are describing - are bad for a lot of reasons. Commented Dec 2, 2021 at 8:46
  • Out of curiosity can you list some of those reasons?
    – NickKeeger
    Commented Dec 2, 2021 at 8:55
  • @NickKeeger The fact that su can be used with the root password to gain root access without even using sudo or doas is a big reason. This means that no manner of configuring sudo or doas would disallow a user with the root password from gaining root access. Also, changing the root password could be done by anyone with access to it, instantly cutting off access from everyone else.
    – Kusalananda
    Commented Feb 15, 2023 at 5:38
  • @NickKeeger - With root passwords it's harder to keep track in the logs who did what as root - Often you also don't want users to run everything on the system as root but only certain commands (this also holds for a single user system, most daemons have their own username)
    – Garo
    Commented Feb 15, 2023 at 5:44

1 Answer 1

1

This is not possible to achieve with doas, by design. If you need to run a command as root using the root password, you may do so on a Linux system using the su command like so:

su - -c "command"

(single dash is used to get the root environment when switching)

On a BSD system, you would instead use

su root -c "command"

(Note that the -c option is passed to the root user's shell. It is not an option to su in this case.)

2
  • The question was about doas. Also, as mentioned in the comments in the question: A system should not have a root password
    – Garo
    Commented Feb 15, 2023 at 5:48
  • 3
    @Garo "should not have a root password" is irrelevant as the question presumes that there is a root password. Note that I also have edited the given answer to address why using su in this case is the better approach.
    – Kusalananda
    Commented Feb 15, 2023 at 6:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .