LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 07-05-2010, 05:14 PM   #1
judoka
Member
 
Registered: Jul 2009
Distribution: Ubuntu 14.04 LTS, CentOS
Posts: 218

Rep: Reputation: 16
Red face How to use Sudo in Fedora?


When I type sudo [command] it prompts for my password and after I enter it it tells me that i'm not in the sudoers file. How do i fix this?
 
Old 07-05-2010, 05:32 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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.
 
Old 07-05-2010, 05:51 PM   #3
judoka
Member
 
Registered: Jul 2009
Distribution: Ubuntu 14.04 LTS, CentOS
Posts: 218

Original Poster
Rep: Reputation: 16
Ok, thx, can i just use su in fedora like sudo in ubuntu?
 
Old 07-05-2010, 06:26 PM   #4
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,142

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
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!
 
Old 07-05-2010, 09:24 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
you can set it ( not set by default) if you want . But i never found a good ( or bad) reason to do so .
use su or " su - "
"su - " is preferred

the two commands do different things
 
Old 07-05-2010, 09:40 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,139

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
Quote:
Originally Posted by judoka View Post
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.
 
Old 07-05-2010, 09:59 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
Quote:
Now wait for this to become a flamefest re unleashing the four horsemen of the Apocalypse by even suggesting "su" usage.
that is a old and LONG flame

yes there is a security hole with sudo ,but if set up correctly ,(as far as i know there are no exploits in the wild )

it is more personal choice
one or the other .
 
Old 07-05-2010, 11:34 PM   #8
judoka
Member
 
Registered: Jul 2009
Distribution: Ubuntu 14.04 LTS, CentOS
Posts: 218

Original Poster
Rep: Reputation: 16
Thanks for the info.
 
Old 07-06-2010, 11:44 AM   #9
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,142

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
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.
 
Old 07-11-2010, 07:28 PM   #10
ShellyCat
Member
 
Registered: Jul 2007
Distribution: Slackware 13
Posts: 178

Rep: Reputation: 29
Post

Quote:
Originally Posted by DavidMcCann View Post
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
 
Old 07-11-2010, 09:22 PM   #11
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
the reason vi was not working using the " su " command on fedora
is that MOST things will also NEED the root $PATH also
use " su - "
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
Sudo password for fedora pradeeprajkumar Fedora 2 06-16-2010 11:01 AM
Fedora 9, sudo atmurali Linux - Software 1 11-23-2009 06:13 AM
Fedora 11 sudo has a 20 second start delay manuleka Linux - Newbie 25 06-22-2009 09:18 PM
Sudo on Fedora abhijeetudas Linux - Security 2 12-02-2005 09:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration