[ -n $1 ]; do
sudo echo "$1 ALL=(ALL:ALL) ALL" >> /etc/sudoers;
shift # shift all parameters;
done
Then, run the script like this (assuming you saved it as addsudousers.sh):
nickw444@laptop ~ $ sudo ./addsudousers.sh username1 username2 somenewadmin bob
that is, space-separated.
To read the names from a file:
nickw444@laptop ~ $ sudo ./addsudusers.sh `cat listofusers.txt`
listofusers.txt should also be space-separated.
sudo echo "$1 ALL=(ALL:ALL) ALL" >> /etc/sudoers;
shift # shift all parameters;
done
Then, run the script like this (assuming you saved it as addsudousers.sh):
nickw444@laptop ~ $ sudo ./addsudousers.sh username1 username2 somenewadmin bob
that is, space-separated.
To read the names from a file:
nickw444@laptop ~ $ sudo ./addsudusers.sh `cat listofusers.txt`
listofusers.txt should also be space-separated.