I did something stupid:
chown -R root:root /usr
chmod -R g-w /usr
Apparently, the best thing I can do is reinstall the system. However, my system works fine so far - is there anything immediately dangerous not fixing this asap? I have Ubuntu 18.04 (no Internet connection), it is just used as a local NAS.
The reason I did this was due to a warning when doing updates:
WARN: uid is 0 but '/usr' is owned by 1000
WARN: /usr is group writable!
I asked and someone in a forum suggested the above commands with "it is perfectly safe". Lesson learned: Don't trust people on the Internet, even if they sound totally convinced.
The reason, apparently, why /usr
was group writable and not owned by root is because of my specific DIY-Nas Ubuntu (Odroid):
drwxrwxr-x 10 odroid odroid 4096 Apr 12 2018 usr
Perhaps I should have not used the -R
recursive option. It doesn't matter now.
The last few hours, I looked through various posts to find out what I did. It looks like running any chown
on /usr
breaks setuid
and setgid
bits, so I would need to manually compare to an existing system to restore all of those once I have fix the ownership again. For fixing sudo
command, I already did this:
chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo
Besides this, I don't see any more problems. When I log in to Ubuntu interface, I get a permission warning from some Bluetooth Software, but it is not immidiatly relevant.
I understand that there is some software in /usr that has a group other than root
(see list here, for example), for reasons of security - but will there be any really negative effects on my nas-system, especially related to file handling/archive things, e.g. corrupted or inaccessible files?
Note that I created a new stackexchange account because I am too embarrassed.. anyway, many thanks for suggestions!
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
? See here – Helmut Dec 08 '18 at 16:14sudo -i
to get a root shell. Then I didchown root:root /usr/bin/sudo
and indeed, the setuid bit has gone andsudo
is broken :-( The setuid bit isn't removed by thechmod g-w
but by thechown
. I'm afraid my whole answer has proved wrong now. – PerlDuck Dec 08 '18 at 16:34sudo
command. If that works, everything else can be recovered. – PerlDuck Dec 08 '18 at 17:38