Beginning with shell scripting

Posted by Kevin Wyman on Ask Ubuntu See other posts from Ask Ubuntu or by Kevin Wyman
Published on 2012-10-27T08:26:39Z Indexed on 2012/10/27 11:23 UTC
Read the original article Hit count: 292

Filed under:
|
|

I am fresh into Ubuntu and one of my goals is shell scripting for personal (and maybe public) use.

I'm a novice, though I do understand some of the basics (e.g. what a variable, string, loop, etc... is) but to get the most of scripting I need to learn in-depth. I figure the best way to do that is to jump right into scripting and ask questions only pertinent to the stage I am at in my attempted script.

  • Scenario: I have edited my sudoers file to allow my non-root user to run sudo commands without being prompted for a password.

  • Question: In vim, what would be the best code to use for a function that checks whether this condition is [true], If not, prompt the user if they want the script to edit and save the sudoers file to make this condition [true]?

Layout - If condition is true, carry-on with rest of script. If condition is not true, the script silently edits/adds the line: %sudo ALL=(ALL:ALL) NOPASSWD: ALL in the sudoers file, saves and then continues on with the next part of the script.

Any help with this would be greatly appreciated and assist me in my journey to writing shell scripts.

© Ask Ubuntu or respective owner

Related posts about command-line

Related posts about sudo