LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-08-2016, 03:36 PM   #1
MrPork
LQ Newbie
 
Registered: Jul 2016
Posts: 4

Rep: Reputation: Disabled
Angry I cant sudo


Problem :

sudo: /etc/sudoers is owned by uid 1000, should be 0
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

Reason why :

sudo chown -R sael:sael /etc

Was trying to change permissions so that I could edit something now im a sitting duck.
 
Old 07-08-2016, 03:50 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Why on earth did you chown -R /etc ????

/etc/ holds system config files, you're not supposed to be able to edit them as a regular user, that's the point. This is also another reason why sudo-only distros are stupid, but that's an argument for another thread.

Boot into a live distro, mount your root partition, and chown everything back to what it's supposed to be. Hopefully you have a backup you can use for reference? Most of them should be root:root, but there are several critical exceptions. If you don't have a reference to go off of, you may end up wanting to chown them all to root:root and then install the same distro in a VM so you can see what they're supposed to be. And then chalk this up as a learning experience and never do it again

Whatever you use for a reference, the following could help you identify the outliers that aren't root:root
Code:
find /etc/ ! -user root -or ! -group root | xargs ls -ld
There are only 26 outliers on my CentOS 7 system, not too bad.

Last edited by suicidaleggroll; 07-08-2016 at 03:57 PM.
 
Old 07-08-2016, 04:09 PM   #3
MrPork
LQ Newbie
 
Registered: Jul 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by suicidaleggroll View Post
Why on earth did you chown -R /etc ????

/etc/ holds system config files, you're not supposed to be able to edit them as a regular user, that's the point. This is also another reason why sudo-only distros are stupid, but that's an argument for another thread.

Boot into a live distro, mount your root partition, and chown everything back to what it's supposed to be. Hopefully you have a backup you can use for reference? Most of them should be root:root, but there are several critical exceptions. If you don't have a reference to go off of, you may end up wanting to chown them all to root:root and then install the same distro in a VM so you can see what they're supposed to be. And then chalk this up as a learning experience and never do it again

Whatever you use for a reference, the following could help you identify the outliers that aren't root:root
Code:
find /etc/ ! -user root -or ! -group root | xargs ls -ld
There are only 26 outliers on my CentOS 7 system, not too bad.
Well I'm VERY new to linux and had no idea that /etc was system files. Mostly because of what it was named. I just figured it was random information for installed programs. Also, I have no idea what you just told me to do. Is there a way to back up my files and reinstall linux?
 
Old 07-08-2016, 04:13 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
For future reference: http://tldp.org/LDP/tlk/fs/filesystem.html
 
Old 07-12-2016, 10:11 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by MrPork View Post
Well I'm VERY new to linux and had no idea that /etc was system files. Mostly because of what it was named. I just figured it was random information for installed programs. Also, I have no idea what you just told me to do. Is there a way to back up my files and reinstall linux?
don't get defensive.
habitual is trying to help you, and their gentle critique is justified:
if you are so new to linux, what were you doing trying to change your sudoers file? and why weren't you using visudo for that, as every tutorial says?

ok, try this:
Code:
sudo chown -R root:root /etc
and reboot.

if that helps, lucky.
if not, and judging from your admission that you are clueless, i think your best bet is to boot up a live distro, copy whatever files you want to save to a spare usb stick, and reinstall.

and chalk it up to experience: be more careful in future. don't execute a command without knowing what it does.
and it has happened to all of us at some point!
 
Old 07-12-2016, 10:21 AM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by MrPork View Post
Well I'm VERY new to linux and had no idea that /etc was system files. Mostly because of what it was named. I just figured it was random information for installed programs.]
For future reference, whatever the task, if you need root privileges in order to do it, then you need to take a long hard look at what you're doing and why. If it was just "random information" that didn't matter, you wouldn't need to be root.

Quote:
Originally Posted by MrPork View Post
Also, I have no idea what you just told me to do. Is there a way to back up my files and reinstall linux?
Sure, either way you'll want to boot into a live distro so you have permission to mount drives, etc.
 
Old 07-13-2016, 03:42 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Actually, if this is RHEL based distro, there is a way to correct ownerships (& perms if reqd) http://www.cyberciti.biz/tips/reset-...ermission.html
Obviously you'll need to be/have root access.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo: effective uid is not 0, is sudo installed setuid root? awladnas Linux - Newbie 10 08-30-2014 06:03 PM
Question about the sudo command, specifically how to have sudo act as if user is root slacker_ Linux - Newbie 17 09-22-2013 03:48 PM
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
Unable to redirect all sudo messages to /var/log/sudo driftwood Linux - Server 2 10-18-2012 04:34 AM
Restricting Editing in Sudo (Advanced Sudo Question) LinuxGeek Linux - Software 4 11-04-2006 03:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration