在实际生产出现问题,获得机器ip并ssh登陆以后,常常需要知道获得前端显示器(tty1)打印信息。用以获取具体报错内容,从而做针对性调试
/dev/vcs
and /dev/vcsa
[root@WorkFromHome ~]# man vcs
vcs, vcsa - virtual console memory
......
/dev/vcs0 is a character device with major number 7 and minor number 0, usually of mode 0644 and owner root.tty.
It refers to the memory of the currently displayed virtual console terminal.
/dev/vcs[1-63] are character devices for virtual console terminals, they have major number 7 and minor number 1 to
63, usually mode 0644 and owner root.tty. /dev/vcsa[0-63] are the same, but using unsigned shorts (in host byte
order) that include attributes, and prefixed with four bytes giving the screen dimensions and cursor position: lines,
columns, x, y. (x = y = 0 at the top left corner of the screen.)
......
the /dev/vcs devices each correspond to the /dev/tty devices with the same number. 即,/dev/ttyN 对应vcs设备是 /dev/vcsN In essence, they're the scrollback buffers for the virtual terminals represented by the /dev/tty devices. There's very little in userspace that actually cares about or uses these device nodes, and about the only things they're used for are getting screen dumps of virtual consoles or recording the behavior of console programs. Your terminal emulators aren't showing up in any of them because terminal emulators use pseudoterminals, not virtual consoles. 即,虚拟终端pty(pseudo-tty)没有对应的vcs设备
注:setterm
利用/dev/vcsa*
获取对应对应终端打印
[root@WorkFromHome ~]# setterm -dump #获取tty1屏幕输出到 screen.dump
[root@WorkFromHome ~]# setterm -append 2 #获取tty1屏幕输出追加到 screen.dump
[root@WorkFromHome ~]# setterm -append 2 #获取tty2屏幕输出追加到 screen.dump
[root@WorkFromHome ~]# setterm -append 3 -file screen3.dump #获取tty3屏幕输出追加到 screen3.dump
setterm
[root@WorkFromHome ~]# man setterm
setterm - set terminal attributes
......
-dump [1-NR_CONS]
Writes a snapshot of the given virtual console (with attributes) to the file specified in the -file option,
overwriting its contents; the default is screen.dump.
Without an argument, dumps the current virtual console. Overrides -append.
-append [1-NR_CONS]
Like -dump, but appends to the snapshot file instead of overwriting it. Only works if no -dump options are
given.
......
注:cat /dev/vcs1
无换行符,直接输出会导致输出不直观,可通过stty
获取对应终端宽度,然后使用fold
格式化输出
[root@WorkFromHome tmp]# stty -a -F /dev/tty1 #获取 tty1 终端columns属性
speed 38400 baud; rows 54; columns 144; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = <undef>;
flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff -iuclc -ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
[root@WorkFromHome tmp]# fold -w 144 /dev/vcs1 #获取 tty1 终端输出,并加入换行
CentOS Linux 7 (Core)
Kernel 3.10.0-957.el7.x86_64 on an x86_64
WorkFromHome login: root (automatic login)
Last login: Fri Jun 5 22:43:09 from 10.67.18.173
[root@WorkFromHome ~]#
fold
and stty
[root@WorkFromHome ~]# man stty
stty - change and print terminal line settings
......
-a, --all
print all current settings in human-readable form
-g, --save
print all current settings in a stty-readable form
-F, --file=DEVICE
open and use the specified DEVICE instead of stdin
......
[root@WorkFromHome ~]# man fold
fold - wrap each input line to fit in specified width
......
-w, --width=WIDTH
use WIDTH columns instead of 80
......
https://unix.stackexchange.com/questions/485239/what-is-dev-vcs-on-linux vcs(4) - Linux man page(https://linux.die.net/man/4/vcs)
本文分享自 WriteSimpleDemo 微信公众号,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文参与 腾讯云自媒体同步曝光计划 ,欢迎热爱写作的你一起参与!