2

I had an issue with wifi, which is still unsolved because of the problem that happened when I was trying to solve it.

I found this solution for wifi so tried it out:

sudo gedit /etc/pm/config.d/config

Insert in config this text

SUSPEND_MODULES = "drivername logicalchipname"

I noticed that I didn't have permission to write or execute the file so I tried to use chmod to solve the problem. This is an ordered list of all operations that I've made and that led to the problem of this question:

chmod 700 config 
chmod 700 config.d 
chmod 700 etc
chmod 754 etc

After the third or fourth command (I'm not sure which one of them) I lost my administrator rights; in fact if I try to use the command sudo it outputs 3 lines which I'll translate as best I can:

sudo: cannot stat /etc/sudoers : permission denied
sudo: no valid source of sudoers found, exiting
sudo: could not initialize policy plugin

On the terminal it displays

-bash: /etc/profile: Permission denied
Missing name@zenoraiser-P552LA

Now whenever I open the terminal it outputs me the bash /etc/profile: Permission denied line that I've never seen before and the missing name part is unusual because it should be written zenoraiser instead of that.

What do you suggest I do?

Zanna
  • 72,312

2 Answers2

2

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
Zanna
  • 72,312
0

You removed the executable rights to access the /etc/ directory by other users. That's why they can't access the directory anymore.

You might want to try to sudo su followed by chmod 755 /etc.

However if that is not working you might want to start up a live image mount your HDD and then do the chmod command chmod 755 /mountpoint/etc

Ziazis
  • 2,184