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

DEBIAN: Show a logfile on TTY1 as default display on physical computer

· 52CE 我爱测

OK lets admit you connect a display to a computer that runs linux. The display will show a login screen asking for user and password. I am logged in via SSH on pts/0 I can now run a program on TTY1 like this some-program > /dev/t…

问题原文

原帖链接 · Max Muster · CC BY-SA 4.0

OK lets admit you connect a display to a computer that runs linux.
The display will show a login screen asking for user and password.
I am logged in via SSH on pts/0

I can now run a program on TTY1 like this

some-program > /dev/tty1 2>&1

But what I am looking for is a possibility to just show my console to tty1 without the user to be able to interfere. I tried:

screen > /dev/tty1 2>&1

but it opened the screen on pts/1 instead ot tty1. I tried

top > /dev/tty1 2>&1

result was a dark screen any hint?

已采纳解答

原帖链接 · A.B · CC BY-SA 4.0

The openvt command, present in the kbd package on Debian, deals specifically with using VTs.

For example you can run top on /dev/tty8 with:

openvt -c 8 -- top

It takes care itself of preparing the correct detached environment for the forked command (redirecting I/Os to the VT, calling setsid(2) etc.) and returns immediately.

I avoided /dev/tty1 in this example because very often first /dev/ttyX are already used to spawn login prompts.

Use chvt (eg chvt 8) if you have to change the VT to be displayed.

You can also choose to not specify the VT and let openvt pick the first available, and immediately switch to it using -s, So this would work in one shot:

openvt -s -- top

Be careful to not leave older instances running then...

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

资料来源与适用范围

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

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

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