You are not logged in.

#1 2013-09-24 05:52:46

dynamite
Member
Registered: 2013-02-28
Posts: 13

[SOLVED] reseting su password, single user mode not working

Hi everyone,
So I did something stupid (not on purpose obviously) and tried to move the contents of / into my home directory (using mv).
Ok not a really big deal, loaded up a live cd of mint which happened to be around and moved the everything back, rebooted and everything seemed fine.
Then tried to use sudo, and got the error "sudo: effective uid is not 0, is sudo installed setuid root?"
looks like a permissions/ownership issue of /usr/, does this sound right to people?
Anyway then tried su to change the ownership back to root. I am guessing the mint live cd took ownership of it for some reason.
But my password didn't work (neither did leaving it blank), so rebooted into single user mode and reset it and rebooted. However the authentication still fails.

I tried passwd, passwd root and passwd username for good measure but it hasn't resolved the issue. (the disk was mounted as rw)

Have i missed something obvious? What is the next thing to try?

Thanks for any help

Last edited by dynamite (2013-09-25 05:44:01)

Offline

#2 2013-09-24 07:21:39

Amanda S
Member
Registered: 2013-09-21
Posts: 276
Website

Re: [SOLVED] reseting su password, single user mode not working

You can change the root password with

sudo passwd

Type that command, hit Enter, type your user password and then type the new password for the root account.

Last edited by Amanda S (2013-09-24 07:21:57)


If it ain't broke, you haven't tweaked it enough...

Offline

#3 2013-09-24 07:35:18

dynamite
Member
Registered: 2013-02-28
Posts: 13

Re: [SOLVED] reseting su password, single user mode not working

sudo isn't working, I suspect because of the ownership of the /usr/bin/sudo being changed in the copy. (gives the error sudo: effective uid is not 0, is sudo installed setuid root?) I probably used sudo within the live cd when I copied the files back, which took ownership of them for some reason.
Usually this would work though.

Offline

#4 2013-09-24 07:53:40

Amanda S
Member
Registered: 2013-09-21
Posts: 276
Website

Re: [SOLVED] reseting su password, single user mode not working

I couldn't find much but seems like most answers say something about changing the permissions in '/usr/bin/sudo'. You could try to change the permissions of that file in a LiveCD.

sudo chmod 4755 /usr/bin/sudo

You can also check the sudoers file.

Also, if the first command doesn't work you can try

sudo chmod 0755 /usr/bin/sudo

Don't forget to read http://en.wikipedia.org/wiki/Chmod
Seems like you also can do

sudo chmod 777 /usr/bin/sudo

Also, try the following

pkexec chown root:root /usr/bin/sudo

Last edited by Amanda S (2013-09-24 08:00:27)


If it ain't broke, you haven't tweaked it enough...

Offline

#5 2013-09-24 09:32:36

dynamite
Member
Registered: 2013-02-28
Posts: 13

Re: [SOLVED] reseting su password, single user mode not working

Unfortunately none of these worked.
Further, when using chroot sudo works, so I tried to reinstall it using pacman and got the following error:

(1/1) checking keys in keyring                     [######################] 100%
error: GPGME error: Invalid crypto engine
(1/1) checking package integrity                   [######################] 100%
error: GPGME error: Invalid crypto engine
error: sudo: missing required signature
:: File /var/cache/pacman/pkg/sudo-1.8.7-1-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] y
error: failed to commit transaction (invalid or corrupted package (PGP signature))
Errors occurred, no packages were upgraded.

when I tried again I got:

error: could not open file: /etc/mtab: No such file or directory
error: could not determine filesystem mount points
error: failed to commit transaction (unexpected error)
Errors occurred, no packages were upgraded.

Offline

#6 2013-09-24 10:14:32

chord
Member
Registered: 2012-11-07
Posts: 121

Re: [SOLVED] reseting su password, single user mode not working

dynamite wrote:

rebooted into single user mode and reset it and rebooted. However the authentication still fails.

Most cases when booting in single user mode, you get root file system mounted as readonly. Even  if "mount" shows rootfs mounted as "rw".
I would tried once more, with

mount -o remount,rw /

before running passwd.

Offline

#7 2013-09-24 21:19:04

dynamite
Member
Registered: 2013-02-28
Posts: 13

Re: [SOLVED] reseting su password, single user mode not working

Thanks for that, but remounting didnt make a difference.
Is this what the permisions should be set like for the /usr/bin/sudo file?

[nick@localhost bin]$ ls -l sudo
-rwxr-xr-x 1 root root 129384 Sep 24 16:24 sudo

and does this imply maybe a different file is the issue?

Offline

#8 2013-09-24 21:47:26

Andy45
Member
Registered: 2013-09-21
Posts: 14

Re: [SOLVED] reseting su password, single user mode not working

try uninstalling and reinstalling sudo from a live cd (with working internet on the cd!). Boot into the livecd and mount your operating system under /mnt. Totally remove sudo: pacman -Rns sudo --root=/mnt. (This next step is optional, but highly recommended.) Then upgrade your system to ensure full compatibilty with the new version of sudo: pacman -Syyu --root=/mnt. Finally reinstall sudo: pacman -S sudo --root=/mnt.

Offline

#9 2013-09-24 22:27:19

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: [SOLVED] reseting su password, single user mode not working

Those are not the right permissions, no. It should look like:

-rwsr-xr-x 1 root root 127K Meh  14 09:58 /usr/bin/sudo

The 's' indicates the setuid bit is set. You would need chmod u+s to correct it. (But this won't work if you cannot su or sudo, obviously.)

How exactly did you move the files to your home directory with mv? Did you use sudo? Or had you used su? What command did you issue?

How exactly did you do the move back from the Live CD? Again, exactly what command did you use?

I'm asking because it may be that other things are also wrong, even if that's not obvious right now, and people will stand a better chance of figuring that out the more they know about the causes.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#10 2013-09-25 02:17:52

dynamite
Member
Registered: 2013-02-28
Posts: 13

Re: [SOLVED] reseting su password, single user mode not working

The commands I used were as follows:
in /

sudo mv * /mnt/gopro/DCIM/100GOPRO/ ~/Pictures/some path

Stupid syntax mistake I know.
then to go back, I loaded up a live cd and mounted sda

sudo mount /dev/sda6 /mnt
sudo bash
cd /mnt/home/nick/Pictures/some dir
cp -R usr /mnt/

sudo was needed to get access to the drive
Note these may not be exactly accurate because I am doing them from memory. Also i copied all of the folders (eg opt, lib etc) one by one and got no errors on any of them.

Offline

#11 2013-09-25 02:34:35

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: [SOLVED] reseting su password, single user mode not working

cp -a or rsync -aAX would probably work but cp -R won't get all of the information for everything. mv should also work OK. If you still have the originals there, I would recopy or move the stuff back so you know you won't have any other nasty surprises (e.g. ping not working).


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#12 2013-09-25 03:22:44

dynamite
Member
Registered: 2013-02-28
Posts: 13

Re: [SOLVED] reseting su password, single user mode not working

Cool thanks for that, the originals are still there so I will try that in a while, just backing up everything at the moment.

Would you mind explaining what the differences are between -a -r and mv? what is it that an archive copy does that a recursive one won't?

Offline

#13 2013-09-25 05:42:46

dynamite
Member
Registered: 2013-02-28
Posts: 13

Re: [SOLVED] reseting su password, single user mode not working

Thanks so much cfr
cp -a worked.

Offline

#14 2013-09-26 02:49:34

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: [SOLVED] reseting su password, single user mode not working

See the manual page for cp

man cp

...
      -a, --archive
              same as -dR --preserve=all
...
      -d     same as --no-dereference --preserve=links
...
      --preserve[=ATTR_LIST]
              preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links,
              xattr, all
...

The best way to understand it, I find, is to make some scratch directories and files in /tmp with various settings and then play around with cp/mv/rsync.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB