Ubuntu 16.04 lts lost administrator rights bash: /etc/profile: Permission denied
There is no need to execute chmod
at all when using sudo
to edit a file, although you shouldn't use sudo gedit
(rather sudo -H gedit
for example)
Since you didn't change permissions recursively, you can fix the problem fairly easily.
Boot a live session (for example, Ubuntu bootable USB you use for installation, or System Rescue. If you don't have one, you can make one using another computer or even buy one). If using an Ubuntu live USB, select **Try Ubuntu without installing".
In the live environment, identify the (afflicted) root partition on the disk using sudo fdisk -l
It will probably the biggest partition and it will be labelled "Linux filesystem". Something like /dev/sda1
or maybe /dev/mmcblk0p2
.
Mount the root partition, using the proper name instead of sdXY
sudo mount /dev/sdxY /mnt
Check it was the right partition:
ls /mnt
Should output something you'd expect to see in /
, roughly like:
bin dev lib64 mnt root snap sys var
boot etc lost+found opt run srv tmp
cdrom home lib media proc sbin usr
If it looks right:
cd /mnt
sudo chmod 755 etc
sudo chmod 755 etc/pm
sudo chmod 755 etc/pm/config.d
cd
Then you can unmount the partition and reboot into your system as normal
sudo umount /mnt
reboot