LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware - Installation (https://www.linuxquestions.org/questions/slackware-installation-40/)
-   -   Sudo (https://www.linuxquestions.org/questions/slackware-installation-40/sudo-4175413552/)

ve1drg 06-26-2012 06:54 PM

Sudo
 
I am running Slackware 13.37. The latest release.
And I am learning.

I am trying to use the sudo command and it says I am not in the Sudoers file.

How do I fix this? Do I add my username to the group file?
I mean to ADM user or other root type user in that file? And yes I am in that file. But it doesn't seem to matter.

custangro 06-26-2012 07:06 PM

Quote:

Originally Posted by ve1drg (Post 4712856)
I am running Slackware 13.37. The latest release.
And I am learning.

I am trying to use the sudo command and it says I am not in the Sudoers file.

How do I fix this? Do I add my username to the group file?
I mean to ADM user or other root type user in that file? And yes I am in that file. But it doesn't seem to matter.

You would normally edit the sudoers file with the...

Code:

visudo
...command

-C

ve1drg 06-27-2012 07:20 AM

Would you or someone please provide me the commands to make once in the sudoer file?
And if this is the vi editor, how to I save what I do, and how do I get out of this editor??
I must learn VI but I keep putting it off.


Quote:

Originally Posted by custangro (Post 4712866)
You would normally edit the sudoers file with the...

Code:

visudo
...command

-C


schmatzler 06-27-2012 07:39 PM

Running commands with sudo can be a problem sometimes (example: running slackbuilds with correct file permissions).

Why don't you use "su" to login as the root user and run your command without sudo?

alekow 06-28-2012 02:44 AM

Quote:

Why don't you use "su" to login as the root user and run your command without sudo?
+1
Quote:

And if this is the vi editor, how to I save what I do, and how do I get out of this editor??
You can use the editor you like by typing in command such as:

Code:

EDITOR="mcedit" visudo
or similar.

ruario 06-28-2012 04:01 AM

If you are going to use sudo with slack you should add /usr/local/sbin /usr/sbin and /sbin to the path of your regular user as it will make life much easier. Additionally put the command 'complete -cf sudo' somewhere appropriate like your ~/.bashrc if you want command completion. Though before you do all that reconsider the advice from schmatzler and alekow regarding just using su.

The thing about sudo is that it works best when you have multiple admins on the same machine or want to grant access to individual commands to specific users. However for a personal machine it is pretty much pointless IMHO and for that reason I never understood why Ubuntu pushes it so hard given their primary target market.

Anyway, here are my thoughts from a similar thread in the past:

Quote:

Originally Posted by ruario (Post 4369340)
Consider if I wanted to run the fake command 'example' once as a root user. Here is what I would actually have to type (where $password is my actual password).

Using su:
su[Enter]$password[Enter]example[Enter][Ctrl]+d
(Note: That is '[Ctrl]' and 'd' together to exit the root session, you obviously aren't typing the '+' character)

Using sudo:
sudo[space]example[Enter]$password[Enter]

Ignoring the characters needed that are the same in both cases (i.e. 'example' followed by [Enter] and your password followed by [Enter]), you have to type 5 key presses to execute a single command as root via 'su' (s u [Enter] [Ctrl] d) and 5 key presses to execute a single command as root via 'sudo' (s u d o [space]). Or to put it another way, you save nothing using sudo.

If however you wanted to type two or more commands as root, you immediately start saving on the key presses by using 'su' instead of 'sudo'. Yes the second 'sudo' command does not require a password but as long as you have not closed your root session yet (i.e. no Ctrl+d) you don't have to type your password again with 'su' either and you save having to write 'sudo' for every single line.

There is also the point that outside of distros where 'sudo' is preconfigured (e.g. Ubuntu and derivatives) you save time configuring '/etc/sudoers' and setting up various admin variables for your regular user.

Indeed the other nice thing with using 'su' is that you can just open a root terminal for all your admin needs and you decide if and when you should close it, rather than relying on preconfigured time-out periods with 'sudo'.


ottavio 06-30-2012 05:30 AM

Quote:

Originally Posted by alekow (Post 4713898)
+1


You can use the editor you like by typing in command such as:

Code:

EDITOR="mcedit" visudo
or similar.

I believe Slackware's visudo is hard-coded to run vi.

Code:


 man visudo
      There is a hard-coded list of one or more editors that visudo will use set at compile-time that may be
      overridden via the editor sudoers Default variable.  This list defaults to "/usr/bin/vi".  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-env-editor option or the
      env_editor 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.


TobiSGD 06-30-2012 06:14 AM

Quote:

Originally Posted by ottavio (Post 4715620)
I believe Slackware's visudo is hard-coded to run vi.

Code:


 man visudo
      There is a hard-coded list of one or more editors that visudo will use set at compile-time that may be
      overridden via the editor sudoers Default variable.  This list defaults to "/usr/bin/vi".  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-env-editor option or the
      env_editor 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.


Believe is irrelevant when it comes to technical systems. A short look into the Slackbuild for sudo reveals that it is compiled with the "--with-env-editor" option. So specifying and editor works fine.

mrascii 08-13-2012 12:44 AM

Quote:

I never understood why Ubuntu pushes it so hard given their primary target market.
Obvious I think. It removes the temptation to work as root all the time and only one password is needed not two.

DNA
AKA mrascii


All times are GMT -5. The time now is 05:42 PM.