Why can't I use 'sudo su' within a shell script? How to make a shell script run with sudo automatically

前端 未结 6 643
Happy的楠姐
Happy的楠姐 2020-12-29 09:22

I cannot figure out what\'s wrong with this. When I run it in terminal and enter password, nothing happens, but if I run every command separately in terminal, it works. Than

6条回答
  •  天命终不由人
    2020-12-29 09:33

    Because running "sudo su" opens a new shell and the command does not return until you exit from that shell. Perhaps split the script into 2 files: first one runs sudo and executes that 2nd script under sudo.

提交回复
热议问题