fra*_*one 6 xorg tty xinit chvt
我想启动一个 Xorg 服务器(它应该只具有xterm
来自新创建的“原始”的最小终端模拟器tty
)。我认为这就像发出 axinit
或可能 a一样简单startx
,但两者都让我失望。因此问题是:
如何在不同的 VT/TTY 上手动运行/初始化/启动 Xorg 服务器?
这里的
这是背景和我已经尝试过的:
看看man openvt
我能够在新创建的tty
(或者vt
,无法准确说出不同的vt <> tty)上运行 shell,如下所示:
$> sudo openvt -s /bin/bash
Run Code Online (Sandbox Code Playgroud)
导致-s
直接切换到新 tty 上的新 tty/vt 我想手动启动一个Xorg
服务器,该服务器man xinit
应该以最小的xterm
应用程序启动。在切换到 tty I (通过创建openvt
)的新 shell 上,我因此发出以下命令:
$> su -c 'xinit xterm -display :4 -- :4' - mahr &>/tmp/output
Run Code Online (Sandbox Code Playgroud)
我收到这个输出
$> cat /tmp/output
X.Org X Server 1.19.6
Release Date: 2017-12-20
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.4.0-148-generic x86_64 Ubuntu
Current Operating System: Linux scitech 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64
Kernel command line: BOOT_IMAGE=/vmlinuz-4.15.0-70-generic root=/dev/mapper/ubuntu--vg-root ro
Build Date: 03 June 2019 08:10:35AM
xorg-server 2:1.19.6-1ubuntu4.3 (For technical support please see http://www.ubuntu.com/support)
Current version of pixman: 0.34.0
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/home/mahr/.local/share/xorg/Xorg.4.log", Time: Thu Nov 28 10:57:53 2019
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
(EE)
Fatal server error:
(EE) parse_vt_settings: Cannot open /dev/tty0 (Permission denied)
(EE)
(EE)
Please consult the The X.Org Foundation support
at http://wiki.x.org
for help.
(EE) Please also check the log file at "/home/mahr/.local/share/xorg/Xorg.4.log" for additional information.
(EE)
(EE) Server terminated with error (1). Closing log file.
Session terminated, terminating shell...xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: unexpected signal 2
...terminated.
Run Code Online (Sandbox Code Playgroud)
不要使用xinit
,因为它很脆弱。使用startx
。 xinit
似乎被编写为接受来自任何用户 ID 的 X 连接,没有警告或文档。 startx
似乎可以解决这个问题。我不知道为什么这种情况会被容忍,也不知道它最初是如何发生的。
工作方式X
“最近”发生了变化。 X
过去依赖于被set-uid root,并切换到新的VT。请注意,即使如此,也X
只有从文本 VT 启动它才可能起作用。例如,非 root 用户可能无法X
从另一个会话中启动X
。换句话说,我不确定这是否会达到您想要的效果。
X 现在已更改,以便它可以使用当前的VT。一些工具已经startx
改变了它们的行为,以使用新的设计。
其设计是您不需要以 root 身份启动任何程序(以提高安全性)。这是通过使用logind
较小的后台服务(以 root 权限启动)来实现的。
如果您返回X
以 root 身份运行,则不需要 的许可logind
。我认为X
可能会与此保持兼容。
您似乎一直在尝试运行X
而不强制其运行为满root
。在这种情况下,您需要获得 的许可logind
。 授予您在登录的 VT 上logind
执行操作的权限。我想出了一个欺骗登录的技巧。
user=mahr
sudo systemd-run \
--property PAMName=login \
--property User="$user" \
--property StandardInput=tty \
--property TTYPath=/dev/tty8 \
sh -c 'chvt 8 && exec startx /usr/bin/xterm'
Run Code Online (Sandbox Code Playgroud)
感觉应该也可以动态分配 tty(使用openvt -s
,以及使用该命令的脚本tty
)。然而,我只是冻结了我的屏幕几次试图做到这一点:-)。
(logind
旨在减少像X服务器这样的非root程序对系统造成的损害。AIUI的实现非常有限。它不提供恢复密钥。 logind
如果您使用内核系统注意密钥,甚至会被严重杀死.)
即使使用内核命令 SysRQ + R,我也无法恢复屏幕。我认为可能有什么东西坏了logind
或者gdm
:-)。
归档时间: |
|
查看次数: |
18525 次 |
最近记录: |