恢复 /usr 下文件的所有权更改,Void Linux

恢复 /usr 下文件的所有权更改,Void Linux

chown -R root:root /usr我在 Void Linux 系统上失去了理智

有人愿意将ls -lR /usrVoid 系统的结果邮寄给我吗?我将检查这些更改,让一切再次正常工作,并在这个问题中发布我的发现。

根据 msp9011 的回复,并意识到我需要 xfce4、networkmanager 系统的信息,请发布结果:

find /usr/ \(  -perm -4000 \)  -exec ls -l {} +

find /usr/ \( ! -group root \)  -exec ls -l {} +

你能在某个地方分享结果吗?

PS 只是重新安装 Void 很痛苦,因为我正在进行长途旅行,而且我的互联网访问通常是通过蜂窝网络或糟糕的 wifi 进行的。

答案1

您可以使用 重新安装受影响的软件包,除非您指定两次,xbps-install -f否则它将保留配置文件。-f

 -f, --force
     Force downgrade installation (if package version in repos is less
     than installed version), or reinstallation (if package version in
     repos is the same) to the target PKG, overwriting regular package
     files and symlinks (if they have been modified) but preserving
     configuration files.  If -f is specified twice all files will be
     unpacked, even configuration files.

xbps-pkgdb(1)能够检测包文件的许多问题,但遗憾的是目前不能检测所有者/模式,但这将是一个很好的添加功能。

答案2

希望这是您所需要的,

[root@localhost usr]# find /usr/ \(  ! -group root \)  -exec ls -l {} +
-rwx--s--x. 1 root slocate   38464 Mar 12  2015 /usr/bin/locate
-rwxr-sr-x. 1 root nobody   141384 Aug 31  2017 /usr/bin/ssh-agent
---s--x---. 1 root stapusr  183072 Jun 19  2018 /usr/bin/staprun
-r-xr-sr-x. 1 root tty       15224 Jul 24  2015 /usr/bin/wall
-rwxr-sr-x. 1 root tty       12016 Jan 26  2018 /usr/bin/write
-rwx--s--x. 1 root utmp      17160 May  9  2018 /usr/lib64/vte/gnome-pty-helper
-rwx--s--x. 1 root utmp       9808 Aug 18  2010 /usr/libexec/utempter/utempter
-rwx--s--x. 1 root lock      15808 Aug 19  2010 /usr/sbin/lockdev
-rwxr-sr-x. 1 root postdrop 189000 Mar 23  2017 /usr/sbin/postdrop
-rwxr-sr-x. 1 root postdrop 217832 Mar 23  2017 /usr/sbin/postqueue
-r-s--x---. 1 root apache    13984 Jun 19  2018 /usr/sbin/suexec

/usr/libexec/utempter:
total 12
-rwx--s--x. 1 root utmp 9808 Aug 18  2010 utempter

答案3

我通过 Void live USB 棒恢复了权限!我做了一个find /usr -printf "0%m %u:%g %p\n" > permissions-all生成一个具有 /usr 中所有权限的文件。然后从 borked 安装启动,我使用一个简单的 bash 脚本来恢复所有权限。xbps-install -f如果您的连接性很差并且您想要恢复系统的大部分内容(例如 xfce4),那么这是有问题的。谢谢大家的思考,我学到了很多!

/usr/permissions-all 的头

0755 root:root /usr
0755 root:root /usr/lib
0755 root:root /usr/lib/libimobiledevice.so.6.0.0
0777 root:root /usr/lib/libsoxr.so.0
0777 root:root /usr/lib/libXvMCr600.so.1.0
0777 root:root /usr/lib/libwebpmux.so.3
0755 root:root /usr/lib/audit
0755 root:root /usr/lib/audit/sotruss-lib.so
0777 root:root /usr/lib/libfontenc.so.1
0755 root:root /usr/lib/libvulkan_radeon.so
0755 root:root /usr/lib/libthunarx-3.so.0.0.0
0777 root:root /usr/lib/libturbojpeg.so.0

脚本恢复权限.sh

#!/bin/bash
set -e
while read p ug f
do
    if [ -e "$f" ] ; then
        ug_=$(find "$f" -maxdepth 0 -printf "%u:%g")
        p_=$(find "$f" -maxdepth 0 -printf "0%m")
        if [ "$ug_" != "$ug"  ] ; then
            echo "$f wrong ug $ug_ should be $ug, fixing"
            chown $ug "$f"
        fi
        if [ "$p_" != "$p"  ] ; then
            echo "$f wrong perms $p_ should be $p, fixing"
            chmod $p "$f"
        fi
    fi
done < permissions-all

我已将我的permissions-all脚本和恢复脚本添加到公共 google-drive 文件夹中,以便任何遇到相同问题的人都可以尝试。该文件来自最新的 void xfce4 live 磁盘。这里谷歌驱动器是数据。

相关内容