LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Adding a user to the sudoers file? (https://www.linuxquestions.org/questions/slackware-14/adding-a-user-to-the-sudoers-file-683244/)

annihilan 11-13-2008 04:14 PM

Adding a user to the sudoers file?
 
I know how to add the user to the file basically, but how can I set this for a more or less normal user, with normal privileges and that I sudo to install and such? I have NO idea how to use vi, seriously it hurts my head.

keefaz 11-13-2008 04:22 PM

You can always create a sudoers file under your normal user account and then copy it in /etc (as root)
Just an idea though

trickykid 11-13-2008 04:25 PM

Quote:

Originally Posted by annihilan (Post 3341118)
I know how to add the user to the file basically, but how can I set this for a more or less normal user, with normal privileges and that I sudo to install and such? I have NO idea how to use vi, seriously it hurts my head.

Don't use vi, the proper way is to use visudo command to edit sudoers. It'll prompt if you make mistakes and it also locks the file while it's being edited.

vi is easy though, here are some of the basics:

i = insert mode (edit mode)
esc = command mode

x = delete present character
dd = delete whole line
dw = delete current word
o = start new line for editing from present line
a = start editing one character to the right

wq = write and quit
Shift+ZZ = write to the file and quit

rworkman 11-13-2008 04:26 PM

The sudo package shipped in Slackware right now doesn't seem to respect VISUAL or EDITOR from the environment - see visudo(8) and the configure flags used in the build script for why :)

In other words, learn to use vi :-)

EDIT: Pat just pointed out my oversight in the man page :/
I'm leaving the above text here though, as I don't much like to cover up errors :-)

From visudo(8):
Quote:

There is a hard-coded list of editors that visudo will use set at compile-time that may be overridden via the editor sudoers Default variable. This list defaults to the path to vi(1) on your system, as determined by the configure script. Normally, visudo does not honor the VISUAL or EDITOR environment variables unless they contain an editor in the aforementioned editors list. However, if visudo is configured with the --with-enveditor flag or the enveditor Default variable is set in sudoers, visudo will use any the editor defines by VISUAL or EDITOR. Note that this can be a security hole since it allows the user to execute any program they wish simply by setting VISUAL or EDITOR.

annihilan 11-13-2008 04:28 PM

Quote:

Originally Posted by trickykid (Post 3341135)
Don't use vi, the proper way is to use visudo command to edit sudoers. It'll prompt if you make mistakes and it also locks the file while it's being edited.

vi is easy though, here are some of the basics:

i = insert mode (edit mode)
esc = command mode

x = delete present character
dd = delete whole line
dw = delete current word
o = start new line for editing from present line
a = start editing one character to the right

wq = write and quit
Shift+ZZ = write to the file and quit

The thing is, I don't know how to actually do the commands, I su to root and then visudo, and then the content appears in my terminal window, I add what I want in, and then I can't figure out how to save it, where do I put in ZZ?
Help......... D:

trickykid 11-13-2008 04:36 PM

Quote:

Originally Posted by annihilan (Post 3341141)
The thing is, I don't know how to actually do the commands, I su to root and then visudo, and then the content appears in my terminal window, I add what I want in, and then I can't figure out how to save it, where do I put in ZZ?
Help......... D:

You can either then press ESC to go back into the command mode and issue :wq! to save and quit and or do a Shift+ZZ in command mode to quit and save.


All times are GMT -5. The time now is 07:34 AM.