Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I accidentally changed the ownership of the /bin, /boot, /etc and /dev recursively to nobody:nogroup using chown when I misplaced a forward slash!

How can I resort the original file ownerships?

I've managed to get them all to root:root but I'm not sure if all the files should be owned by root and if this will break something?

Is they are option to fix file permissions like there is in OS X?

Help!

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I run debian squeeze, and I used the following command:

$> sudo find /bin /boot /etc /dev ! \( -user root -group root \) -printf '%p\t%u\t%g\n'

to get this list of files not owned by root:root (changed normal user to name "me"):

/etc/shadow root    shadow
/etc/privoxy/trust  privoxy root
/etc/privoxy/global.action  privoxy root
/etc/privoxy/user.action    privoxy root
/etc/privoxy/global.action.dpkg-old privoxy root
/etc/identd.key identd  root
/etc/at.deny    root    daemon
/etc/ssl/private    root    ssl-cert
/etc/ssl/private/ssl-cert-snakeoil.key  root    ssl-cert
/etc/gshadow    root    shadow
/etc/cups   root    lp
/etc/cups/printers.conf.O   root    lp
/etc/cups/printers.conf root    lp
/etc/cups/ssl   root    lp
/etc/cups/ssl/server.crt    root    lp
/etc/cups/ssl/server.key    root    lp
/etc/cups/ppd   root    lp
/etc/fuse.conf  root    fuse
/etc/exim4/passwd.client    root    Debian-exim
/dev/dri/card0  root    video
/dev/xconsole   root    adm
/dev/fuse   root    fuse
/dev/loop5  root    disk
/dev/loop6  root    disk
/dev/loop2  root    disk
/dev/loop3  root    disk
/dev/loop7  root    disk
/dev/loop1  root    disk
/dev/loop4  root    disk
/dev/mixer1 root    audio
/dev/dsp1   root    audio
/dev/audio1 root    audio
/dev/mixer  root    audio
/dev/dsp    root    audio
/dev/adsp   root    audio
/dev/audio  root    audio
/dev/snd/controlC1  root    audio
/dev/snd/pcmC1D0p   root    audio
/dev/snd/pcmC1D0c   root    audio
/dev/snd/controlC0  root    audio
/dev/snd/pcmC0D4p   root    audio
/dev/snd/pcmC0D3c   root    audio
/dev/snd/pcmC0D0p   root    audio
/dev/snd/pcmC0D1c   root    audio
/dev/snd/pcmC0D0c   root    audio
/dev/snd/pcmC0D2c   root    audio
/dev/snd/seq    root    audio
/dev/snd/timer  root    audio
/dev/loop0  root    disk
/dev/shm/pulse-shm-2780159313   me  me
/dev/shm/pulse-shm-1228309411   me  me
/dev/shm/pulse-shm-1153223704   me  me
/dev/shm/pulse-shm-3080420302   me  me
/dev/shm/pulse-shm-1994524084   me  me
/dev/pts/3  me  tty
/dev/pts/5  me  tty
/dev/pts/4  me  tty
/dev/pts/2  me  tty
/dev/pts/1  me  tty
/dev/pts/0  me  tty
/dev/hda1   root    disk
/dev/hda2   root    disk
/dev/hda    root    disk
/dev/hdc    root    cdrom
/dev/agpgart    root    video
/dev/fd0    root    floppy

Shouldn't be too many to change by hand, and hopefully your system doesn't differ too much from mine.

share|improve this answer
    
my orignal mistake was that I did a chown -R nobody:nogroup / and it had fully changed all the files in first 4 root directories before I cancelled it. I've managed to change all the files in those folders to root:root. My concern is that it is quite possible that not all the files in those directories should be owned by root. That said the server is still working, though I don't dare restart it. –  Camsoft Apr 30 '10 at 10:29
    
I wasn't really clear in my answer, but the output of the command I displayed above shows in order: filename, user, group, for all the files not owned by root:root on my debian system. I imagine your system uses many, if not all of the same permissions. I don't know if there is a way to restore permissions e.g. with apt –  jberryman May 1 '10 at 18:52

It can be done. However, it will take a little doing.

Find another system(preferably virtual) that you can install the same distro on. Create users with the same UID as the borked system. Update it so that all the packages are at the same version level as the borked system. Mount the root of the old system as /mnt/ on the new system. Then:

[root@good-system ~] find / -name /proc -prune -o -exec chown --reference={} /mnt/{}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.