1

Good evening, please I ran the following commands by mistake in my Ubuntu 21.04 machine and then everything became broken...

sudo chown john: /*
sudo chown john: /**
sudo chown john: /**/**

and sudo is no longer working

sudo: /etc/sudo.conf is owned by uid 1000, should be 0
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

EDIT: after referring to /usr/bin/sudo must be owned by uid 0 and have the setuid bit set and Sudo doesn't work: "/etc/sudoers is owned by uid 1000, should be 0" I ran the following commands in Live USB it worked again...

sudo chown root:root /* -R
sudo chown root:root /** -R
sudo chown root:root /**/** -R
sudo chown root:root /usr/bin/** -R
sudo chown root:root /usr/bin/**/** -R
sudo chown root:root /etc/sudoers /etc/sudoers.d /etc/sudo.conf -R
sudo chmod 4755 /etc/sudoers
sudo chmod 4755 /etc/sudo.conf
sudo chown root:root /usr/bin/sudo
sudo chmod 4755 /usr/bin/sudo
sudo chown root:root /usr/lib/sudo/sudoers.so
sudo chmod 4755 /usr/lib/sudo/sudoers.so

EDIT 2: and the following commands too...

sudo chmod 4755 /usr/libexec/**
sudo chown root:root /usr/libexec/**
sudo chmod 4755 /usr/libexec/polkit-agent-helper-1
Zorono
  • 41
  • 3
    How do you run three commands by mistake against all directories? You may after al ot of work and many days or weeks get this working again. But I would recommend a re install from scratch. – David Oct 10 '21 at 16:14
  • 1
    the path wasn't meant to be root... i meant /downloads – Zorono Oct 10 '21 at 16:15
  • 2
    a useful hint for the future: before performing this type of operation perhaps first use ls in order to see what will be impacted by your command before committing yourself. – graham Oct 10 '21 at 16:37

1 Answers1

0

Sorry. That is... bad. You should reinstall Ubuntu. Copy all the files you care about somewhere safe. Copying them to two safe places is better, if you can. If the cp (or, depending on your "safe place", mount as well) command doesn't work to copy these files, you can do this from a Live CD. Personally, I'd just use a LiveCD to be safe, but if the cp command works, that is probably fine too. Double-check that they are in a safe location.

You need to reinstall, similar to this question. Sadly, the ** glob from your command means it ran it recursively. Technically, it may be possible to manually fix it, but it would be very time-consuming.

This last part isn't helpful now, but... take regular backups of your system in case of something going wrong. Also, RAID is not a backup.

cocomac
  • 3,394
  • 3
    When you try to mv several files to a directory by mv files* mistyped_directory, only the last moved file survives, the others get overwritten. mv files* mistyped_directory/ throws an error and your files stay intact.

    So, there are cases where you want to type the / out. Learned by painful experience...

    – emk2203 Oct 10 '21 at 17:14
  • I edited it. I wasn’t aware of that, but thanks for letting me know! – cocomac Oct 10 '21 at 17:26
  • You're welcome. Better to learn it here than by trying to move 100+ files like I did. – emk2203 Oct 11 '21 at 05:44