You are not logged in.

#1 2017-09-15 13:34:44

santiagorp
Member
Registered: 2017-09-15
Posts: 2

Change ownership/permissions of /usr/bin and /usr/share

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

#2 2017-09-15 13:41:17

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Change ownership/permissions of /usr/bin and /usr/share

You could install [community]/pacutils and use pacrepairfile. smile

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

#3 2017-09-15 14:24:16

santiagorp
Member
Registered: 2017-09-15
Posts: 2

Re: Change ownership/permissions of /usr/bin and /usr/share

Great!

I'll use `pacrepairfile` then. If it does not work I will check the other solution.

Thanks a lot!

Offline

#4 2017-09-15 14:34:18

Blasphemist
Member
From: Colorado
Registered: 2013-01-17
Posts: 160

Re: Change ownership/permissions of /usr/bin and /usr/share

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

#5 2017-09-15 14:56:17

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Change ownership/permissions of /usr/bin and /usr/share

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'

Last edited by Trilby (2017-09-15 14:58:56)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2017-09-15 17:57:25

Blasphemist
Member
From: Colorado
Registered: 2013-01-17
Posts: 160

Re: Change ownership/permissions of /usr/bin and /usr/share

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.


Simple and Open

Offline

#7 2017-09-15 18:03:43

Blasphemist
Member
From: Colorado
Registered: 2013-01-17
Posts: 160

Re: Change ownership/permissions of /usr/bin and /usr/share

Blasphemist wrote:
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

#8 2017-09-15 21:16:01

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Change ownership/permissions of /usr/bin and /usr/share

$ 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

Board footer

Powered by FluxBB