大网数据广告活动
服务器运维问答

How to start headless X upon boot for non-root users in Debian

· 52CE 我爱测

My requirement is a little different from this one in that I would like to launch a window manager for each of two non-root users upon boot. For testing, first I prepare the following lines in .xinitrc and/or .xsession in home di…

问题原文

原帖链接 · Masa O · CC BY-SA 3.0

My requirement is a little different from this one in that I would like to launch a window manager for each of two non-root users upon boot.

For testing, first I prepare the following lines in .xinitrc and/or .xsession in home directories of user2 and user3 like so:

#!/bin/sh
exec icewm

Then I manually login to virtual console as user2 or user3 or open an xterm window and type this command:

xinit -- /usr/bin/Xvfb :3 -cc 4 -screen 0 1024x768x16

This does the job - icewm and Xvfb run behind the scene.

Now I want to automate the login and command xinit on boot. However none of the following approaches work:

Either manually type these two commands as root or place them in /etc/rc.local:

su -l user2 -c xinit -- /usr/bin/Xvfb :3 -cc 4 -screen 0 1024x768x16

No protocol specified
IceWM: Can't open display: :0. X must be running and $DISPLAY set.

start-stop-daemon --start -u user2 -g user2 -b --pidfile /tmp/pid --exec /usr/bin/xinit -- -- Xvfb :3
ps ax

[Xorg] <defunct>

Helps will be greatly appreciated!

[Edit after testing alex.d.'s approach]

File /home/user2/.xsession:

#!/bin/bash
export DISPLAY=localhost:3
export XAUTHORITY=$HOME/.Xauthority
exec icewm

Issue this command as root:

su -l user2 -c /usr/bin/startx -- /usr/bin/Xvfb :3 &

I get this:

hostname: Name or service not known
xauth: (stdin):1:  bad display name "example.com:2" in "add" command

IceWM: Can't open display: localhost:3. X must be running and $DISPLAY set.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
xauth: (argv):1:  bad display name "example.com:2" in "remove" command

Any idea? Please!

已采纳解答

原帖链接 · Masa O · CC BY-SA 3.0

This is my working approach.

file /etc/systemd/system/john.service:

[Unit]
Description=xinit - user "john"

[Service]
User=john
Group=john
ExecStart=/usr/bin/xinit openbox-session -- /usr/bin/Xvfb :1 -nolisten tcp
ExecStopPost=/usr/bin/killall -u john

[Install]
WantedBy=multi-user.target

file /home/john/.config/openbox/autostart:

wine my_program.exe

Thank you all for the helps!

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-05-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。