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
My problem is with sudo the script prompts for password. Is there any way that I could do this without prompting the user for password ???
Most definitely, if you don’t mind making that particular command ‘free for use’ for that particular user:
See basically my other answer here: Shell script – Sudo-permissions lost over time
The simplest thing that may work is
Also, you could sudo an arbitrary command on the same terminal (tty/vty), and
sudowill cache the authentication for a while (or untilsudo -k), so you may start the script and it will ‘remember’ the credentials from your earliersudoinvocation. I sometimes do this when composing pipes withsudo(just preceded them withsudo true)