DEV Community

Cover image for Don't make this mistake  sudo chown -R 'userName' /*
Ismael Garcia
Ismael Garcia

Posted on • Updated on

Don't make this mistake sudo chown -R 'userName' /*

Recently I was trying to change the owner for the folder that a docker compose volume created and I accidentally ran the following command

 sudo chown -R 'userName' /*
Enter fullscreen mode Exit fullscreen mode

Then hell broke lose, so now probably you are in the same situation.

Reboot your computer and hold F11 (Please check which one is for your computer, F8 is the case on my computer) after the BIOS splash to bring up the GRUB boot menu. If you use one of the popular distros of linux (something like Ubuntu), there should be an option to start linux in recovery mode (the option might be found under 'Advanced Options' sub-menu if you use GRUB 2). Start linux in recovery mode.

Then select the option that will give you a root prompt. Since the shell is logged in as root, all commands will be run as root without needing the sudo command. You can use this to repair the permissions on /usr/bin/sudo:

chown root:root /usr/bin/sudo
chmod u+s /usr/bin/sudo
exit
Enter fullscreen mode Exit fullscreen mode

After this you can reboot to regular mode that should fix it

Discussion (0)