You are not logged in.

#1 2017-07-24 17:09:23

headsht
Member
Registered: 2017-01-28
Posts: 8

[SOLVED] Possible ways to recover after chown -R user /usr/...

I was trying to fix npm permissions and executed this command:

 sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share} 

I didn't read the fine print - okay, it was a warning in red text - regarding 'npm config get prefix' which is supposed to output /usr/local and not /usr . The command was executed as:

 sudo chown -R user /usr/{lib/node_modules,bin,share} 

Are all files in /usr/lib/ and /usr/bin/ /usr/share/ owned by root?

Last edited by headsht (2017-07-24 20:42:53)

Offline

#2 2017-07-24 17:16:25

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] Possible ways to recover after chown -R user /usr/...

All of mine appear to be, but then again I won't have the same packages installed that you do.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2017-07-24 17:21:03

progandy
Member
Registered: 2012-05-17
Posts: 5,190

Re: [SOLVED] Possible ways to recover after chown -R user /usr/...

You can start with setting everything to root. Afterwards run "pacman -Qkk" to check if everything is OK, then reinstall the few packages which show UID errors.

Last edited by progandy (2017-07-24 17:21:44)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#4 2017-07-24 17:41:33

headsht
Member
Registered: 2017-01-28
Posts: 8

Re: [SOLVED] Possible ways to recover after chown -R user /usr/...

progandy wrote:

You can start with setting everything to root. Afterwards run "pacman -Qkk" to check if everything is OK, then reinstall the few packages which show UID errors.

Is there a way to automatically reinstall every permission uid and gid mismatch from the result of 'pacman -Qkk' or do I have to do it manually?

Offline

#5 2017-07-24 17:49:55

adesh
Member
Registered: 2016-10-05
Posts: 167

Re: [SOLVED] Possible ways to recover after chown -R user /usr/...

It may be overkill but probably reinstalling all packages will fix the permissions.

Offline

#6 2017-07-24 18:07:38

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

Re: [SOLVED] Possible ways to recover after chown -R user /usr/...

You can just filter the -Qkk output.  The following would reinstall packages with UID or GID mismatch warnings:

pacman -S $(pacman -Qkk 2>&1 1>/dev/null | awk -F: '/[UG]ID mismatch/{ print $2; }')

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

Offline

#7 2017-07-24 18:15:29

loqs
Member
Registered: 2014-03-06
Posts: 17,304

Re: [SOLVED] Possible ways to recover after chown -R user /usr/...

adesh wrote:

It may be overkill but probably reinstalling all packages will fix the permissions.


Pacman does not alter ownership or access permissions on package (re)installation.

Edit:
Pacman will alter ownership or access permissions of files but not directories.

Last edited by loqs (2017-07-24 18:51:14)

Offline

#8 2017-07-24 18:22:53

headsht
Member
Registered: 2017-01-28
Posts: 8

Re: [SOLVED] Possible ways to recover after chown -R user /usr/...

loqs wrote:
adesh wrote:

It may be overkill but probably reinstalling all packages will fix the permissions.

Pacman does not alter ownership or access permissions on package (re)installation.

So is there an alternative to manually going through every package?

Offline

#9 2017-07-24 18:35:50

loqs
Member
Registered: 2014-03-06
Posts: 17,304

Re: [SOLVED] Possible ways to recover after chown -R user /usr/...

I would follow the advice in post #3 then see how many mismatches there are from pacman -Qkk.
Depending on the size of the list would affect if I tried to write a script to parse the output of pacman -Qkk or just altered the entries manually.
Edit:
Apologies it does change ownerships and access permissions so see post #6 to automatically fix things
Sorry for the mis information
Edit2:
It changes access permissions as well.
Edit3:
Pacman will change ownership and access permissions of files but not directories.

Last edited by loqs (2017-07-24 18:52:05)

Offline

#10 2017-07-24 19:03:54

apg
Developer
Registered: 2012-11-10
Posts: 211

Re: [SOLVED] Possible ways to recover after chown -R user /usr/...

Offline

#11 2017-07-24 20:42:25

headsht
Member
Registered: 2017-01-28
Posts: 8

Re: [SOLVED] Possible ways to recover after chown -R user /usr/...

I ended up reinstalling all packages (pacman -Qnq | pacman -S -).

Offline

Board footer

Powered by FluxBB