VectorLinux

Please login or register.

Login with username, password and session length
Advanced search  

News:

Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

Author Topic: sudo and su  (Read 3027 times)

wibedo

  • Member
  • *
  • Posts: 6
sudo and su
« on: June 05, 2008, 12:28:06 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?
Logged

bigpaws

  • Vectorian
  • ****
  • Posts: 1869
Re: sudo and su
« Reply #1 on: June 05, 2008, 12:48:19 pm »

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
    • my website
Re: sudo and su
« Reply #2 on: June 05, 2008, 02: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
    • The Linux Works
Re: sudo and su
« Reply #3 on: June 13, 2008, 08: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: [Select]
##
# 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: [Select]
#%wheel ALL=(ALL) ALL
Type x

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

Code: [Select]
%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
Re: sudo and su
« Reply #4 on: June 14, 2008, 10: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?!  :o
Logged

caitlyn

  • Packager
  • Vectorian
  • ****
  • Posts: 2876
    • The Linux Works
Re: sudo and su
« Reply #5 on: June 14, 2008, 10: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
Re: sudo and su
« Reply #6 on: June 14, 2008, 10: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: 2301
Re: sudo and su
« Reply #7 on: June 15, 2008, 08: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 ;D
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
Re: sudo and su
« Reply #8 on: June 15, 2008, 02: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
    • Joe1962's Website
Re: sudo and su
« Reply #9 on: June 16, 2008, 03: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, 06: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
Re: sudo and su
« Reply #10 on: June 16, 2008, 06: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 :D
Logged