恢复 /usr 文件夹的权限默认值

恢复 /usr 文件夹的权限默认值

我运行了一个愚蠢的命令:sudo chown -R ngoclb:ngoclb /usr。然后我无法使用 sudo 命令并登录 Ubuntu。为了解决这个问题,我使用恢复模式将权限更改/usr为 root ( sudo chown -R root:root /usr) 并可以登录 Ubuntu,但现在,Ubuntu 的 GUI 不像默认的(对于某些组件,它与 Windows 经典相同:滚动条、菜单...)并且我无法访问系统设置/用户帐户。我该如何解决这个问题?

答案1

几乎所有东西/usr都归root:root

find /usr -not -gid 0 -printf "%M\t%u\t%g\t%p\n"在这里使用 15.04 运行,输出是

-r-xr-sr-x  root    postdrop    /usr/sbin/postqueue
-rwsr-xr--  root    dip /usr/sbin/pppd
-r-xr-sr-x  root    postdrop    /usr/sbin/postdrop
drwxrwsr-t  root    lpadmin /usr/share/ppd/custom
drwxrwsr-x  root    staff   /usr/local/share/xml
drwxrwsr-x  root    staff   /usr/local/share/xml/declaration
drwxrwsr-x  root    staff   /usr/local/share/xml/entities
drwxrwsr-x  root    staff   /usr/local/share/xml/schema
drwxrwsr-x  root    staff   /usr/local/share/xml/misc
drwxrwsr-x  root    staff   /usr/local/share/emacs
drwxrwsr-x  root    staff   /usr/local/share/emacs/site-lisp
drwxrwsr-x  root    staff   /usr/local/share/sgml
drwxrwsr-x  root    staff   /usr/local/share/sgml/declaration
drwxrwsr-x  root    staff   /usr/local/share/sgml/entities
drwxrwsr-x  root    staff   /usr/local/share/sgml/dtd
drwxrwsr-x  root    staff   /usr/local/share/sgml/stylesheet
drwxrwsr-x  root    staff   /usr/local/share/sgml/misc
drwxrwsr-x  root    staff   /usr/local/share/ca-certificates
drwxrwsr-x  root    staff   /usr/local/share/fonts
drwxrwsr-x  root    staff   /usr/local/lib/python3.4
drwxrwsr-x  root    staff   /usr/local/lib/python3.4/dist-packages
drwxrwsr-x  root    staff   /usr/local/lib/python2.7
drwxrwsr-x  root    staff   /usr/local/lib/python2.7/dist-packages
drwxrwsr-x  root    staff   /usr/local/lib/python2.7/site-packages
drwxr-xr-x  root    utempter    /usr/lib/utempter
-rwxr-sr-x  root    utmp    /usr/lib/utempter/utempter
-rwxr-sr-x  root    mail    /usr/lib/evolution/camel-lock-helper-1.2
-rwsr-xr--  root    messagebus  /usr/lib/dbus-1.0/dbus-daemon-launch-helper
-rwxr-sr-x  root    utmp    /usr/lib/libvte-2.91-0/gnome-pty-helper
-rwxr-sr-x  root    crontab /usr/bin/crontab
-rwxr-sr-x  root    tty /usr/bin/wall
-rwxr-sr-x  root    tty /usr/bin/bsd-write
-rwxr-sr-x  root    shadow  /usr/bin/chage
-rwxr-sr-x  root    shadow  /usr/bin/expiry
-rwxr-sr-x  root    mail    /usr/bin/mail-unlock
-rwxr-sr-x  root    mlocate /usr/bin/mlocate
-rwxr-sr-x  root    mail    /usr/bin/dotlockfile
-rwxr-sr-x  root    mail    /usr/bin/mail-touchlock
-rwxr-sr-x  root    mail    /usr/bin/mail-lock
-rwxr-sr-x  root    ssh /usr/bin/ssh-agent
-rwsr-sr-x  daemon  daemon  /usr/bin/at

并且根据输出,我看不出你可能犯了什么错误,导致你得到你所描述的结果。可能是 dbus 的东西……

但您仍然可以手动 chown 上述文件来尝试恢复您的 ubuntu。

你可能没有相同的文件,或者我可能会错过你的一些文件,所以即使你手动chown上面的文件,你还没有完全完成。

相关内容