LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   sudo: /etc/sudoers is owned by uid 1000, should be 0 (https://www.linuxquestions.org/questions/linux-newbie-8/sudo-etc-sudoers-is-owned-by-uid-1000-should-be-0-a-4175503030/)

ChiggyDada 04-25-2014 11:41 PM

sudo: /etc/sudoers is owned by uid 1000, should be 0
 
Hi.

I'm trying to command-line copy my files from my user Documents directory to an external xfs hard drive where I store things.
I keep getting this error
Code:

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

I've tried doing it as root (hence the error) and via a gui file browser, after trying to change permissions (chown -R) on both my directory and the folder I'm trying to copy on the xfs external drive- both fail, and the "cp -a" command and "sudo cp -a" also fail and kicks up the above error. I'm in linuxmint petra.
What am I doing wrong?

(

jdkaye 04-26-2014 12:17 AM

What command are you using to copy the files that gives you this error? Was it something like this?
Code:

sudo cp /etc/sudoers /media/blahblahblad
jdk

eklavya 04-26-2014 12:28 AM

Have you edited /etc/sudoers file or /etc/passwd file? You must not edit these files unless you do not know the consequences of your action.

You must have remembered what have you done before getting the error. Revert your changes.

ChiggyDada 04-26-2014 01:23 AM

No. I've not edited anything- fairly fresh install.

Looking over all the errors, I keep seeing that my home directory and folders apparently does not exist- even if I open a terminal IN the folder, if I use that exact syntax, it still can't find it. (anyone can r/w to the destination). /home is on a separate partition and includes older files from prior installs (since wiped).
I'm using
Code:

username@laptop ~/Documents $ cp -av /folder /media/username/mountedpartition/folder
I get...
Code:

cp: cannot stat ‘./documents’: No such file or directory
(..."stat =huh???")

...I can make folders and copy from the gui to both, and copy via nemo, but not the terminal. What am I missing?
If I sudo in the terminal I get that weird permissions problem- but it can't find the directories I'm specifying, even if I open terminals within those directories and copy/paste the paths. I gotta be missing something easy and big.

eklavya 04-26-2014 03:05 AM

See the file permission of the file /etc/sudoers, it should be
-r--r----- 1 root root /etc/sudoers
It should be 440.

The file permission of /etc/passwd should be 644
both file's owner should be root and group should be root.

In /etc/passwd file root's uid should be 0 and gid should be 0.

Smokey_justme 04-26-2014 04:05 AM

Well, let's start with a request.. Please provide us with the exact command you runned (and from where), don't replace it with "/folder".. that's important because we need to tie it to the error..

The stat error means that it cannot read that file/folder (it doesn't exist, most likely).. Also, case matters.. so "Documents" is not equal to "documents"

The last question is about the sudo error.. You've tried a command starting with sudo, that's for sure... However, for some reason that file has modified permissions.

Try running (exactly like this):
Code:

su - root
It will ask you for the root password (and, by default this will probably be your first account password, in mint.. but I'm not sure).. Then run:
Code:

chmod 440 /etc/sudoer

ChiggyDada 04-26-2014 05:17 AM

Quote:

Originally Posted by Smokey_justme (Post 5159458)
Try running (exactly like this):
Code:

su - root
It will ask you for the root password (and, by default this will probably be your first account password, in mint.. but I'm not sure)..

didn't work, instant:
Code:

su - root
Password:
su: Authentication failure

...my password doesn't work! I tried many times, rebooted even. Works in everyplace but this. I only have one account and it's the administrator.


Quote:

Originally Posted by Smokey_justme (Post 5159458)
Well, let's start with a request.. Please provide us with the exact command you runned (and from where), don't replace it with "/folder".. that's important because we need to tie it to the error..

I don't have the terminals open anymore... but here's what I remember
Code:

cp -a /home/documents/ /media/newbie/640a-xfs/backup
(from terminal opened via shortcut on the pannel, then via terminals opened from nemo in the folders so I could get the path in case I was making mistakes -but it never made it to any kind of copy operation, just couldn't find the initial folders regardless, so...). I also tried adding my user name after "/home/" =no difference, apparently there's nothing IN my home folder via the command line...?!
so I tried it with "sudo cp -a ..." and with the -ar switch. tried various paths for the source, by browsing via nemo and opening a terminal and copy-pasting JUST the location. When none of that worked, I check in gparted and did it from the dev, IE, "sudo cp -a /dev/sda8/home/newbie/documents ..."
=instant stat errors. {EDIT} I just learned it helps to "~/" or "~/(folder name)" to start from the right spot. BINGO!

If it helps, I can copy via nemo without any issues. I can also sudo apps (terminal, nemo, and so forth).
Hope that is enough of following the directions... memory is fading now. Thank you for the help.

p.s. OK, if I "~/Documents/FOLDER_E" I can find the folder.
Code:

newbie@laptop ~ $ cp -ar ~/Documents/FOLDER_E /media/newbie/640a-xfs/bak/
cp: cannot create directory ‘/media/newbie/640a-xfs/bak/’: Permission denied
newbie@laptop ~ $ sudo cp -ar ~/Documents/FOLDER_E /media/newbie/640a-xfs/bak/
sudo: /etc/sudoers is owned by uid 1000, should be 0
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

Can't get in as su -root.

Smokey_justme 04-26-2014 05:43 AM

hehe.. Here's the thing...

In Linux, each user has it's own folder in the /home directory... Also, like I've said, "Documents" is different then "documents"... That's why the first cp failed..

The correct path is "/home/newbie/Documents"... You can use the command
Code:

pwd
to check the full path of the directory you're currently in (just remember that capitalization matter)

LE: "~/" is actually translated to "/home/newbie/"... You can also use the "~newbie/" variant when using another user, for example... :)

Now, unfortunately I've googled the root situation in Mint (btw, in Linux that's the Administrator account -- the one and only, others just have permissions to imitate him).. It seems that root is disabled and has no password.. But because of your /etc/sudoers problem you cannot get root priviledges..

Basically, your stuck.. So here's what you might want to do (please be aware that I'm typing this from memory -- and some google to be sure it's correct, however it might fail at some point):

1) Restart your computer..
2) On GRUB menu, press e to enter the editor mode
3) Use the arrow keys to navigate until the line that begins with "linux " and press e when on that line
4) Go to the end of the line and add the following:
Code:

rw init=/bin/bash
5) Press ENTER and b (or something of this sort) to boot the computer with this settings...
6) After the computer booted into a teminal use the following commands:
Code:

chmod 440 /etc/sudoers
chown root:root /etc/sudoers
passwd root
shutdown -r now

The passwd command will ask you for a root password (just in case something like this should happen again)
The last command reboots your computer.. After this you should be able to reuse commands starting with sudo again..

ChiggyDada 04-29-2014 05:17 PM

Thank you.
I just got this and it sounds like there's some more things I can try on the other machine (my server) which has the same errors (actually ALL my Linuxmint 16 single-user machines have this problem!!!)

1) I rebooted into root shell via single user. This was a challenge until I learned how to display grub on a single-os system
I.E.
a) reboot system, hitting/holding down shift to get a grub screen.
b) Selected recovery mode
c) selected "root - Drop to root shell prompt"
d) Wanted a password- my user account did not work nor did any other passwords I've ever used for this install. I tried a possible old root password from a PRIOR INSTALL (separate / partition that I wiped for the new/fresh install, keeping my old /home and same user name)
e) Finally got a root shell prompt (WOW!)

then I ran
Code:

passwd root
to change my root password to something sane and current -repeated with no typos so all good =access in a root shell (WHEW!).

Then to make sure I attempted to run
Code:

mount -t proc proc /proc
mount -o remount,rw /

-but already using proc and done, so all good.

so I changed my sudoers stuff via
Code:

chown root:root /etc/sudoers
chmod 440 /etc/sudoers

and just for the heck of it I ran
Code:

ls /home
and got all the users on this rig. Matched, just what I expected.

so I
Code:

sync
and then
Code:

reboot
I ran into issues getting the machine restarted- the iwl3945 (wifi crap) halted the whole rig, as usual -had to escape and enter out and finally hard-kill the rig, but that's another issue....

OK so that's how to do it.
Strange how that happens. I've never had it happen on rigs where I install Mint alongside already established OS's- now I'm going to try it on my server.
*...

ChiggyDada 04-29-2014 05:19 PM

Oh, and now I can cp to my hearts content as well as rsync, especially with the correct paths.
Code:

lol
-oh. I just checked and ALL my distros that use sudo and have NOT had a root password set, have needed this fix.

Hopefully that solves everything.
THANK YOU ALL!
:D

jamied_uk 09-06-2018 07:40 AM

A better fix for this issue on Mint 19
 
This worked for me


Code:

sudo passwd root
put in your desired password and problem solved!

however i still get this warning:

/etc/sudoers.d is owned by uid 1000, but should be 0

when trying to run this:

Code:

sudo chmod 440 /etc/sudoers.d
but fixed with this:



Code:

su - root
chmod 440 /etc/sudoers.d


iconoclasthero 11-30-2021 08:17 PM

all i had to do was...
 
this thread was a lifesaver. just wanted to share what worked for me.
drop to root shell from recovery mode
Code:

chown root:root /etc/sudoers
i don't know if the root password was ever set on this machine but none of my usual passwords would work with su - sudo prior to the fix so I set a sudo password while I was there.
rebooted, got some weird graphics mode, rebooted, voila.

all was trying to do is figure out why I can't add visudo to the exemptions list in sudoers. i'm assuming that's because visudo edits files that still require sudo/root permissions...giving up on that.

(ubuntu 18.04)

computersavvy 12-01-2021 06:26 PM

visudo edits the /etc/sudoers file which does not even have write permissions. (440).
It cannot be exempted because it MUST have a root user running it before it will operate. The program itself checks the UID of the user running it and will not launch if it is not a root user (or a user running as root using sudo).

Arbitrarily changing permissions and changing away from the default config in the sudoers file without a deep and thorough understanding of what you are doing can lead to a totally fubar setup. Many times new installs are prompted by just a simple typo or a change without considering the consequences.

iconoclasthero 12-01-2021 08:19 PM

Quote:

Arbitrarily changing permissions and changing away from the default config in the sudoers file without a deep and thorough understanding of what you are doing can lead to a totally fubar setup. Many times new installs are prompted by just a simple typo or a change without considering the consequences.
No s--t Sherlock. Everyone here has learned that lesson, that's why they're here! Stop preaching as your words will never reach anyone before they make this mistake.* This is a thread to help fix the problem not to criticize others for messing around on their machines.

I also object to "arbitrarily." I was experimenting on my machine, not just changing things willy-nilly 'cuz I thought my /etc files needed some sprucing up and I was just tossing write permissions around left and right, arbitrarily...

(FWIW: I'd removed the write permission before I tried to chown root:root /etc/sudoers so I didn't need to do that in the recovery root shell.)

*E.g., if you'd sent me a personal email on Monday before making this mistake, or even thinking about making this mistake, then that would have been great!

evo2 12-01-2021 08:40 PM

Quote:

Originally Posted by iconoclasthero (Post 6305941)
No s--t Sherlock. Everyone here has learned that lesson, that's why they're here! Stop preaching as your words will never reach anyone before they make this mistake.*

Welcome to LQ... way to make a good first impression.

Evo2.


All times are GMT -5. The time now is 07:55 PM.