6

I kinda screwed up the /etc directory by running:

sudo chmod 417 /etc 

Leaving me unable to use sudo:

sudo: can't open /etc/sudoers: permission denied.
sudo: no valid sudoers sources foundm quitting

Ive been trying to fix it via recovery mode but i'm not sure to what mode I should set it. (I know sudoers is 0440, but this doesnt fix it because /etc is still messed up.)

Oh and for the future, how do i add lines to files in etc without screwing up the permissions of etc?

Thanks in advance, Joeri.

P.S. Im running in Virtual box if that makes a difference.

Edit: Booting in recovery and running:

root@joeri-VirtualBox:/# chmod 755 etc
chmod: changing permissions of 'etc' : read-only file system
root@joeri-VirtualBox:/# cd etc
root@joeri-VirtualBox:/etc# ls -ld
drw-rw-rwx 139 root root 12288 2012-04-19 16:29

Doesnt change the permissions of etc. Doing the same on a self created folder on the desktop does, so chmod is working, just not on etc.

Joeri
  • 61
  • 1
  • 1
  • 3
  • You mean you running ubuntu in Virtual box? Not in WUBI or as a dual boot? – Ravi Apr 19 '12 at 05:46
  • Yep I am running it in virtual box. The dual boot had problems with getting into the university network. – Joeri Apr 19 '12 at 06:07
  • The general approach to editing files owned by root is to use either sudo or gksudo. There are lots of questions whose answers describe how to do that. For an example take a look at How do I get permissions to edit system configuration files? – irrational John Apr 19 '12 at 11:58
  • This question appears to be abandoned and unanswered, could you perhaps add more detail to your question? If this question no longer applies then you can either delete it or answer it yourself if you've solved the problem. This is to help with the Ask Ubuntu Clean Up. If you feel this question is not abandoned, please flag the question explaining that. :) – Seth Jan 01 '13 at 04:31

3 Answers3

2

drwxr-xr-x 157 root root 12288 2012-04-19 07:40 /etc

sudo chmod 755 /etc

Hope that helps ...

Ruediger
  • 2,182
  • Thanks, but running
     chmod 755 /etc
    
    

    From recovery didt fix my sudo acces problem.

    – Joeri Apr 19 '12 at 06:06
  • Actually running chmod ### /etc in recovery as root doesnt seem to change annything.

    :/etc$ ls -ld keeps returning drw-rw-rwx 139 no matter what i place at ###.

    – Joeri Apr 19 '12 at 06:33
  • If you're running from the recovery disk, your real disk may be mounted at a different location, perhaps /target. mount will show you where it is, then you can chroot etc within that. – poolie Apr 19 '12 at 08:11
  • In recovery mode you need probably to remount the root filesystem with read/write permission mount -o remount,rw / – Ruediger Apr 19 '12 at 08:46
  • Or you could just execute the fsck option in the recovery mode menu. After it completes you file system should be remounted as read/write. – irrational John Apr 19 '12 at 11:44
0
pkexec chmod 0440 /etc/sudoers
  • Hi Saurabh! Can you please provide an explanation on the meaning of this command, and what is actually does? – Alaa Ali Aug 12 '13 at 12:09
  • pkexec repair permission of sudoers file – Saurabh Chandra Patel Aug 13 '13 at 04:28
  • @SaurabhChandraPatel What Alaa Ali means is: Please [edit] your answer to include an explanation of what your command does with the intention of educating the OP and thousands of future researchers regarding how/when/why it should be used. – mickmackusa Nov 26 '21 at 20:20
0

The following command worked for me:

pkexec chmod 0440 /etc/sudoers
Fabby
  • 34,259
Abhishyam
  • 73
  • 1
  • 1
  • 5