VectorLinux
November 27, 2014, 12:33:30 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Visit our home page for VL info. To search the old message board go to http://vectorlinux.com/forum1. The first VL forum is temporarily offline until we can find a host for it. Thanks for your patience.
 
Now powered by KnowledgeDex.
   Home   Help Search Login Register  
Please support VectorLinux!
Pages: [1]
  Print  
Author Topic: sudo and su  (Read 2819 times)
wibedo
Member
*
Posts: 6


« on: June 05, 2008, 11:28:06 am »

If I want to execute a command as root, VL will not accept the password.
If I use "su root", I can input the root-password and it will be accepted.
Is this okay?
Logged
bigpaws
Vectorian
****
Posts: 1857


« Reply #1 on: June 05, 2008, 11:48:19 am »

That is fine. You do not need to name root if you use
su alone.

Bigpaws
Logged
Triarius Fidelis
Vecteloper
Vectorian
****
Posts: 2399


Domine, exaudi vocem meam


WWW
« Reply #2 on: June 05, 2008, 01:55:02 pm »

If I want to execute a command as root, VL will not accept the password.
If I use "su root", I can input the root-password and it will be accepted.
Is this okay?

sudo requires more configuration than su. As I rule, I only use sudo for non-interactive tasks where a normal user has to do something that requires root privileges, and it would be inconvenient (or impossible) to type the root password every time.
Logged

"Leatherface, you BITCH! Ho Chi Minh, hah hah hah!"

Formerly known as "Epic Fail Guy" and "Döden" in recent months
caitlyn
Packager
Vectorian
****
Posts: 2876


WWW
« Reply #3 on: June 13, 2008, 07:21:48 am »

One of the big advantages of sudo is that it logs the commands you run with it.  I've occasionally done something stupid and caused breakage on my system.  Looking through my log and seeing what command I ran has saved me a lot of time and effort.

You need to do the following to make sudo work for you:

1.  Add your account to the wheel group.
2.  Open a terminal window and su to root.
3.  As root, run visudo.  This will bring up a special instance of the vi editor designed to work with your sudoers (sudo configuration) file.  Don't worry about the complexity of the file in front of you.  You only have to make a tiny, easy one character change.  Type in:

/wheel

and hit enter.  That tells visudo to search for "wheel" and take you to the first occurrence.  You'll see a section like this towards the middle of the screen:

Code:
##
# User specification
##

# root and users in group wheel can run anything on any machine as any user
root ALL=(ALL) ALL
#%wheel ALL=(ALL) ALL

Use your arrow keys (NOT your mouse) to position your cursor over the first character in the line

Code:
#%wheel ALL=(ALL) ALL

Type x

That's lower case x, no return.  The leading # should disappear and the line should now read:

Code:
%wheel ALL=(ALL) ALL

If so type in:

 :wq

and hit enter.  Your account will now work with sudo.

One caution:  NEVER use any editor besides visudo to edit your sudoers file.  By design that will damage the file and may render it useless.  vi and visudo aren't easy for people who aren't used to them but you really don't have a choice in this case unless you go through far more complicated steps than what I just described.

Good luck!



Logged

eMachines EL-1300G desktop, 1.6GHz AMD Athlon 2650e CPU, 4GB RAM, nVidia GeForce 6150 SE video
CentOS 6.5 (will try VL64-7.1 soon)

Toshiba Satellite A135-S4727,  Intel Pentium T2080 / 1.73 GHz, 2GB RAM, Intel GMA 950

HP Mini 110 netbook, 1.6GHz Intel Atom CPU, 2GB RAM, Intel 950 video, VL 7.1
wcs
Packager
Vectorian
****
Posts: 1144


« Reply #4 on: June 14, 2008, 09:05:14 pm »

Quote
One caution:  NEVER use any editor besides visudo to edit your sudoers file.  By design that will damage the file and may render it useless.

Oh, I didn't know that... I've seen the recommendation for using visudo before, but never thought it was an absolute requirement.

I've edited /etc/sudoers a couple of times using mousepad and medit, and it worked (meaning, it did what I wanted it to do).
Could I have messed up something else?!  Shocked
Logged
caitlyn
Packager
Vectorian
****
Posts: 2876


WWW
« Reply #5 on: June 14, 2008, 09:23:13 pm »

You probably didn't mess anything up.  visudo is, according to the sudo documentation, an absolute requirement.  Forcing you to use a special editor is supposed to be a security enhancement.

Interestingly enough visudo doesn't have to be vi.  You can configure sudo to use another editor as visudo and have it accepted.  I've seen nano used as a substitute in a distro that didn't include vi as part of the default installation.
Logged

eMachines EL-1300G desktop, 1.6GHz AMD Athlon 2650e CPU, 4GB RAM, nVidia GeForce 6150 SE video
CentOS 6.5 (will try VL64-7.1 soon)

Toshiba Satellite A135-S4727,  Intel Pentium T2080 / 1.73 GHz, 2GB RAM, Intel GMA 950

HP Mini 110 netbook, 1.6GHz Intel Atom CPU, 2GB RAM, Intel 950 video, VL 7.1
wcs
Packager
Vectorian
****
Posts: 1144


« Reply #6 on: June 14, 2008, 09:28:58 pm »

Quote
You probably didn't mess anything up
Good to know. So far it's working.

Quote
Interestingly enough visudo doesn't have to be vi.
Oh, that's better. I'm much more comfortable with nano.
I'm sure I would learn to enjoy the power of vi, but it's just too much at first sight...
Logged
rbistolfi
Packager
Vectorian
****
Posts: 2290


« Reply #7 on: June 15, 2008, 07:24:10 am »

AFAIK, the only thing visudo does is to not allow a saving if the file has not the proper sudoers format. It is a good feature, since a bad sudoers would leave you without a working login. That said, I use regular vim to edit it, I am a dangerous man Grin
Logged

"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!
wcs
Packager
Vectorian
****
Posts: 1144


« Reply #8 on: June 15, 2008, 01:22:35 pm »


Thanks. I only inserted a couple of lines in the middle of it, so it seems to be fine.
Logged
Joe1962
Administrator
Vectorian
*****
Posts: 2499



WWW
« Reply #9 on: June 16, 2008, 02:07:55 pm »

Using visudo is safe, because, as already stated, it checks the syntaxis of the sudoers file before saving. It is not, however a requirement, I only used visudo once, a long time ago, then ran off to more familiar editors. I've used mostly mcedit, kedit and kate, but also a few others.
« Last Edit: June 16, 2008, 05:56:54 pm by Joe1962 » Logged

O'Neill (RE the Asgard): "Usually they ask nicely before they ignore us and do what they damn well please."
http://joe1962.bigbox.info
Running: VL 7 Std 64 + self-cooked XFCE-4.10
exeterdad
Packager
Vectorian
****
Posts: 2046



« Reply #10 on: June 16, 2008, 05:50:34 pm »

Until they come out with a mousepadsudo or meditsudo, I'm gonna have to live dangerously. I mess up more stuff with vi Cheesy
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!