44

I want to give a Fedora user sudo privileges. How do I do that?

0

3 Answers 3

49

As root (or with sudo from an account which already has the power), add the user to the wheel group:

gpasswd wheel -a username

I use gpasswd because not all versions of usermod have an easy way to add the user to a group without changing all the users' groups. However, on any recent Fedora, usermod username -a -G wheel should have the same effect.

Group membership does not take effect immediately — the details are complicated, but the easy answer is that the user whose account has been modified should log out and in again.


If you are using Fedora Workstation with the GNOME desktop environment, you can use the GNOME settings panel to add a user as an "administrator":

GNOME Settings: user

You will need to unlock the panel either by already being an administrative user (useful for adding the power to another account) or by providing the root password. The switch is grayed out in my screenshot because I'm the only administrative user on this system and it won't let you shoot yourself in the foot in that way. (The command line tools, of course, will.)

The GUI switch has the underlying effect of adding you the user to wheel, so it's exactly the same as the command line option.


If you are using Fedora Linux 14 or earlier, use visudo to edit the sudoers file, removing the # from this line:

%wheel  ALL=(ALL)       ALL

This is the default in the sudoers file on Fedora Linux 15 and newer, so adding the user to wheel is all you need to do. Note that (as above) this won't take effect immediately; the easiest thing to do is log out and in again.

See also this question and answer over on Server Fault for information on granting sudo-like "auth as self" behavior to wheel group members for graphical apps which use consolehelper or PackageKit.

0
3

I suppose that the first question is, do you have sudo installed on the server(s) in question? Assuming so, it is just a matter of deciding whether you want to treat the user as a unique entity or as part of a group, a group which may have only 1 member. The command visudo as root will give you access to edit the sudoers file, often /etc/sudoers.

the former:

user ALL= /foo/bar

the latter:

%group  ALL= /foo/bar

These are merely two examples, the sudo package has a tremendous number of features and settings options at your disposal. I recommend reading the sudoers, sudo's configuration file, manual. I would also recommend starting simple and building up to the actual desired configuration.

6
  • 1
    Actually, all I want is to be able to do simple admin stuff like sudo yum install blah.
    – tshepang
    Nov 29, 2010 at 16:52
  • Depending on the size of the set of "simple admin stuff" it may be more convenient to leverage sudo's aliasing to establish a list of allowed commands and provide privilege escalation to the list rather than to enumerate each with its own configuration.
    – Tok
    Nov 29, 2010 at 16:57
  • Not sure what you mean. I just wanted something as simple as adding user ALL=(ALL) ALL, without breaking the brain with the myriad sudo options? I ask because in Debian the recommended way is to add user to sudo group, so I wanted to know what it was in Fedora.
    – tshepang
    Nov 29, 2010 at 17:16
  • That syntax will work for Fedora as well, however, I would not recommend granting unrestricted sudo access to all commands as a general rule.
    – Tok
    Nov 29, 2010 at 17:34
  • @Tshepang - I missed the second part of your earlier question. I believe that Fedora will allow you to specify a user by name in the sudoers file without adding them to any group in particular. Have you experienced one or more problems with this approach?
    – Tok
    Nov 30, 2010 at 13:24
-3

Googled this:

How to make Fedora user a sudoer?

Watched this video:

https://www.youtube.com/watch?v=3uApwHl0PQA

Which directed to this utility (fedy):

http://satya164.github.io/fedy/

which can be installed with the following command (works for me in fedora 20):

su -c "curl http://satya164.github.io/fedy/fedy-installer -o fedy-installer && chmod +x fedy-installer && ./fedy-installer"

supply the requested password, once it is finished installing, run

su -c fedy

and the UI will run. you can then add your user to the sudoers list:

enter image description here

be sure to reboot after you make these changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.