Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am facing a issue. When I try to do sudo on my terminal I get:

sudo: must be setuid root

I googled for the problem and did as the suggestions like setting permission of sudo but they were already in the required state. Cannot figure out what may be the problem. Please help.

Thanks

Output of mount:

 /dev/sda8 on / type ext4 (rw,errors=remount-ro) 
 proc on /proc type proc (rw,noexec,nosuid,nodev) 
 sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) 
 none on /sys/fs/fuse/connections type fusectl (rw) 
 none on /sys/kernel/debug type debugfs (rw)
 none on /sys/kernel/security type securityfs (rw) 
 udev on /dev type devtmpfs (rw,mode=0755)
 devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
 tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
 none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
 none on /run/shm type tmpfs (rw,nosuid,nodev)
 /dev/sda6 on /home type ext4 (rw)
 /dev/sda7 on /var type ext4 (rw)
 /home/incaendo/.Private on /home/incaendo type ecryptfs (ecryptfs_check_dev_ruid,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_unlink_sigs,ecryptfs_sig=b746275454680798,ecryptfs_fnek_sig=2164f6a8d7aa74c7)
 gvfs-fuse-daemon on /home/incaendo/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=incaendo)
share|improve this question
    
What's the output of ls -l $(which sudo)? –  Eliah Kagan Mar 6 '13 at 6:10
    
its -rwxr-xr-x 1 root root 69708 Jun 1 2012 /usr/bin/sudo –  Sankalp Mishra Mar 6 '13 at 6:19
add comment

3 Answers

Reinstalling the sudo package using

pkexec apt-get --reinstall install sudo

will set sudo's setuid flag. If that fails, try reinstalling it using your graphical package manager or aptitude. If that fails too, set sudo's setuid bit manually:

pkexec chmod u+s /usr/bin/sudo

If that fails as well with error "pkexec: must be setuid root", then check that the filesystem containing /usr/bin hasn't been accidentally mounted with the nosuid option set. Examine the output of mount.

If that is not the case either, then check if any binary in /usr/bin has its setuid bit set, using:

find /usr/bin -perm 4755

This should list at least passwd, sudo, and the likes. If there is none, then surely a stray cosmic ray has kicked those setuid bits over (or maybe this was you after all, with an overzealous chmod -s * because it is rumoured that setuid is bad?)

Either way, you will first have to reestablish your sudo rights. I have described the way to do that in a separate answer to this question. Once you have those, reinstall every package containing a setuid binary, or chmod each binary manually, as shown at the top of this answer.


Unfortunately, as the answer to another question states, there is no easy way to find out which binaries in Ubuntu are installed setuid root.

Here is, for reference, the list on a nearly pristine 12.04. Package names on the left, binaries on the right of the colon:

$ find {/usr,}/bin -perm 4755 | xargs dpkg -S
passwd: /usr/bin/chsh
iputils-tracepath: /usr/bin/traceroute6.iputils
mtr-tiny: /usr/bin/mtr
passwd: /usr/bin/gpasswd
sudo: /usr/bin/sudoedit
login: /usr/bin/newgrp
passwd: /usr/bin/chfn
sudo: /usr/bin/sudo
passwd: /usr/bin/passwd
login: /bin/su
iputils-ping: /bin/ping
mount: /bin/umount
mount: /bin/mount
fuse: /bin/fusermount
iputils-ping: /bin/ping6
share|improve this answer
    
@SankalpMishra it will be helpful for later reference if you could add to the question the reason why the setuid bits got lost in the first place. –  zwets Mar 6 '13 at 12:25
add comment

The issue the OP has is that all setuid root binaries in /usr/bin have somehow lost their setuid bit. This causes the bootstrapping problem of setting the setuid bit back on /usr/bin/sudo without being able to sudo. Here is how to do just that:

  1. Reboot and in the Grub menu, select the "recovery mode" option.

  2. When the recovery menu appears, select "root" to drop to a root shell.

  3. Remount the root filesystem to be writeable:

    # mount -o remount,rw /
    
  4. Set the setuid bit on sudo and pkexec:

    # chmod u+s /usr/bin/sudo /usr/bin/pkexec
    

Exit recovery mode and continue regular boot.

share|improve this answer
    
Thaks Zewts for wonderful help. ..But unfortunately, none brought luck to me!!:(.. Finally i have to re install the ubuntu –  Sankalp Mishra Mar 8 '13 at 9:34
add comment
up vote 0 down vote accepted

After trying all then suggestions given to me, The only way was to Re install Ubuntu and that is what I have to do Finally.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.