You are not logged in.

#1 2012-04-02 01:54:19

tuberbob
Member
Registered: 2012-04-02
Posts: 3

[SOLVED]Missed a character adding a line to Sudoers, cannot edit Sudoe

I have just about completed setup on my Acer netbook (D255 if you care). I am running Arch x64, openbox for WM, and a few other things that I do not believe really matter, as I know where I went wrong.

I was adding a shutdown menu (pygtk-shutdown) to my Openbox menu, and had it working with the caveat of the sudo requirement to shutdown. So, after testing and verifying that the menu worked, I added a line (user hostname=NOPASSWD: /sbin/shutdown -h now,/sbin/reboot) in the /etc/sudoers file (yes, I used 'EDITOR=nano visudo' to edit it, not nano or gedit, and yes, I changed it to my username and hostname) to allow non root users to shutdown, and forgot the ':' while typing. I saved the file, and sudo no longer works. While trying to figure out what went wrong, I re-read (online) the line I added, and that is when I saw the ':' that I know I missed.

I have my USB arch install media handy, inserted, and ready. I have not been able to find any clear instructions as to what to do from here.

I believe I need to chroot to the / partition on my netbook, and I followed a tutorial from the wiki to mount the folder I want into a temporary folder, but when I browse to /etc/, I see only sudoers.d - no sudoers file. I feel I went wrong somewhere in the chroot process, because it is my first time trying to chroot in any way.

I am hopeful that someone here will be able to walk me through it. I have managed to solve every single issue I have come up against over the last week, and I am 90% done...then this!

edit: Title

Last edited by tuberbob (2012-04-02 02:40:33)

Offline

#2 2012-04-02 02:06:37

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: [SOLVED]Missed a character adding a line to Sudoers, cannot edit Sudoe

I don't think you need anything nearly that complicated.

Can't you just use su?

$ su
password: <enter ROOT password here>
# EDITOR=nano visudo

or just log in as root and visudo.

EDIT: I suppose I'm not sure about this one - but logging in as root is worth a shot.

Last edited by Trilby (2012-04-02 02:08:38)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2012-04-02 02:09:57

bohoomil
Banned
Registered: 2010-09-04
Posts: 2,377
Website

Re: [SOLVED]Missed a character adding a line to Sudoers, cannot edit Sudoe

Logging in as root has nothing to do with sudo... I guess sudoers file should be recreated when visudo is run again.

BTW: 'su' is a part of shadow.

Last edited by bohoomil (2012-04-02 02:12:24)


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#4 2012-04-02 02:22:48

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: [SOLVED]Missed a character adding a line to Sudoers, cannot edit Sudoe

bohoomil wrote:

Logging in as root has nothing to do with sudo

Loggin in as root would allow him to run visudo without sudo.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2012-04-02 02:23:14

tuberbob
Member
Registered: 2012-04-02
Posts: 3

Re: [SOLVED]Missed a character adding a line to Sudoers, cannot edit Sudoe

Trilby wrote:

I don't think you need anything nearly that complicated.

Can't you just use su?

$ su
password: <enter ROOT password here>
# EDITOR=nano visudo

or just log in as root and visudo.

EDIT: I suppose I'm not sure about this one - but logging in as root is worth a shot.

When I call sudo, it gives me a parse error. I do not have the exact error now, as I was doing the searching on the netbook, and turned it off a while ago so I could reboot into the live environment. I have not tried su, and perhaps this really shows my ignorance, but are they not essentially the same thing?

Offline

#6 2012-04-02 02:24:46

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: [SOLVED]Missed a character adding a line to Sudoers, cannot edit Sudoe

Can you not just su to root rather than chrooting?

Assuming you do need to chroot, I don't think that sudoers.d would exist on the live media, though I'm not positive, so I don't think you are in /etc on the live media. What exactly did you do to chroot?

Further question: how important is it to keep any customisations you made to sudo? Could you just uninstall and reinstall the package, get a default set up and then reedit the sudoers file?

Do you have a backup you could copy the sudoers file back from?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#7 2012-04-02 02:28:59

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: [SOLVED]Missed a character adding a line to Sudoers, cannot edit Sudoe

tuberbob wrote:

I have not tried su, and perhaps this really shows my ignorance, but are they not essentially the same thing?

No. sudo allows designated users to run specified commands as other users (often as root).

su enables a user to "switch user" i.e. to become another user. Type

su

Give root's password at the prompt. You will now be root. Edit the file as necessary (or reinstall sudo or whatever).

Don't forget to exit when you are done or else you will stay logged in as root.

sudo is not even installed as part of the base Arch install. But the root account is enabled.

su has nothing to do with sudo so the fact that sudo is broken won't affect suing to root.

Last edited by cfr (2012-04-02 02:30:47)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#8 2012-04-02 02:30:23

tuberbob
Member
Registered: 2012-04-02
Posts: 3

Re: [SOLVED]Missed a character adding a line to Sudoers, cannot edit Sudoe

Well, there I went making this all kinds of complicated. I did not know that one could 'su' even when one cannot 'sudo.' TIL

This aspect of things is solved, but now I have to look into why the reboot still required a password.

edit: how rude of me, I forgot to thank you all for your help! Many thank yous...

Last edited by tuberbob (2012-04-02 02:31:39)

Offline

#9 2012-04-02 02:38:38

bohoomil
Banned
Registered: 2010-09-04
Posts: 2,377
Website

Re: [SOLVED]Missed a character adding a line to Sudoers, cannot edit Sudoe

Trilby wrote:

Loggin in as root would allow him to run visudo without sudo.

Of course, I only mentioned the obvious thing that su belongs to a different package to make the OP understand that there should be no problem booting to the system.


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#10 2012-04-02 02:50:57

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: [SOLVED]Missed a character adding a line to Sudoers, cannot edit Sudoe

For getting it to work without the password, you can take the hostname out of the mix, and just use

username ALL=NOPASSWD: /sbin/reboot

where "username" is your user name.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#11 2012-04-02 06:01:24

sonoran
Member
From: sonoran desert
Registered: 2009-01-12
Posts: 192

Re: [SOLVED]Missed a character adding a line to Sudoers, cannot edit Sudoe

tuberbob wrote:

(yes, I used 'EDITOR=nano visudo' to edit it, not nano or gedit, and yes, I changed it to my username and hostname) to allow non root users to shutdown, and forgot the ':' while typing. I saved the file, and sudo no longer works.

In the interest of the signal/noise ratio, I thought the point of using visudo is that it does a syntax check on sudoers and won't save the file if there are any errors. Glad you got it fixed, anyway.

Offline

Board footer

Powered by FluxBB