VMware Cloud Community
SBC350
Enthusiast
Enthusiast

Need help to edit sudoers using script

Hi, im using a kickstart script to automate my ESX installation.

There is a line in the script used to uncomment 1 line in sudoers but it uncomment 2 lines concerning wheel.

Here is the script: sed -i 's/# %wheel/%wheel/g' /etc/sudoers

Here is the part I want to edit in sudoers "# %wheel ALL=(ALL) ALL":

"# Uncomment to allow people in group wheel to run all commands

"# %wheel ALL=(ALL) ALL

"# Same thing without a password

"# %wheel ALL=(ALL) NOPASSWD: ALL

Thank you

If you found this or any other answer useful please consider the use of the Helpful or correct buttons to award points

Alex

Consultant - VMware Specialist

If you found this or any other answer useful please consider the use of the Helpful or correct buttons to award points Alex Consultant - VMware Specialist
0 Kudos
2 Replies
mcowger
Immortal
Immortal

why not just append the line you want to the end (rather than trying to uncomment):

echo "Line you want to appear" >> /etc/sudoers






--Matt

VCP, vExpert, Unix Geek

--Matt VCDX #52 blog.cowger.us
SBC350
Enthusiast
Enthusiast

I finally found my own answer here :

sed -i '/NOPASSWD/!s/# %wheel/%wheel/g' /etc/sudoers

If you found this or any other answer useful please consider the use of the Helpful or correct buttons to award points

Alex

Consultant - VMware Specialist

If you found this or any other answer useful please consider the use of the Helpful or correct buttons to award points Alex Consultant - VMware Specialist
0 Kudos