You are not logged in.

#1 2008-02-05 14:51:38

loosec
Member
Registered: 2007-03-08
Posts: 134

[SOLVED] chown -R root:root /

Ok, Was standing in /root as root. Has some folders copied here that had wrong permission so naturally I ran:
chown -R root:root *
and everything was fine.

Genious that I am I also thought of all the hidden files/folders and ran:
chown -R root:root .*

and a silent hell broke loose, followed by errors from /proc that the owner could not be changed. CTRL-C stopped this.
Every file is now owned by root:root, atleast all up to /proc.


First of all: I did type EXACTLY as above and pwd was /root so why would this happen? Hard link somewhere in the hidden files of /root ?

Second: How the hell do I restore all correct owners/groups to all files in the system? I feel a reboot might be fatal at the moment.


Edit: sudo started working again after a pacman -Sf sudo so I think I've found how to solve this.
Initscripts and kernel26 are probably good things to install again. Home directory is easily solved with another chown -R me:users /home/me and the directories /tmp and /usr are not affected.

Is there any switch in pacman that forces _every_ package to be reinstalled? *reads*


Edit2: So a list of packages is spit out from pacman -Q however this is not directly useful since it alsa gives the version number after a whitespace. Since i suck att awk and sed I'll have to edit this list manually and then cut/paste it into pacman -Sf.

What I tried was: sudo pacman -Sf `pacman -Q`

Last edited by loosec (2008-02-05 16:37:12)

Offline

#2 2008-02-05 15:15:18

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: [SOLVED] chown -R root:root /

As to why: "echo .* matches .." add recursivity (1 level) "echo .*/*" and you see will a mushroom pattern.

I think your system should still be bootable.
On my system everything in /boot and /etc is owned by root:root. Only some stuff in /dev isn't (but this gets recreated by udev, right?)
Running "find ! -user root" and "find ! -group root" doesn't really reveal anything important in /usr either.

Use "pacman -Q | cut -d' ' -f1" to get the package list.

Offline

#3 2008-02-05 15:26:20

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: [SOLVED] chown -R root:root /

As Gilneas said, the pattern .* matches the directory .. - which is / when you're currently in /root, so doing chown .* root:root -R chowns .. and all subfolders of ..

Last edited by Cerebral (2008-02-05 15:27:00)

Offline

#4 2008-02-05 15:27:30

loosec
Member
Registered: 2007-03-08
Posts: 134

Re: [SOLVED] chown -R root:root /

Thank you Sir! I really need to read up on text-editing thou. Reboot in progress.

Offline

#5 2008-02-05 15:36:48

patroclo7
Member
From: Bassano del Grappa, ITALY
Registered: 2006-01-11
Posts: 915

Re: [SOLVED] chown -R root:root /

It has happened to me in the past. Not to discourage you, but I was forced to a complete reinstall. Most problems are in /var. I remember that in particular I was unable to launch the xserver due to some tricky troubles there.


Mortuus in anima, curam gero cutis

Offline

#6 2008-02-05 15:47:43

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: [SOLVED] chown -R root:root /

pacman -S $(pacman -Qq | grep -v "$(pacman -Qmq)")

Note that if you don't have any "foreign" packages, that is packages which don't belong to any database (displayed by pacman -Qm), it's simpler :
pacman -S $(pacman -Qq)


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#7 2008-02-05 15:50:40

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: [SOLVED] chown -R root:root /

Just as a matter of interest, is there someway you can run chown/chmod -R .* and exclude ..

smile for future reference

Offline

#8 2008-02-05 16:03:59

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: [SOLVED] chown -R root:root /

This command will list all hidden files, taking away . and ..:

ls -d .* | egrep -v "^\.\.?$"

You can stick that in the chmod command:

chmod root:root -R $(ls -d .* | egrep -v "^\.\.?$")

Last edited by Cerebral (2008-02-05 16:06:27)

Offline

#9 2008-02-05 16:13:49

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: [SOLVED] chown -R root:root /

gazj wrote:

Just as a matter of interest, is there someway you can run chown/chmod -R .* and exclude ..

smile for future reference

Something like this maybe:

chown -R root:root .[^.]*

I don't know how well chown understands regexps.

Offline

#10 2008-02-05 16:15:40

chimeric
Member
From: Munich, Germany
Registered: 2007-10-07
Posts: 254
Website

Re: [SOLVED] chown -R root:root /

You could also use an alias in your roots .bashrc to keep chown from doing any recursive processing on '/'.

alias chown="chown --preserve-root"

Last edited by chimeric (2008-02-05 16:17:28)

Offline

#11 2008-02-05 16:16:05

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: [SOLVED] chown -R root:root /

Ramses de Norre wrote:

I don't know how well chown understands regexps.

unless you put it in single quotes it is handled by bash.

Last edited by Gilneas (2008-02-05 16:19:46)

Offline

#12 2008-02-05 16:20:49

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: [SOLVED] chown -R root:root /

Ramses de Norre wrote:
chown -R root:root .[^.]*

Huh, that works quite well.  Yay bash!

 $ ls -d .[^.]*
.ssh           .bash_profile  .forward  .viminfo  .xsession
.bash_history  .bashrc        .lesshst  .xinitrc

Last edited by Cerebral (2008-02-05 16:21:23)

Offline

#13 2008-02-05 16:25:08

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: [SOLVED] chown -R root:root /

Mind an alias on ls though, it's quite common.

Maybe you could also use find "find . -exec chown root:root '{}' \;" this allows for some flexibility too like pruning a directory.

Offline

#14 2008-02-05 16:36:36

loosec
Member
Registered: 2007-03-08
Posts: 134

Re: [SOLVED] chown -R root:root /

Some very useful information there, great thanks.

System is up and about now, only slight inconveniences (spelling?) such as ping only working for root but i'll just sort through files and change groups where needed.

The chmod --preserve-root sounds like it almost should be default or at least posted somewhere.

Last edited by loosec (2008-02-05 21:05:57)

Offline

#15 2008-02-05 20:15:26

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: [SOLVED] chown -R root:root /

Cerebral wrote:
Ramses de Norre wrote:
chown -R root:root .[^.]*

Huh, that works quite well.  Yay bash!

 $ ls -d .[^.]*
.ssh           .bash_profile  .forward  .viminfo  .xsession
.bash_history  .bashrc        .lesshst  .xinitrc

Seems simple enough to stick in mind.  Thanks all!

Offline

#16 2008-02-06 10:19:15

loosec
Member
Registered: 2007-03-08
Posts: 134

Re: [SOLVED] chown -R root:root /

Cerebral wrote:

This command will list all hidden files, taking away . and ..:

ls -d .* | egrep -v "^\.\.?$"

You can stick that in the chmod command:

chmod root:root -R $(ls -d .* | egrep -v "^\.\.?$")

Also this would to the trick:

chmod -R root:root $(ls -A1)

Offline

#17 2008-03-11 12:45:58

praka123
Member
From: Kerala,India
Registered: 2008-03-04
Posts: 188
Website

Re: [SOLVED] chown -R root:root /

shining wrote:

pacman -S $(pacman -Qq | grep -v "$(pacman -Qmq)")

Note that if you don't have any "foreign" packages, that is packages which don't belong to any database (displayed by pacman -Qm), it's simpler :
pacman -S $(pacman -Qq)

Thanks!This options may help me(and others) to reinstall all packages which are already installed.
I need this as my archlinux partition fs went corrupt  after a hard reboot sad

Offline

Board footer

Powered by FluxBB