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?

  • 3
    "What do you suggest I do?" I would advice you to assume you never need to use chmod or chown outside of your own personal files. Never. Ever. The anser from ziazis should work. As another option you can also re-install Ubuntu --without-- formatting any of your partitions. Just mount them. Also: make sure to make a backup of your personal files if you end up doing that. – Rinzwind Jul 25 '17 at 7:11
  • the first suggestion in Ziasis' answer certainly will not work as sudo will not do anything unless the user running it has x on /etc – Zanna Jul 25 '17 at 9:02
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
  • By "Boot a live session (for example, Ubuntu bootable USB you use for installation, (..)" do you mean that i should install on my USB an Ubuntu 16.04 partition?? In that way i'll be operating from the partition on the USB and i should Be able ti use sudo commands?? Because if i continue to operate from my partition(the damaged one)i wont be able to use sudo commands – Zeno Raiser Jul 25 '17 at 9:41
  • @ZenoRaiser I don't mean do I full installation on the USB, I mean use or make a live USB (or DVD) or obtain one, boot it, then from this system, where you will be able to use sudo, mount your damaged system root partition, and change the file properties. I have done this myself many times – Zanna Jul 25 '17 at 9:57
  • I've installed an iso on my USB to try to reinstall Ubuntu but It doesnt work, It doesnt display the Try Ubuntu without installing command – Zeno Raiser Jul 25 '17 at 19:25
  • There's no need to reinstall Ubuntu. What does happen when you try to boot from the USB? @ZenoRaiser – Zanna Jul 25 '17 at 19:26
  • How can i boot from the USB if the system doesnt do it authomatically?? I didnt Say It before but maybe it's important: the issue or this topic doesnt consist only in denied permissions from sudo commands alsoi can't login to my account, i mean that the PC get stucked on the display where usually an Ubuntu user inserts his own password, if I try to write the password while i'm there It appears for One second a terminal and then It goes back ti the display where i should make the login with the password. However, even or this loop Is going on, i Can use the terminal with ctrl+alt+f1 – Zeno Raiser Jul 25 '17 at 19:36
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

  • it's impossible to run sudo in this situation – Zanna Jul 25 '17 at 7:17
  • Thanks for editing my question, for the first action that you suggested it outputs the same 3 linees. I didnt understand what do you mean by "startup a live Image mount your hdd" however i did the chmod command chmod 755 /mountpoint/etc and It says chmod:impossible log in ti 'mountpoint/etc': file or directory doesnt exist – Zeno Raiser Jul 25 '17 at 7:17
  • You can start a "live test session" if you download any recent ubuntu iso. There you can mount your local HDD and use all the commands you want. – Ziazis Jul 25 '17 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.