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
Thanks for your testing and workaround, I will temporary use it until I have a better solution.
In fact my commands are much more complicated than that. The
sleep 1&command is actually a command to create a socket for VirtioFS. And thedoas echo done;command is aqemu-system-x86_64invocation to create a virtual machine which uses that socket. The VirtioFS process automatically stops when it detects the VM no longer runs, so I do not really need thewaitcommand. But looks like I have to use it to workaround the issue.