8

when I set the EACCESS for npm and I was ran the chown command in my terminal for change owner permission but now i stuck in this sudo :" /usr/bin/sudo must be owned by uid 0 and have the setuid bit set" my version is : ubuntu14.04 LTS please help me guyz :)

Chirag thaker
  • 323
  • 2
  • 4
  • 15
  • 3
    Did you do what it says to do at this link: https://docs.npmjs.com/getting-started/fixing-npm-permissions That is the most brain-dead method of forcing an install to work I have ever seen. `chown -R myuser /usr/local`? Even for `/usr/local`, that is epically stupid. And you've apparently found out why. – Andrew Henle May 03 '16 at 12:14
  • /usr/bin/sudo mv /usr/local/bin/sudo{,2} hash -r Refer this https://unix.stackexchange.com/questions/419122/sudo-must-be-owned-by-uid-0-and-have-the-setuid-bit-set?newreg=b2490740fb214ce79c316ad76f859e0a – Sachin Adkar May 27 '19 at 19:45
  • finally, after finding too much i am really thanked https://askubuntu.com/users/10962/user10962 at this link : https://askubuntu.com/a/471503/528411 – Chirag thaker May 03 '16 at 12:44

11 Answers11

22

First restart your pc, and press the ESC key while Ubuntu is booting.

This will bring you up the boot menu.

Select Advanced Options.

Select your OS version in (recovery mode), and press Enter Key.

It will bring you up another screen. Now select “Drop to root shell prompt” and press Enter.

It will load a command line at the bottom of the screen.

Now run each of the following commands.

mount -o remount,rw /
mount --all
chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo
shutdown -r now
Abhi
  • 305
  • 5
  • 23
3

If you have root user password then:

1.Login as root user

2.open terminal

3.Enter following cmd's:-

mount -o remount /
chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo
chown root:root /usr/lib/sudo/sudoers.so && chmod 4755/usr/lib/sudo/sudoers.so
chown root:root /var/* && chmod 4755 /var/*

If you do not have root user password then:

1.Reboot your system in recovery mode(boot and press and hold esc button to enter in recovery mode)

here it looks like

2.Nevigate to (advance option for linux) by using down arrow button and press two times Enter

here it looks like

3.Nevigate to root by using down arrow button and press Enter

here it looks like

4.Now enter following cmd's:-

mount -o remount /
chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo
chown root:root /usr/lib/sudo/sudoers.so && chmod 4755/usr/lib/sudo/sudoers.so
chown root:root /var/* && chmod 4755 /var/*

5.press ctrl+d and then select resume option to boot normal

Kudos you have made it

1

Simple fix

1-enter image description here

2-select recovery

3-select root

4-mount -o remount,rw /

5-chmod u=rwxs,g=rx,o=rx /usr/bin/sudo /usr/bin/pkexec

6-reboot or exit

Netwons
  • 1,170
  • 11
  • 14
1

For me, I solved this by running these commands:

 $ init 1 
 $ mount -o remount /
 $ chown root:root /usr/bin/sudo
 $ chmod u+s /usr/bin/sudo
 $ reboot
James Risner
  • 5,451
  • 11
  • 25
  • 47
justme
  • 13
  • 4
  • 1
    This has worked for me. I didn't have any access of root user, but after following these commands, I got it working. Thanks @James Risner and justme – Hemant Nov 30 '22 at 11:43
0

Its beacuase of Permission issue

 $ su
 Password: <type your root password>

Switch to root user and run the command

# pkexec chmod a=rx,u+ws /usr/bin/sudo

Then check it by typing from the user

$sudo -l

it Works fine for me

Cheers....

Keval Mangukiya
  • 2,243
  • 2
  • 11
  • 13
0

Try this:

pkexec chown root:root /etc/sudoers /etc/sudoers.d -R

I've succeeded it

Akane153
  • 1
  • 1
0

To solve this issue, you need to boot into recovery mode which provides a scroll-down menu with an option to drop down to a root shell.

And type these commands one after another:

# remount disks in read-write mode
mount -o remount,rw /
mount --all

# return ownership
chown root:root /usr/bin/sudo

# fix permissions
chmod 4755 /usr/bin/sudo

After that, you can reboot and log in again.

You may try this, to know if It worked:

sudo -l
coolbeatz71
  • 928
  • 2
  • 10
  • 22
0

1- Alt + Ctrl + mode + F1

if login root ok if not do is

2- Alt + mode + F1

than do to path /usr/bin

3- cd /usr/bin than do is

chmod u+s sudo su mount umount sg pkexec ping passwd newuidmap newgrp newgidmap ksu gpasswd fusermount expiry chsh chfn chage unix_chkpwd

than do is

chmod g+s wall write locate unix_chkpwd

than change passwd root passwd

4- Alt + Ctrl + mode + F7

Or

5- Alt + mode + F7

than try su to login root

su

if not work do it again and change passwd user and root example my user is mizel

6- su - mizel

root only

7- su

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 24 '21 at 19:28
0

This worked for me

“sudo: /usr/bin/sudo must be owned by uid” Or sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set. Reason :This error occurs when incorrect permission or ownership is set on /usr/bin/sudo file.

Solution

Step 1 : Start the server in Single user mode using command at start.

  1. init 1

Step 2 : Once single user mode starts use below commands

  1. mount -o remount,rw /
  2. - chown root:root /usr/bin/sudo
  3. - chmod 4755 /usr/bin/sudo

Step 3: Now Reboot the Server and check.

  1. reboot //(linux command line)

enter link description here

Bmaxtar
  • 1
  • 2
0

This applies to those environments where they have docker / Kubernetes environment running and has host root file system mounted into the container / pod.

In this case host's root "/" is mounted as "/host" inside the pod.

kubectl exec -it mypod -- chown root:root /host/usr/bin/sudo && chmod 4755 /host/usr/bin/sudo

I have not tried creating a fresh Kubernetes pod but I guess that should work too.

Hem
  • 619
  • 13
  • 26