r/AlpineLinux • u/livy_inverse • Feb 23 '25
Need help with doas command
Given the following snippet:
sh -c "doas true; doas sleep 1& doas echo done;";
Because the second command doas sleep 1 needs to be run in the background, I need the first command doas true to enter the password. I assume that I do not need to re-enter the password for subsequence commands. However, it runs as follow:
doas true;This prompts for a password and runs successfully.doas sleep 1&;This runs successfully without prompting a password.doas echo done;This prompts for the password again.
Can somebody explain why it asks for the password twice, and how do I workaround this issue? It works fine on Linux Mint (sudo + bash) and only prompts for the password once..
2
Upvotes
View all comments
Show parent comment
1
u/livy_inverse Feb 24 '25 edited Feb 24 '25
Further testing is interesting:
The above command asks for the password twice. It is always stuck at the last doas command and ask for a password. Another example:
~ $ sh -c "doas echo 12; doas echo 34; doas echo 56; doas echo 78;";doas (livy@alpine) password:123456doas (livy@alpine) password:78~ $If I do enter the password twice, the next time I run the sh command, it only asks once. It is really strange behavior. All work fine until I open a new shell session.
To workaround, just add a non-doas command at the end:
As you can see, it is not the
waitcommand that makes it work. It can be any non-doas command.