LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-25-2014, 11:41 PM   #1
ChiggyDada
LQ Newbie
 
Registered: Apr 2012
Distribution: Mint, CentOS, Unbuntu based
Posts: 24

Rep: Reputation: Disabled
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?

(
 
Old 04-26-2014, 12:17 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
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
 
Old 04-26-2014, 12:28 AM   #3
eklavya
Member
 
Registered: Mar 2013
Posts: 636

Rep: Reputation: 142Reputation: 142
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.
 
Old 04-26-2014, 01:23 AM   #4
ChiggyDada
LQ Newbie
 
Registered: Apr 2012
Distribution: Mint, CentOS, Unbuntu based
Posts: 24

Original Poster
Rep: Reputation: Disabled
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.

Last edited by ChiggyDada; 04-26-2014 at 01:25 AM. Reason: added /home info
 
Old 04-26-2014, 03:05 AM   #5
eklavya
Member
 
Registered: Mar 2013
Posts: 636

Rep: Reputation: 142Reputation: 142
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.
 
Old 04-26-2014, 04:05 AM   #6
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

Rep: Reputation: 203Reputation: 203Reputation: 203
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
 
1 members found this post helpful.
Old 04-26-2014, 05:17 AM   #7
ChiggyDada
LQ Newbie
 
Registered: Apr 2012
Distribution: Mint, CentOS, Unbuntu based
Posts: 24

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Smokey_justme View Post
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 View Post
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.

Last edited by ChiggyDada; 04-26-2014 at 05:20 AM.
 
Old 04-26-2014, 05:43 AM   #8
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

Rep: Reputation: 203Reputation: 203Reputation: 203
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..

Last edited by Smokey_justme; 04-26-2014 at 05:56 AM.
 
1 members found this post helpful.
Old 04-29-2014, 05:17 PM   #9
ChiggyDada
LQ Newbie
 
Registered: Apr 2012
Distribution: Mint, CentOS, Unbuntu based
Posts: 24

Original Poster
Rep: Reputation: Disabled
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.
*...
 
Old 04-29-2014, 05:19 PM   #10
ChiggyDada
LQ Newbie
 
Registered: Apr 2012
Distribution: Mint, CentOS, Unbuntu based
Posts: 24

Original Poster
Rep: Reputation: Disabled
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!

Last edited by ChiggyDada; 04-30-2014 at 12:30 AM. Reason: adding that this worked on other systems too
 
Old 09-06-2018, 07:40 AM   #11
jamied_uk
LQ Newbie
 
Registered: Feb 2014
Posts: 7

Rep: Reputation: Disabled
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

Last edited by jamied_uk; 09-06-2018 at 07:43 AM.
 
Old 11-30-2021, 08:17 PM   #12
iconoclasthero
LQ Newbie
 
Registered: Nov 2021
Posts: 3

Rep: Reputation: Disabled
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)

Last edited by iconoclasthero; 11-30-2021 at 08:19 PM.
 
Old 12-01-2021, 06:26 PM   #13
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
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.
 
Old 12-01-2021, 08:19 PM   #14
iconoclasthero
LQ Newbie
 
Registered: Nov 2021
Posts: 3

Rep: Reputation: Disabled
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!

Last edited by iconoclasthero; 12-01-2021 at 08:28 PM.
 
Old 12-01-2021, 08:40 PM   #15
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by iconoclasthero View Post
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.
 
  


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 Off
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
Can you let this Set-UID program (owned by root) run?? goldengriff Ubuntu 5 11-20-2013 07:54 PM
[SOLVED] whoami: unknown uid 1000 Lobinho Linux - Embedded & Single-board computer 2 01-31-2013 04:25 AM
sudoers file error: owned by gid 10, should be 0 usafitz Linux - Newbie 8 12-01-2007 05:08 PM
uid, gid don't exist, yet files owned by them, i need to delete them mattie_linux Linux - General 10 05-05-2005 03:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:51 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