Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
As unprivileged user run 'man sudoers'. The manual page should show you how the /etc/sudoers file should be used. Log in as root user and run 'less /etc/sudoers'. Reading /etc/sudoers will show you examples you could adapt to your needs. Now run 'visudo' to edit /etc/sudoers. Please do not use any other editor as visudo checks for syntax errors when you write out the file to disk.
I never bother with setting up sudo. What's wrong with typing "su" and giving the root password?
If you want to edit /etc/sudoers, then enter "EDITOR=nano" before using "visudo". You really don't want to be exposed to sudoers and vi at the same time!
Ok, thx, can i just use su in fedora like sudo in ubuntu?
Sort of -
Code:
su -c "<command>"
is the closest equivalent. "su" (or "su -") actually cause you to become the root user - see the manpage (su requires the root password, not yours like {usually} sudo).
Now wait for this to become a flamefest re unleashing the four horsemen of the Apocalypse by even suggesting "su" usage.
You might (or perhaps not) be interested in the background. To use "su", you obviously need to know the root password, and you can then do anything. To use "sudo", you use your own password and it's possible to set the permission to apply only to set commands, rather than to everything as in Ubuntu.
Think of an enterprise situation. A system administrator comes to help someone. They use "su" to take control of the computer. The same administrator wants to delegate a particular task to one or more reliable people. They put the trustees in the sudoers file, with permission to carry out a specific job. When these people use that privilege, they give their password to prove it's not just anyone sitting in their seat.
With your own computer at home, it seldom matters what you use. People just like arguing about it, like Gnome vs KDE, or vi vs emacs.
I never bother with setting up sudo. What's wrong with typing "su" and giving the root password?
If you want to edit /etc/sudoers, then enter "EDITOR=nano" before using "visudo". You really don't want to be exposed to sudoers and vi at the same time!
I found this difficult, because it would give me the error "can't use insert in vi mode" (or something to that effect). I don't know vi very well to begin with, so this idea of "vi mode" in nano not allowing me to insert text drove me nuts! (After all, what's the point?)
As others have said, though, using "visudo" verifies the file before writing it. But if you're making a simple change and pretty confident you won't screw it up, there's an easier way:
Code:
su root
cat /etc/sudoers >> ~/sudoers-tmp
nano -w ~/sudoers-tmp
(Make your edits, triple-check it, press CTRL+O to write, then press CTRL+E to exit.)
cat ~/sudoers-tmp >> /etc/sudoers
(The double-cheveron ">>" is very important, otherwise I am appending the changed file to the original, where I want to overwrite it!)
cat /etc/sudoers (To check you overwrote it correctly.)
Added to "sudoers" to allow a user to run "updatedb" to update the database for slocate:
Code:
%wheel ALL=/usr/bin/updatedb
I had to also add this user to the "wheel" group (edit /etc/group):
Code:
wheel:x:10:root,username
I put my actual username, not "username”
This works, but bizarrely, I am not asked for a password...supposedly, sudo should ask for my user's password by default. Maybe I am misunderstanding something.
Last edited by ShellyCat; 07-11-2010 at 07:30 PM.
Reason: put 2 lines in the wrong order
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.