0

By mistake I changed /bin to a user/group. Is there a way to revert to the default users/groups? The command I executed is:

chown -R -H -v starlord:starlord /bin
fbm224
  • 151
  • change /etc to /bin – Zanna Apr 17 '17 at 18:22
  • 1
    It's almost never a good idea to use chown -R or chmod -R, since the permissions are usually set the way they are for good reasons. Take the time to figure out how to do things in the "proper" way to avoid headaches. – Chai T. Rex Apr 17 '17 at 19:27

2 Answers2

1

Files from a clean install in /bin with setuid bit set

On a clean install, the following files in bin have the setuid bit set (according find /bin -perm -4000):

/bin/ping
/bin/ping6
/bin/su
/bin/umount
/bin/fusermount
/bin/mount
/bin/ntfs-3g

Note: You may have installed software which adds to that list (or which, for some reason, has the setgid bit set), so the following may not work completely, since it will leave the setuid bit off of anything not in that list.

Correcting the problem

sudo chown -R -H root:root /bin
sudo chmod u+s /bin/ping /bin/ping6 /bin/su /bin/umount /bin/fusermount /bin/mount /bin/ntfs-3g

Avoiding the problem in the future

It's rarely a good idea to modify anything in /bin, which is reserved for files installed and maintained via the package manager. The package manager, not you, owns /bin.

If you remove something, the things that depend on it will break. If you change or add something, your changes can be obliterated in a future update via the package manager.

Instead, store programs useful for all users in places like /usr/local/bin and /usr/local/sbin. Store programs useful for only one user in ~user/bin. Those places are owned and managed by the system administrator and the individual user respectively.

If you still want to ignore that advice, the correct way to modify things in /bin is to use sudo. For example, you can copy a file into /bin with:

sudo cp program /bin

You can delete it with:

sudo rm /bin/program
Chai T. Rex
  • 5,193
0

Try running sudo chown -R -H root:root /bin

Provided you haven't also run any chmod commands on /bin that should revert things back to the way they should be

Will
  • 655
  • 1
    Unfortunately, this won't work fully, since there are some setuid root commands there that won't have the setuid bit set anymore. This can be verified with, for example, ping 8.8.8.8, which gives ping: socket: Operation not permitted twice. – Chai T. Rex Apr 17 '17 at 19:32