So I made a tiny script to change my mac address but it requires me to enter my password to make the switch... what can I add to have it enter it for me?
sudo ifconfig en1 ether 00:11:22:33:44:55
you may add your ifconfig command for your id in your /etc/sudoers sudo config file
EDIT: I've realized by now that you can't actually do this unless you wrap these commands in a binary. For example, using the system() function from a C program. I guess that setuid shell scripts are such a bad idea that linux doesn't use them at all :).
While it can be dangerous in some circumstances, you can make your script setuid. To do this, put that command into a file like so:
#!/bin/bash
ifconfig en1 ether 00:11:22:33:44:55
Then set the permissions so that it's owned by root but only you can touch the file:
$sudo chown root file.sh
$sudo chgrp username file.sh
$sudo chmod 070 file.sh
Then make it suid:
$sudo chmod +s file.sh
Now you should be able to execute this file as your user, but have it run with root privileges.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With