If you don’t know what it is, you probably shouldn’t be using it. That said, to edit your /etc/sudoers file you need to use
sudo visudo
You have two “modes”
• Command mode – Press ‘ESC’ to access.
• Insert mode – Press ‘I’ to access.
You’re always in one or the other.
• To move the insertion point around, press ‘ESC’ and use the arrow keys.
• Once you’re where you want to be, press ‘I’ and start entering text.
• To delete a character, you need to be in command mode, select the character and press the delete key. (Note: not the Backspace key) You can do this in insert mode, but it does some funky things with the text.
• To save your changes, in command mode, type :w and press enter.
• To quit, in command mode, type :q and press enter.
• To quit without saving any changes, in command mode, type :q! and press enter.
Be careful, if you mess it up, you will no longer be able to sudo. Then you need to sudo to fix it. Bit of a problem there. To fix it, you need to login as root, run visudo, and fix the file.
December 4, 2008 at 8:08 am
Thank you for this post. Helped me a lot with my ubuntu 🙂
January 16, 2009 at 11:08 am
I spent an hour trying to figure out the V! editor; thanks so much for the post.
February 1, 2009 at 5:52 pm
Very clear and concise. Helped me. Thanks.
July 18, 2009 at 10:28 pm
This was helpful. Thanks for posting it. For some reason I couldn’t delete text correctly until I realized I had to type ‘d’ and then press the right arrow. Pressing ‘d’ then down would delete a whole line! ‘Vi’va la Emacs!
March 5, 2012 at 6:47 pm
This was helpful — Thx
August 31, 2012 at 8:19 am
This is wonderful documents. Good job! Mathew
April 25, 2013 at 4:07 pm
Reblogged this on Muhammed Refaai and commented:
Interesting tip for adding your account on sudoers.d file! 😉
May 10, 2013 at 2:35 am
[…] source […]
May 10, 2013 at 3:06 am
Thanks for the help, you really saved me some time.
Reblogged on dtraindesigns
September 26, 2013 at 9:25 am
Clear and concise explanation, thank you!!!!
You saved me 🙂
November 28, 2013 at 3:26 pm
please I have a question but I can’t solve it, can you solve me. I must to do it in LUNIX.
>>
>>
>>
>>
– enter the command (visudo) t edit the /etc/sudoers file. what is the command Alias for /usr/bin/updated?
April 23, 2015 at 6:22 pm
My sudo is messed up but I could run visudo using: pkexec visudo
June 13, 2016 at 10:13 pm
if you’re using mac os x, you’re lucky
first, if you are using El Capitan, disable System Integration Protection (how to: http://osxdaily.com/2015/10/05/disable-rootless-system-integrity-protection-mac-os-x/ )
and then, go to /etc by pressing Shift+Command+G on desktop then type: /etc
you will find “sudoers” and “sudoers~orig”, that’s it! delete “sudoers” file then rename “sudoers~orig” to be “sudoers” (if you’re not allowed to rename, makesure you’re using your main account then change Everyone to Read and Write on Get Info)
REMEMBER!! this is your last chance to rescue sudo. if you messed up your sudo again, there’s no way except clean instal mac os x :.(
January 22, 2022 at 10:26 pm
[…] visudo (Only use this because it has validation included. If you don’t know how to use vi here are the quick basics you need to edit the file). To allow certain parameters there is an answer […]
August 25, 2022 at 8:23 pm
[…] visudo (Only use this because it has validation included. If you don’t know how to use vi here are the quick basics you need to edit the file). To allow certain parameters there is an answer […]