2

So i ran into an issue and i needed to rewrite a file taht was in ETC file folder and the system wasn't allowing it. I claimed the whole ETC folder.. the file wrote fine after that. Now as i am using sudo it says there needs permission granted from the Pi user to use the command. And other commands are completely shut off. Like now i need to rewrite a file in the /boot directory and i am unable to sudo change ownership of that boot directory becuase Pi user owns it.

So now i'd like to revert ownership of ETC folder back to root.. because ETC folder houses all the sudo profiles, so sudo is offline. Then i'd like to go into a user that can read and write any file on the computer. I need to be done with claiming file folders, otherwise i forget the folder is claimed/dont know how to unclaim it.. any and all suggestions welcome to resolving this issue.

Changing file permissions back so root owns the ETC file folder and granting system wide access to my user/using a user that has systemwide access. All i have found so far is systemwide access through the terminal. I need systemwide access throughout all the filefolders and the desktop

sudo chown -R pi:pi  /boot/config.txt
sudo: /etc/sudoers is owned by uid 1000, should be 0
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
4
  • i did that same command chown pi:pi for the etc file folder - after that we are here – EmpireLearning May 9 '20 at 3:36
  • It is unclear what you ACTUALLY did so no one can tell you how to fix it. sudo chown -R pi:pi /boot/config.txt is impossible, because it is a FAT partition which doesn't support permissions. Your best option is to restore from your backup. – Milliways May 9 '20 at 5:08
  • This is a clear case of fatal sudoitis. – Dougie May 9 '20 at 11:33
  • When you changed the ownership of the /etc/sudoers file, the sudo command stopped working. Makes it hard to use sudo to get it back. [In case you also changed permissions, my Raspbian /etc/sudouers file has permissions 0440.] If you have a Linux system with an SD card reader, you can insert the Pi's SD card, mount the card's second partition (ext4) and use that system's sudo command to change the ownership back to root. I didn't make this an answer because the other two answers are not wrong. And a detailed description of how to use an SD reader/mount/umount would take time. – Chad Farmer May 15 '20 at 6:37
1

You will need to build a rescue system on another SDCard. Boot that and mount the broken system in a USB reader. Then spend time checking and correcting the permissions of everything you think you've damaged.

Easier may be to build a fresh Raspbian Buster system then move your stuff (programs & data you've created) from the original broken system, before finally overwriting the original SDCard with a backup copy of your new SDCard (using the SD Card Backup tool).

This is a clear example why you should never use sudo unless you have a positive need to use sudo. 99.9% of all the tasks you're doing on your RPi do NOT need to run with sudo.

0

If you do not have a backup your options are limited.

You can repair many such problems on the Pi by rebooting to a root shell.

  1. Append init=/bin/sh at the end of cmdline.txt and reboot. (This will need to be done on another computer.)
  2. After booting you will be at the prompt in a root shell.
  3. Your root file system is mounted as readonly now, so remount it as read/write mount -n -o remount,rw /

You can then edit files.

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.