无法再登录到我的 Ubuntu 服务器

Mr.*_* Jo 2 linux shell ubuntu

我试图为我的 root 用户更改 shell。当我现在使用无权限用户登录并尝试使用 切换到我的 root 用户时su root -> password,登录失败,因为此消息:

Cannot execute whereis zsh: No such file or directory
Run Code Online (Sandbox Code Playgroud)

问题是,我在 shell 更改为 zsh 期间输入了错误的路径。知道如何解决此问题以便我可以重新登录吗?

Phi*_*ing 6

sudo默认情况下已安装Ubuntu 。如果您仍然拥有 sudo 访问权限,您应该能够

sudo chsh -s /bin/bash root
Run Code Online (Sandbox Code Playgroud)

这会将 root 的 shell 重置为 bash。先试试这个。

如果您没有 sudo 访问权限,那么您需要找到一种方法来编辑/etc/passwd. 您可能需要使用特殊选项启动系统,为您提供一个 root shell,或者您可以将您的磁盘驱动器插入另一台机器。


如果你真的需要 root shell,这里有说明:http : //tipsonubuntu.com/2016/09/02/reset-forgotten-passwords-ubuntu-16-04/

在启动时,您可以:

  • 选择Advanced option for Ubuntu--> Ubuntu .... (Recovery Mode)-->root - Drop to root shell prompt
  • 或...按下eUbuntu被选中并将文本添加init=/bin/bash到 linux 参数