有没有办法恢复 Debian squeeze 中的默认文件权限?

发布于 2024-12-27 02:02:22 字数 1459 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寂寞笑我太脆弱 2025-01-03 02:02:22

确实没有必要重新安装或任何其他此类严厉措施。只要您仍然拥有 root 访问权限,只需做一些工作,系统就可以正常工作。

您使用了短语“不会启动到任何用户帐户”。从这里我认为您的意思是系统将引导,您只是无法以 root 以外的任何用户身份登录

在任何 Linux 发行版上,除了 /home/[USERNAME] 中的文件之外,系统上几乎所有文件都归 root 所有。

您很可能可以像其他用户一样进行身份验证,但由于他们的配置文件等由 root 用户拥有,因此系统无法完成登录过程。您可以通过检查 /var/log/auth.log 轻松验证这一点。

我要做的第一件事是将 /home 中各个用户目录的文件和目录权限修复为适当的用户和组。这可以通过一个简单的命令从 /home 完成。

chown 就是你想要的程序。阅读手册页以获取更多信息,但基本上只是:

chown [path to user's home directory (i.e. /home/user) -R username.username.

假设您有用户“foo”。您可以执行以下命令:

chown -R foo.foo /home/foo

添加一点 for 循环,您可以一下子更改权限:(假设您使用的是 bash):

for i in /home/*; do name=`basename $i`; chown -R $name.$name $i; done

您现在应该能够以任何用户身份登录。

There really is no need to re-install or any other such drastic measures. With a little work the system will be fine, as long as you still have root access.

You used the phrase "won't boot into any user account." From that I take you to mean that the system will boot you just can't log in as any user other than root.

On any linux distro almost all files on the system except those in /home/[USERNAME] are owned by root.

You are most likely authenticating as the other users just fine, but since their config files, etc. are owned by root the system cannot complete the login process. You can easily verify this by checking /var/log/auth.log

The first thing I'd do is fix the file and directory permissions on the various user directories in /home to the appropriate user and group. This can be done from /home with a simple command.

chown is the program you want. Read the man page for more info but basically just:

chown [path to user's home directory (i.e. /home/user) -R username.username.

Say for instance you had user 'foo'. You'd execute this command:

chown -R foo.foo /home/foo

Add a little for loop and you could change the perms in one fell swoop: (assuming you're using bash):

for i in /home/*; do name=`basename $i`; chown -R $name.$name $i; done

You should now be able to log in as any user just fine.

峩卟喜欢 2025-01-03 02:02:22

原来的系统就无法启动了。

可能

  • 使用其他介质启动操作系统,
  • 检索并备份 /home/etc
  • 重新安装 Debian,
  • 恢复备份。

Knoppix 是一个很好的系统,可用于访问和恢复第一个驱动器,或者您可以尝试引导 Debian 本身(从另一个磁盘或 CD)来执行此操作。

The original system won't boot anymore.

Probably

  • Boot an OS using another medium,
  • retrieve and backup /home and /etc,
  • re-install Debian,
  • restore backups.

Knoppix is a good system to use to access and restore the first drive, or you could try to boot Debian itself (from another disk or a CD) to do that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文