Score:1

I ran the following commands by mistake in my Ubuntu 21.04 machine and then everything became broken

in flag

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
David avatar
cn flag
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.
Zorono avatar
in flag
the path wasn't meant to be root... i meant /downloads
24601 avatar
in flag
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.
Score:0
cn flag

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.

emk2203 avatar
in flag
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...
cocomac avatar
cn flag
I edited it. I wasn’t aware of that, but thanks for letting me know!
emk2203 avatar
in flag
You're welcome. Better to learn it here than by trying to move 100+ files like I did.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.