Shell script calls sudo; how do I suppress the password prompt

前端 未结 5 841
萌比男神i
萌比男神i 2020-12-28 22:39

I am writing a simple shell script which changes the mac address of the network hardware. One of the line is :

sudo ifconfig eth0 hw ether 00:99:99:00:00:00
         


        
5条回答
  •  梦谈多话
    2020-12-28 22:42

    A safer way to do it would be:

    sudo visudo -f sudoers
    

    then add

    myuser ALL=NOPASSWD:/sbin/ifconfig
    

    to the editor window that appeared. Once you are done, use :x to quit

提交回复
热议问题