chmod sudoers without using sudo

I have lubuntu installed with persistance on a large usb flash drive, and somehow, My /etc/sudoers file has file permissions 0664, when ever I try to use sudo, it says :

sudo: /etc/sudoers is mode 0644, should be 0440

sudo: no valid sudoers sources found, quitting

when I try chmod 0440 /etc/sudoers it says:

chmod: changing permissions of `/etc/sudoers': Operation not permitted

sudo chmod 0440 /etc/sudoers causes the first message. Am I using chmod incorrectly? How can I fix this? If you need to know, it is lubuntu 10.10, isntalled with unetbootin.

EDIT: I know how to fix it with recovery mode, i just need to know how to get into recovery mode in a live cd, is it possible?

3 Answers

Two methods:

  • Early in the boot process, escape to the bootloader menu, and append the following to the kernel command-line:

    single

    For Ubuntu, this will cause it to boot in the "recovery" mode, straight into a root shell.

    If chmod in the recovery console complains about a read-only filesystem, remount it read-only:

    mount / -o remount,rw

    If single doesn't work for some reason, another option is to skip the init process entirely, but this might not enable the persistent overlay.

    init=/bin/sh rw

    (deleting any existing ro options)

  • Alternatively, use another Linux computer which you have root access on – such as a real live CD (whether it's Ubuntu or not doesn't matter). Then plug in your drive, mount the filesystem which has etc/sudoers on it (with -o loop if necessary), and use sudo chmod.


Am I using chmod incorrectly?

The usage is correct, it's just that only the file's owner can change its permissions, and /etc/sudoers is normally owned by root – which you aren't.

0

I'm not sure if recent Ubuntus have root user enabled by default, but you could try

su root

to get a root shell instead. If that doesn't work, this guide takes you through repairing sudo on Ubuntu (I haven't tried it myself!)

6

I think I have sorted it out using this command

pkexec chmod 0440 /etc/sudoers

I can now do

sudo -s
root@ubuntu:~#

Is this a good enough solution to the problem?

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like