Don’t EVER do this

So, was trying to share files in a linux/ubuntu home directory with another user by using chown on all of the files in the home directory. Wanted to make sure that hidden files were shared also. Instead of “sudo chown ./.*” to process all of the files in the current directory, I missed a period and did “sudo chown /.*”. In retrospect I should have just done “sudo chown .*”. I’m not sure why I felt compelled to (attempt to) declare the current directory. That started changing ownership of ALL of the files in the file system, including all of the files owned by root.

That didn’t seem like that big of deal to recover from, until I learned about the very special chmod setting: 4755. That “4” is for “setuid”. The 4755 means that the binary will be executed as the owner (usually root).

Apparently, when you chown from root, it also does a bonus chmod by removing the leading “4”. And that’s when everything fell apart. The first noticeable problem was the inability to do “sudo” anymore. I’d received this error: “/usr/bin/sudo must be owned by uid 0 and have the setuid bit set”.

As I dug further, I discovered that many applications couldn’t be run and the computer could no longer connect to the internet.

I found this article on “Ask Ubuntu”, which interestingly enough, there was contention about the answer:
https://askubuntu.com/questions/452860/usr-bin-sudo-must-be-owned-by-uid-0-and-have-the-setuid-bit-set

The officially accepted answer is “Wipe your computer and start over”. That seemed rather harsh, and there’s a competing answer that’s gotten 4 times the upvotes that explains how to fix the problem with an “un-setuid-ed” binary.

While it’s true that you can fix a binary that has the setuid messed up, as the author of the accepted answer explains: If you have to fix one, you’ve probably got to fix a bunch, which most likely means your linux/ubuntu operating system is toast.

And that’s where I was. Untold number (tens, hundreds, thousands?) of setuid’s needed to be corrected to get the operating system running again. So I’m wiping the computer and starting over again. Learn from my mistake! 🙁

Source for “4755” explanation: https://unix.stackexchange.com/questions/605653/file-permissions-what-is-the-difference-between-755-and-4755

Leave a Comment

Powered by Paranoid Hosting™. 'Cause you never know...