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
  • 70,465
Zeno Raiser
  • 485
  • 1
  • 6
  • 18
  • 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 07: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 09:02

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
  • 70,465
  • 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 09: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 09: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
  • Yeah the system will be completely broken with /etc inaccessible like that. Booting from a USB is something you have to set up in your BIOS or UEFI settings or boot menu. I have to press esc after turning on my PC, then I can select usb, but you may need to press a different key and change boot order.you can find info on how to do this elsewhere on the site, but if stuck, try searching for how to access bios/uefi on your specific hardware using a search engine @ZenoRaiser most folks have to figure this out in order to install Ubuntu in the first place, hence my assuming you'd know – Zanna Jul 25 '17 at 19:55
  • I booted from USB and followed step by step your guideline, the output of ls /mnt was right but It didnt work maybe I've made an incorrect reboot.. when i executed the command reboot i didnt went again to BIOS so i ended up again in the usb's Ubuntu, After that i turned off the PC went to BIOS switched the USB as third boot(original settings) and went back to the PC's Ubuntu but the problem Is still the same... Do you think that I've misunderstood the reboot process and did something wrong? In this case should i again try your guideline all over from the beginning? – Zeno Raiser Jul 25 '17 at 20:39
  • @ZenoRaiser ooh it's my fault, I wrote the chmod commands wrongly, with the / at the beginning, forgetting we are in /mnt and not in a chroot. I'm so sorry. Please repeat with revised answer – Zanna Jul 25 '17 at 20:59
  • So i must execute all the chmod without / before every etc? – Zeno Raiser Jul 25 '17 at 21:02
  • @ZenoRaiser exactly, have edited... – Zanna Jul 25 '17 at 21:05
  • All done but as i clicked on the line ti write the password to login PC suddenly blocked and made me access as a temporary guest session – Zeno Raiser Jul 25 '17 at 21:13
  • Wait i just switched while i was a guest to zeno(my account) – Zeno Raiser Jul 25 '17 at 21:16
  • Ok i rebooted the PC and It went to my account, thanks buddy you're a Hero – Zeno Raiser Jul 25 '17 at 21:18
  • The wifi issue it's still there i'll open up another topic – Zeno Raiser Jul 25 '17 at 21:20
  • ah great, glad you got it fixed :D sorry about the confusion @ZenoRaiser hope the wifi can get sorted easily – Zanna Jul 25 '17 at 21:32
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,174
  • it's impossible to run sudo in this situation – Zanna Jul 25 '17 at 07: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 07: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 07:19