Command bricked system
Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 12 comments · opened Feb 27, 2025 · closed Feb 28, 2025
💡 Likely answer: A maintainer (bcherny, collaborator)
responded on this thread — see the highlighted reply below.
Ubuntu 24.02 server
To automate claude updates it advises to run sudo chown -R $USER:$(id -gn) /usr && sudo chmod -R u+w /usr
This bricked the sudo system to no longer work and had to attach a rescue instance to fix the permissions of the files it broke.
I would like to hope this is user error but i dont know how else you would action this request.
12 Comments
cc @sid374 mind taking a look?
What I had to do to fix this after mindlessly running the command:
In recovery mode, drop down into root:
sudo chown -R root:root /usrchmod u+s /usr/bin/sudoI'm assuming this is a prank, and to be fair, I needed the practice with xargs and awk and stuff, so hey, good one.
I tried suggesting to Anthropic that they needed to warn people about this several days ago: https://github.com/anthropics/claude-code/issues/43.
What the
claudeprogram advises is dangerous in terms of security and stability (as can be seen above). People should not be installing the program as root/superuser and the program should not be suggesting that they perform dangerous commands so that it can automatically update. As mentioned in the issue that I filed, Anthropic should update instructions to show people how to install Node packages as a non-privileged user. My experience is thatclaudeworks fine as a non-privileged user, installed by a non-privileged user.I was also silly enough to run this.. On Ubuntu 22.04,
My fix:
This should theoretically work. However the last command gave me a number of errors with with fuse3, nodejs, and npm. The system now booted and I could uninstall the, purge, fix broken packages and reinstall cleanly.
Also I should give credit to Gemini for helping me with this
Hey @BumbleTree & @ac2522 ,
I ran into the same issue on my Arch. Here's how I fixed it:
lsblk/mnt:sudo mount /dev/sdXY /mnt(Replace sdXY with your system partition)arch-chrootinto the mounted disk:sudo arch-chroot /mntchown -R root:root /usrsudo chmod -R 755 /usrI had several iterations before I was able to fix it, if these don't work, then just chroot again and run these commands as well:
For Ubuntu, I think the process should be similar, but use
sudo chroot /mntinstead of arch-chroot.Hope this helps!
Sorry about this folks. We are now redirecting to our docs page that helps you set up a user accessible global npm prefix instead of changing permissions:
https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview#auto-updater-permission-options
The suggested command breaks your whole system
sudo chown -R $USER:$(id -gn) /usr/local && sudo chmod -R u+w /usr/localbroke my sudo command completely. After running this, I received the error:
"sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set"
The command in your instructions should be modified to only affect directories needed by the CLI. Modifying permissions recursively across system directories is potentially dangerous and should come with clear warnings. Please consider revising the installation instructions to prevent other users from experiencing this issue.
How to fix it:
lsblk):``
bash
``sudo mount /dev/nvme0n1p2 /mnt # replace with your actual system partition
``
bash
``sudo mount /dev/nvme0n1p1 /mnt/boot # if needed
``
bash
``sudo arch-chroot /mnt
```bash
chown -R root:root /usr
chmod -R 755 /usr
# Set setuid bit for critical binaries
chmod u+s /usr/bin/sudo
chmod u+s /usr/bin/su
chmod u+s /usr/bin/passwd
chmod u+s /usr/bin/newgrp
chmod u+s /usr/bin/gpasswd
chmod u+s /usr/bin/chsh
chmod u+s /usr/bin/chfn
```
``
bash
``exit
sudo umount -R /mnt
reboot
I strongly recommend modifying the install instructions to use a more targeted approach for whatever needs sudo-less write access. This recursive permission change is dangerous and should come with clear warnings.
Maybe nice discount?
I also fell victim to this today and completely destroyed my system. More concerningly, everyone who ran this command and did not break their system is now unknowingly running a severely compromised system where the entire
/usrdirectory is writable by any program run by the user. Neat.Here is what Claude has to say about this:
OpenAI's ChatGPT says this:
This is extremely bad stuff and needs to be taken seriously. The command has to be removed from the application ASAP.
not really good enough, need to do a lot better.
Updating this thread with a troubleshooting guide available here for folks who have run into this issue.
Best part of this,beside me being a lemming pasting commands in the terminal ,is having a fresh install of the latest Ubuntu.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.