/etc/profile permission denied
Andrew Mclaughlin
I'm running an Ubuntu 12.04 LTS partition and I've recently have had issues logging in.
From the GUI login screen, when I enter my username and password, it takes me right back to the login screen. This is different from when I enter my username and password incorrectly.
So I entered alt+ctrl+F1 to access the terminal and I signed in. It then reads:
-bash: /etc/profile Permission deniedFrom what I've tested, the only commands that I can run from terminal are basic terminal commands like ls and pwd. I tried changing my access to /etc:
sudo chmod 755 /etcI get the errors:
sudo: unable to open /etc/sudoers: Permission denied
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy pluginIf I run it without sudo I get a permission denied. If someone knows how to get around this issue that would be great
63 Answers
Setting permission to /etc:
Since the permission of your /etc directory is drw-rw----, you will not be able to drop down to root privilege to set the right permissions. So you'll have to get a Live Ubuntu media with which you can boot and correct the problems.
Boot to a live session, open a terminal and mount the target root partition:
sudo -i mount /dev/sdXY /mnt(replace
sdXYwith that of target device, the device for/; assuming you don't have a separate partition for/etc.)Make permission changes:
chmod 755 /mnt/etc(assuming the permissions for the contents in
/etcis okay.)reboot
P.S. I tried to replicate this by running sudo chmod 644 /etc and was able to recover with the steps stated above. However, I encountered additional issues with Unity plugins. The following AU Q&A helped to solve some:
If you have a root password, you can use su to become root and then fix the permissions of the files. They should be as follows:
-rw-r--r-- 1 root root 665 Feb 20 03:43 /etc/profileand
-r--r----- 1 root root 745 Feb 10 20:16 /etc/sudoersAfter setting the permissions, you should reboot.
I think you have messed with /etc/sudoers or some other sensitive file and been locked out of sudo.
But you can use pkexec command to fix it.
See here and here for more deatil about file permission and /etc/sudoers.