Unable to use sudo su - command
Solution 1
Normal permissions for /etc/ are: rwx r-x r-x root root
Using chmod 741 /etc/
means to set the permissions /etc/ to rwx r-- --x
.
Notice the lack of r
in the third field. These three fields represent: Owner, group, others. Since the default owner and group is root you just prevented everyone except root from reading files in /etc/. This is a bad thingtm.
If you get a root prompt then you can revert these changes easily enough, but for that you need:
- Either an already open root prompt.
- A way to log in as root or any uid 0 account.(You need to manually set this in Ubuntu.)
- Right to
su
orsudo
(which you just broke). - Or access to the filesystem from another OS.
- Or reinstall the system. (Easiest to do if you just set it up a few minutes ago, but also the least educative way)
For a normal desktop or a server with remote access card (HP ILO, Dells DRAC etc) I would boot into single user mode, provide the root password if needed, and fix the permissions.
Or I would boot from a liveCD (or pendrive) and do the same.
On Amazon this is a bit harder because you have no physical access. However you can start a second instance and mount your old OS disk from there.
Solution 2
pkexec chmod 0440 /etc/sudoers
Then try sudo -s
Related videos on Youtube
pavan tiwari
Updated on September 18, 2022Comments
-
pavan tiwari over 1 year
I am new in ubuntu, i am trying to run following command
sudo su -
Bu i am getting following message
sudo: unable to open /etc/sudoers: Permission denied sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin
Previously it was running but when i run following command
chmod 741 /etc/
It is stop working, i don't have root user password, i am running my machine on Amazon.
Pls suggest me how can i fix this problem.
-
Admin about 11 yearsthanks for replay , but i don't have pkexec, when i used sudo apt-get install policykit-1 command to get it, it is again showing same error message.
-
ganesh about 11 yearsHe just did a chmod 741 /etc/ (no r for others). That is the source of the problem, not FS damage,
-
pavan tiwari about 11 yearscommand should be like that ls -l /etc/sudoers
-
pavan tiwari about 11 yearsMy FS is not damaged -r--r----- 1 root root 584 2009-03-10 20:25 /etc/sudoers
-
Sepahrad Salour about 11 yearsI forgot to write -l option, Thanks.
-
Sepahrad Salour about 11 years@Hennes it's not matter. I talk about something else (Hard Link)