当我放错斜杠时,我意外地使用 chown 将 /bin、/boot、/etc 和 /dev 的所有权递归地更改为 nobody:nogroup!
我怎样才能恢复原始文件所有权?
我已设法将它们全部放到 root:root 但我不确定所有文件是否都应该归 root 所有,以及这是否会破坏某些东西?
他们是否有像 OS X 那样的修复文件权限的选项?
帮助!
答案1
我运行 debian squeeze,并使用以下命令:
$> sudo find /bin /boot /etc /dev ! \( -user root -group root \) -printf '%p\t%u\t%g\n'
获取不属于 root 的文件列表:root(将普通用户更改为名为“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
手动更改的次数不应太多,并且希望您的系统与我的系统不会有太大差别。
答案2
这是可以做到的。不过,这需要一点努力。
找到另一个可以安装相同发行版的系统(最好是虚拟的)。创建与 borked 系统具有相同 UID 的用户。更新它,以便所有软件包都与 borked 系统处于相同的版本级别。将旧系统的根目录作为 /mnt/ 挂载到新系统上。然后:
[root@good-system ~] find / -name /proc -prune -o -exec chown --reference={} /mnt/{}