Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

root can't sudo

9 views
Skip to first unread message

T o n g

unread,
Sep 27, 2010, 8:00:02 PM9/27/10
to
Hi,

I had no problem invoking my scripts embedded with sudo as root before,
but not now in my new installation:

root@coral:~# echo abc | sudo tee /tmp/t
sudo: can't open /etc/sudoers: Permission denied
sudo: no valid sudoers sources found, quitting

root@coral:~# id
uid=0(root) gid=0(root) groups=0(root)

root@coral:~# ls -l /etc/sudoers
-r--r----- 1 root root 2354 2010-09-17 09:34 /etc/sudoers

root@coral:~# head -1 /etc/sudoers
# sudoers file.

What could be wrong?

Thanks

--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/i7raph$96h$1...@dough.gmane.org

Tom H

unread,
Sep 27, 2010, 8:20:01 PM9/27/10
to
On Mon, Sep 27, 2010 at 7:53 PM, T o n g <mlist4...@yahoo.com> wrote:
>
> I had no problem invoking my scripts embedded with sudo as root before,
> but not now in my new installation:
>
> root@coral:~# echo abc | sudo tee /tmp/t
> sudo: can't open /etc/sudoers: Permission denied
> sudo: no valid sudoers sources found, quitting
>
> root@coral:~# id
> uid=0(root) gid=0(root) groups=0(root)
>
> root@coral:~# ls -l /etc/sudoers
> -r--r----- 1 root root 2354 2010-09-17 09:34 /etc/sudoers
>
> root@coral:~# head -1 /etc/sudoers
> # sudoers file.
>
> What could be wrong?

grep root /etc/sudoers


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/AANLkTimGUqRTrZy8_R-8Q...@mail.gmail.com

T o n g

unread,
Sep 27, 2010, 8:40:01 PM9/27/10
to
On Mon, 27 Sep 2010 20:16:05 -0400, Tom H wrote:

>> What could be wrong?
>
> grep root /etc/sudoers

% grep ^root /etc/sudoers
root ALL=(ALL) ALL

It has always been there.

--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/i7rd64$96h$2...@dough.gmane.org

Thierry Chatelet

unread,
Sep 27, 2010, 9:00:02 PM9/27/10
to
I dont use sudo, but can you explain me,so I will go to bed with more
knowledge, why root would need sudo?
Thierry


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/201009280258.0...@free.fr

Kelly Clowers

unread,
Sep 27, 2010, 9:20:01 PM9/27/10
to
On Mon, Sep 27, 2010 at 17:58, Thierry Chatelet <tcha...@free.fr> wrote:
> I dont use sudo, but can you explain me,so I will go to bed with more
> knowledge, why root would need sudo?
> Thierry

I have used sudo as root - but with a username as an argument. Without
a username, it defaults to root, and I can't figure out why you would want that.


Cheers,

Kelly Clowers


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/AANLkTimeA-yMvrFoRLg=CDD1k_dpK7Gu...@mail.gmail.com

T o n g

unread,
Sep 27, 2010, 9:40:01 PM9/27/10
to
On Tue, 28 Sep 2010 02:58:05 +0200, Thierry Chatelet wrote:

> I dont use sudo, but can you explain me,so I will go to bed with more
> knowledge, why root would need sudo?

invoking my scripts embedded with sudo as root

--

--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/i7rg8i$qmi$2...@dough.gmane.org

Kousik Maiti

unread,
Sep 27, 2010, 10:00:01 PM9/27/10
to
sudo means what super user can do, you can also do provided you have given permission in /etc/sudoers file.

By default in certain system sudoers file is read only.If you want to change  that file make it writeable,modify and then again make it read only.  
--
Wishing you the very best of everything, always!!!
Kousik Maiti(কৌশিক মাইতি)
Registered Linux User #474025
Registered Ubuntu User # 28654

Tom H

unread,
Sep 27, 2010, 10:10:02 PM9/27/10
to
> I dont use sudo, but can you explain me,so I will go to bed with more
> knowledge, why root would need sudo?

It doesn't make any sense to use sudo as root without an "-u user"
(and therefore to sudo to root as root) but it should work.


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/AANLkTikkcA=y3X=93pmBXe5n7PA2F...@mail.gmail.com

Tom H

unread,
Sep 27, 2010, 10:20:01 PM9/27/10
to
On Mon, Sep 27, 2010 at 8:34 PM, T o n g <mlist4...@yahoo.com> wrote:
> On Mon, 27 Sep 2010 20:16:05 -0400, Tom H wrote:
>
>>> What could be wrong?
>>
>> grep root /etc/sudoers
>
> % grep ^root /etc/sudoers
> root ALL=(ALL) ALL
>
> It has always been there.

Sorry, no idea then.


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/AANLkTimSWPCLf7ko4zbA1...@mail.gmail.com

Tom H

unread,
Sep 27, 2010, 10:20:01 PM9/27/10
to
On Mon, Sep 27, 2010 at 10:09 PM, Tom H <tomh...@gmail.com> wrote:
> On Mon, Sep 27, 2010 at 8:34 PM, T o n g <mlist4...@yahoo.com> wrote:
>> On Mon, 27 Sep 2010 20:16:05 -0400, Tom H wrote:
>>
>>>> What could be wrong?
>>>
>>> grep root /etc/sudoers
>>
>> % grep ^root /etc/sudoers
>> root ALL=(ALL) ALL
>>
>> It has always been there.
>
> Sorry, no idea then.

Spoke too early.

Do you have the "!root_sudo" option set?


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/AANLkTikHmGrNQ-PKfBJMC...@mail.gmail.com

T o n g

unread,
Sep 27, 2010, 10:30:01 PM9/27/10
to
On Mon, 27 Sep 2010 22:16:34 -0400, Tom H wrote:

> Do you have the "!root_sudo" option set?

Nope:

$ sudo cat /etc/sudoers | grep root_sudo || echo no
no

Thank you all the same.

--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/i7rjhp$4p0$1...@dough.gmane.org

Tom H

unread,
Sep 27, 2010, 10:50:01 PM9/27/10
to
On Mon, Sep 27, 2010 at 10:22 PM, T o n g <mlist4...@yahoo.com> wrote:
> On Mon, 27 Sep 2010 22:16:34 -0400, Tom H wrote:
>
>> Do you have the "!root_sudo" option set?
>
> Nope:
>
> $ sudo cat /etc/sudoers | grep root_sudo || echo no
> no
>
> Thank you all the same.

You're welcome.

Do you have an "/etc/pam.d/sudo" file? Can another user use sudo? Any
hint about the reason for the failure in "/var/log/auth.log"?


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/AANLkTinbWdLRT3UswTFh92qskrn5=FKu3ii8F+=G9...@mail.gmail.com

T o n g

unread,
Sep 27, 2010, 11:00:02 PM9/27/10
to
My bad.

The failed environment is a linux-live environment that I built myself.
When mirroring it to HD, everything works fine. So it's actually the live
environment's problem, not sudo's.

Thanks again for your comprehensive tips, which I'll garter bellow in
case someone else need to troubleshoot:

- Make sure the 'root ALL=(ALL) ALL' line is in /etc/sudoers

% grep ^root /etc/sudoers
root ALL=(ALL) ALL

- should not have the "!root_sudo" option set

$ sudo cat /etc/sudoers | grep root_sudo || echo no
no

Also check,

On Mon, 27 Sep 2010 22:44:07 -0400, Tom H wrote:

> Do you have an "/etc/pam.d/sudo" file? Can another user use sudo? Any
> hint about the reason for the failure in "/var/log/auth.log"?

Thanks again.

--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/i7rla8$94d$1...@dough.gmane.org

Tom H

unread,
Sep 28, 2010, 12:00:02 AM9/28/10
to
On Mon, Sep 27, 2010 at 10:52 PM, T o n g <mlist4...@yahoo.com> wrote:
> My bad.
>
> The failed environment is a linux-live environment that I built myself.
> When mirroring it to HD, everything works fine. So it's actually the live
> environment's problem, not sudo's.
>
> Thanks again for your comprehensive tips, which I'll garter bellow in
> case someone else need to troubleshoot:
>
> - Make sure the 'root ALL=(ALL) ALL' line is in /etc/sudoers
>
> % grep ^root /etc/sudoers
> root ALL=(ALL) ALL
>
> - should not have the "!root_sudo" option set
>
> $ sudo cat /etc/sudoers | grep root_sudo || echo no
> no
>
> Also check,
>
> On Mon, 27 Sep 2010 22:44:07 -0400, Tom H wrote:
>
>> Do you have an "/etc/pam.d/sudo" file? Can another user use sudo? Any
>> hint about the reason for the failure in "/var/log/auth.log"?
>
> Thanks again.

You're welcome.


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/AANLkTi=wHezFLBGK+Lk3Fv6=rjSJwK5e8DtE=AK+...@mail.gmail.com

Alexander Hintzer

unread,
Sep 28, 2010, 3:10:01 AM9/28/10
to
Am 28.09.2010 02:16, schrieb Tom H:
> On Mon, Sep 27, 2010 at 7:53 PM, T o n g<mlist4...@yahoo.com> wrote:
>>
>> I had no problem invoking my scripts embedded with sudo as root before,
>> but not now in my new installation:
>>
>> root@coral:~# echo abc | sudo tee /tmp/t
>> sudo: can't open /etc/sudoers: Permission denied
>> sudo: no valid sudoers sources found, quitting
>>
>> root@coral:~# id
>> uid=0(root) gid=0(root) groups=0(root)
>>
>> root@coral:~# ls -l /etc/sudoers
>> -r--r----- 1 root root 2354 2010-09-17 09:34 /etc/sudoers
>>
>> root@coral:~# head -1 /etc/sudoers
>> # sudoers file.
>>
>> What could be wrong?
>
> grep root /etc/sudoers
>
>
Why should one use "sudo" in addition to being root and thus having all
rights?
I would understand if you add your own user to the sudoers file...but
this way...
Can you tell me the sense behind it? I mean i am really interested in,
because maybe there is something new i can learn about "sudo".


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/4CA192B6...@gmx.de

Camaleón

unread,
Sep 28, 2010, 6:20:02 AM9/28/10
to
On Tue, 28 Sep 2010 09:01:10 +0200, Alexander Hintzer wrote:

> Am 28.09.2010 02:16, schrieb Tom H:

>> On Mon, Sep 27, 2010 at 7:53 PM, T o n g wrote:
>>>
>>> What could be wrong?
>>
>> grep root /etc/sudoers
>>
>>
> Why should one use "sudo" in addition to being root and thus having all
> rights?

+1 :-)

Greetings,

--
Camaleón


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/pan.2010.09...@gmail.com

B. Alexander

unread,
Sep 28, 2010, 9:30:02 AM9/28/10
to
I was looking at this last night. As a test, I pulled root out of sudoers, and it gives the same error as it would for a non-root user, "root is not in the sudoers. This will be reported."

I can't figure out why it is giving you a permission denied. Are you running extended acls or anything like that? That is the only way that you should ever get a permission denied result for root.

--b

Stephen Powell

unread,
Sep 28, 2010, 9:50:01 AM9/28/10
to
On Tue, 28 Sep 2010 06:13:58 -0400 (EDT), Camaleón wrote:
> On Tue, 28 Sep 2010 09:01:10 +0200, Alexander Hintzer wrote:
>> Why should one use "sudo" in addition to being root and thus having all
>> rights?
>
> +1 :-)

I don't speak for the OP, but my guess is that the OP has a
script that he wants to be able to run either as his non-superuser
self or as root. The script needs to perform a function that
normally requires root privileges. There are two possible approaches:
(1) Do userid tests and have dual-path code: one for root and one
for a non-root user. Execute the special command directly if the
userid is root. Execute it via sudo if the userid is not root.
(2) Unconditionally execute the special command via sudo and don't
worry about who the userid is. The second approach is simpler.

--
.''`. Stephen Powell
: :' :
`. `'`
`-


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/1076335335.329489.1285...@md01.wow.synacor.com

Alois Mahdal

unread,
Sep 28, 2010, 10:20:03 AM9/28/10
to
On Tue, 28 Sep 2010 03:26:42 +0200, T o n g <mlist4...@yahoo.com>
wrote:

> On Tue, 28 Sep 2010 02:58:05 +0200, Thierry Chatelet wrote:


>
>> I dont use sudo, but can you explain me,so I will go to bed with more
>> knowledge, why root would need sudo?
>
> invoking my scripts embedded with sudo as root
>

I'm, not sure what you mean by "embedded" here, so my guess
is that you mean making something like this work for both
user and root:

user@machine ~/$ cat > aptupgscript.sh <<EOF
#!/bin/sh
echo Hello
sudo aptitude update
sudo aptitude upgrade
echo Update done by `whoami` || tee ~/done.log
EOF
user@machine ~/$ chmod a+x aptupgscript.sh
user@machine ~/$ ./aptupgscript.sh
Hello
Update done by user
user@machine ~/$ su
Enter password:
root@machine ~/$ ./aptupgscript.sh
Hello
Update done by root
root@machine ~/$

(Sorry for possible wrong details, I typed it from mind :D)


Thanks,
aL.

--
Alois Mahdal using Opera's revolutionary e-mail client:
http://www.opera.com/mail/


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/op.vjqxu...@aloism.cz.avg.com

Camaleón

unread,
Sep 28, 2010, 10:50:02 AM9/28/10
to
On Tue, 28 Sep 2010 09:42:40 -0400, Stephen Powell wrote:

> On Tue, 28 Sep 2010 06:13:58 -0400 (EDT), Camaleón wrote:
>> On Tue, 28 Sep 2010 09:01:10 +0200, Alexander Hintzer wrote:
>>> Why should one use "sudo" in addition to being root and thus having
>>> all rights?
>>
>> +1 :-)
>
> I don't speak for the OP, but my guess is that the OP has a script that
> he wants to be able to run either as his non-superuser self or as root.
> The script needs to perform a function that normally requires root
> privileges. There are two possible approaches: (1) Do userid tests and
> have dual-path code: one for root and one for a non-root user. Execute
> the special command directly if the userid is root. Execute it via sudo
> if the userid is not root. (2) Unconditionally execute the special
> command via sudo and don't worry about who the userid is. The second
> approach is simpler.

I see. A "lazy" programming issue :-)

Greetings,

--
Camaleón


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/pan.2010.09...@gmail.com

Karl Vogel

unread,
Sep 28, 2010, 3:20:01 PM9/28/10
to
>> On Tue, 28 Sep 2010 09:42:40 -0400 (EDT),
>> Stephen Powell <zlin...@wowway.com> said:

S> I don't speak for the OP, but my guess is that the OP has a script that
S> he wants to be able to run either as his non-superuser self or as root.

Easy. This preserves arguments including spaces:

#!/bin/sh
PATH=/usr/local/bin:/bin:/usr/bin; export PATH
test "`id -u`" -gt 0 && exec sudo $0 "$@"

whoami
for arg in "$@"; do
echo "[$arg]"
done
exit 0

--
Karl Vogel I don't speak for the USAF or my company

EXCUSE FOR GETTING TO WORK LATE #7:
The dog ate my car keys. We're going to hitchhike to the vet.


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/201009281854...@kev.msw.wpafb.af.mil

T o n g

unread,
Sep 28, 2010, 5:50:03 PM9/28/10
to
On Tue, 28 Sep 2010 09:42:40 -0400, Stephen Powell wrote:

> I don't speak for the OP, but my guess is that the OP has a script that
> he wants to be able to run either as his non-superuser self or as root.

Exactly. Thanks Stephen.

--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/i7tnie$75o$2...@dough.gmane.org

T o n g

unread,
Sep 28, 2010, 5:50:01 PM9/28/10
to
On Tue, 28 Sep 2010 16:14:24 +0200, Alois Mahdal wrote:

>>> I dont use sudo, but can you explain me,so I will go to bed with more
>>> knowledge, why root would need sudo?
>>
>> invoking my scripts embedded with sudo as root
>>
> I'm, not sure what you mean by "embedded" here, so my guess is that you

> mean making something like this work for both user and root: . . .

Thanks for the clear illustration. Yep, that's what I meant.

Besides, I share my aliases between my normal account and root account,
many of them are using sudo and I don't want to define two sets for the
same functionalities.

cheers

--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/i7tnh0$75o$1...@dough.gmane.org

B. Alexander

unread,
Sep 28, 2010, 8:40:01 PM9/28/10
to
Another way to do it would be to have the "invisible" sudo similar to

NEEDSUDO=""
if [ "`id -u`" != 0 ] ; then
  NEEDSUDO="sudo"
fi
echo abc | $NEEDSUDO tee /tmp/t

Then, if the uid is not 0 (root), then it inserts the sudo line...If run by root, then NEEDSUDO is empty.

--b

Chris Davies

unread,
Oct 1, 2010, 4:30:01 PM10/1/10
to
T o n g <mlist4...@yahoo.com> wrote:
> I had no problem invoking my scripts embedded with sudo as root before,
> but not now in my new installation:

> root@coral:~# echo abc | sudo tee /tmp/t
> sudo: can't open /etc/sudoers: Permission denied
> sudo: no valid sudoers sources found, quitting

What does this give you: ls -l $(type -p sudo)
Chris


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Archive: http://lists.debian.org/geqhn7x...@news.roaima.co.uk

0 new messages