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

前端 未结 6 610
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:24

    sudo su is not a command run within a shell -- it starts a new shell.

    That new shell is no longer running your script, and the old shell that is running the script waits for the new one to exit before it continues.

提交回复
热议问题