You are not logged in.

#1 2018-03-25 14:46:47

berat703
Member
Registered: 2018-03-25
Posts: 6

Error: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid

Hello everyone.

I got this error when i use sudo.I installed nodejs after i did a

 sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}  

to allow for npm install -g without needing sudo.

Then i got " sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set " error

 ls -l /usr/bin/sudo 

print this

 
-rwsr-xr-x 1 arc root 132408 Oca 21 19:06 /usr/bin/sudo

Offline

#2 2018-03-25 14:52:20

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,808

Re: Error: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid

How did the owner of sudo become arc?   
Use su to start a root shell (you will need the root password).  As root, change the ownership of sudo back to root.  Exit the root shell with ctrl-d.
Don't do this again tongue


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2018-03-25 14:54:52

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Error: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid

Welcome to the forums berat703 smile

What on earth led you to believe that the first command you ran was a good idea?
You might be able to recover by logging in as root and running...

chown -R root /usr/{lib/node_modules,bin,share}

No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#4 2018-03-25 15:14:06

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Error: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid

This happened because the nodejs programming language is a toxic environment that habitually suggests you mutilate your operating system for the sake of npm's convenience...

Fun fact: recently npm had a bug where they ran that chown command for you automatically if you used npm via sudo: https://github.com/npm/npm/issues/19883

They fixed it quite fast and issued an emergency patch release. Unfortunately no one can create a patch release for the many morons on the internet who suggest doing this manually and by offering this bad advice cause many people to inadvertently break their systems. sad

Oh well, now you know not to do that again. smile Have fun reinstalling your Arch Linux installation.

Slithery: simply chowning everything to root is not a solution, as there are files which are owned by different users. I wouldn't want to guarantee that this will catch everything even though it didn't also mutilate /var

OTOH with some care one might be able to use paccheck (from pacutils) to triple-check the ownership of all files on the system. At least the OP's command did not modify the group as well as the owner as many files e.g. commands in /usr/bin use setgid to run as some special per-software system user...

Last edited by eschwartz (2018-03-25 15:17:38)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#5 2018-03-25 16:59:39

berat703
Member
Registered: 2018-03-25
Posts: 6

Re: Error: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid

Slithery wrote:

Welcome to the forums berat703 smile

What on earth led you to believe that the first command you ran was a good idea?
You might be able to recover by logging in as root and running...

chown -R root /usr/{lib/node_modules,bin,share}

i'm glad to be here .Thank you smile.

I tried this code then print is

 
-rwxr-xr-x 1 root root 132408 Oca 21 19:06 /usr/bin/sudo

But if arc user  write "sudo su" , the error display again.

Last edited by berat703 (2018-03-25 17:05:02)

Offline

#6 2018-03-25 17:03:38

berat703
Member
Registered: 2018-03-25
Posts: 6

Re: Error: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid

Eschwartz wrote:

This happened because the nodejs programming language is a toxic environment that habitually suggests you mutilate your operating system for the sake of npm's convenience...

Fun fact: recently npm had a bug where they ran that chown command for you automatically if you used npm via sudo: https://github.com/npm/npm/issues/19883

They fixed it quite fast and issued an emergency patch release. Unfortunately no one can create a patch release for the many morons on the internet who suggest doing this manually and by offering this bad advice cause many people to inadvertently break their systems. sad

Oh well, now you know not to do that again. smile Have fun reinstalling your Arch Linux installation.

Slithery: simply chowning everything to root is not a solution, as there are files which are owned by different users. I wouldn't want to guarantee that this will catch everything even though it didn't also mutilate /var

OTOH with some care one might be able to use paccheck (from pacutils) to triple-check the ownership of all files on the system. At least the OP's command did not modify the group as well as the owner as many files e.g. commands in /usr/bin use setgid to run as some special per-software system user...

You are definitely right for all your said.Especially about in npm.So i don't wanna reinstall OS.Have i another way this problem's solution?

Offline

#7 2018-03-25 17:32:20

loqs
Member
Registered: 2014-03-06
Posts: 17,493

Re: Error: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid

berat703 wrote:
Eschwartz wrote:

Oh well, now you know not to do that again. smile Have fun reinstalling your Arch Linux installation.

OTOH with some care one might be able to use paccheck (from pacutils) to triple-check the ownership of all files on the system. At least the OP's command did not modify the group as well as the owner as many files e.g. commands in /usr/bin use setgid to run as some special per-software system user...

You are definitely right for all your said.Especially about in npm.So i don't wanna reinstall OS.Have i another way this problem's solution?

Emphasis added

Offline

#8 2018-03-25 17:49:03

seth
Member
Registered: 2012-09-03
Posts: 51,908

Re: Error: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid

berat703 wrote:

But if arc user  write "sudo su" , the error display again.

 ... and have the setuid bit set ..
chmod u+s /usr/bin/sudo

Still run paccheck - and purge npm....

Online

#9 2018-03-25 18:41:05

berat703
Member
Registered: 2018-03-25
Posts: 6

Re: Error: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid

seth wrote:
berat703 wrote:

But if arc user  write "sudo su" , the error display again.

 ... and have the setuid bit set ..
chmod u+s /usr/bin/sudo

Still run paccheck - and purge npm....

It's worked! Thanks!

Offline

Board footer

Powered by FluxBB