Xubuntu 16.04 ttyname 失败 设备的 ioctl 不合适

boy*_*ley 8 linux root xubuntu ubuntu auto-login

我需要作为独立演示系统的root用户启动 Xubuntu 。

无论是使用 的自动登录功能lightdm,还是在出现提示时通过“其他”>“root”登录时,我总是得到以下响应:

Error found when loading /root/.profile
mesg: ttyname failed: Inappropriate ioctl for device
As result the session will not be configured correctly.
You should fix the problem as soon as feasible.
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

清除上面的弹出框后,系统与ROOT用户按预期执行。

以下是内容/etc/lightdm/lightdm.conf

[Seat:*]
autologin-guest=false 
autologin-user=root
autologin-user-timeout=0
Run Code Online (Sandbox Code Playgroud)

我在网上看到过与 Vagrind 相关的其他类似问题,并且这些问题已通过一些最新更新解决,但这似乎仍在 Xubuntu 16.04 上发生

https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1584488

如何解决 Vagrant 中的`ttyname failed: Inproper ioctl for device`?

大多数论坛都声明此消息是错误的,不应显示。有没有办法以 root 身份自动启动 Xubuntu,同时避免这个错误的弹出窗口?

Dav*_* C. 15

最终的原因是,Xubuntu 显然没想到任何人对 root 帐户执行图形登录,因此它的默认.profile文件在这种情况下会产生虚假错误。如果您查看 /root/.profile 的最后一行,您会发现:

mesg n || true
Run Code Online (Sandbox Code Playgroud)

这是为了防止诸如talk写入控制台之类的程序。如果您通过文本会话(来自 xterm、ssh 等的 su)登录到 root,这一点尤其重要,因为这些消息会使屏幕变得混乱。

|| true一点是为了防止 shell 脚本在 mesg 失败时终止(因为它在这里失败),但这并不能阻止它在失败时生成错误消息,正如您所看到的。

问题的原因是,通过将这一行放在 .profile 中,它会在每次执行 bash 时运行,即使它是从没有 tty 设备的会话中运行的(比如在图形登录的最早部分),所以你会看到错误。这是无害的,因为mesg无论如何从没有 TTY 的会话中运行是没有意义的,但桌面不知道这一点并显示消息。

一种解决方案(如您引用的问题中的评论所说)是更改该行,以便mesg在没有 TTY 时不会尝试调用:

tty -s && mesg n || true
Run Code Online (Sandbox Code Playgroud)

这告诉它在mesg没有 TTY 时不要尝试调用,但在有 TTY 时仍会调用它(例如从 SSH 登录)。