You are not logged in.
By accident I did execute the following command
$ sudo chmod -R my_username /usr/bin /usr/share
As a result sudo, su, etc stopped working. I managed to go to new terminal, login as root and do the following:
$ chown -R root.root /usr/share /usr/bin
Still sudo did not work since it was missing the SUID flag. I fixed that with as root from a terminal:
$ chmod u+s /usr/bin/sudo /usr/bin/su
Now I have /bin/sudo and /bin/su working again. However I am afraid I have messed up ownership of other files there.
Which is the best way to restore the default ownership, permissions and flags of all the system files?
Can I reinstall all the packages already installed in order to restore the file permissions? How?
Thanks a lot!!!
Offline
You could install [community]/pacutils and use pacrepairfile.
Alternatively, reinstalling all packages with `pacman -S $(pacman -Qq)` would certainly do it, but is probably overkill especially as you'd probably want to first filter out packages that aren't actually broken as per pacman -Qkk or don't have files in those directories as per pacman -Qo.
Last edited by eschwartz (2017-09-15 13:44:11)
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Great!
I'll use `pacrepairfile` then. If it does not work I will check the other solution.
Thanks a lot!
Offline
It looks to me like you should ensure that all changed should be owned by root, group root and permissions 755.
Simple and Open
Offline
It looks to me like you should ensure that all changed should be owned by root, group root and permissions 755.
That's a horrible idea. Execute permission wasn't removed from any file that had it. But adding it back to everything will add execute permissions to *many* files that shouldn't be executable.
This could give the list to reinstall, and could be passed to pacman -S:
pacman -Qkk 2>/dev/null | sed -n '/[1-9]0* altered/ s/:.*//p'
Last edited by Trilby (2017-09-15 14:58:56)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Blasphemist wrote:It looks to me like you should ensure that all changed should be owned by root, group root and permissions 755.
That's a horrible idea. Execute permission wasn't removed from any file that had it. But adding it back to everything will add execute permissions to *many* files that shouldn't be executable.
This could give the list to reinstall, and could be passed to pacman -S:
pacman -Qkk 2>/dev/null | sed -n '/[1-9]0* altered/ s/:.*//p'
What are the permissions on those on your system? I didn't change them and that's what they are on mine.
Simple and Open
Offline
Trilby wrote:Blasphemist wrote:It looks to me like you should ensure that all changed should be owned by root, group root and permissions 755.
That's a horrible idea. Execute permission wasn't removed from any file that had it. But adding it back to everything will add execute permissions to *many* files that shouldn't be executable.
This could give the list to reinstall, and could be passed to pacman -S:
pacman -Qkk 2>/dev/null | sed -n '/[1-9]0* altered/ s/:.*//p'
What are the permissions on those on your system? I didn't change them and that's what they are on mine.
I take this back because there are a few files and directories with different permissions even if the vast majority are 755.
Simple and Open
Offline
$ sudo find /usr/{bin,share} -perm 0755 | wc -l
9343
$ sudo find /usr/{bin,share} | wc -l
100522
So on my system, your solution would do nothing for the 9.3% of the files which already properly had that permission and it would screw up the other 90.7% for no good reason. Note that the problem of this thread was not that executable permission was removed from any file, so adding it back fixes nothing and breaks almost everything.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline