M
M
Maxim2019-06-17 04:55:33
linux
Maxim, 2019-06-17 04:55:33

Why doesn't ALT-CTRL-Fx work?

Hello.
Linux CentOS 7
I go to the console via SSH via Putty. I want to switch to TTY2 for example. I press CTRL + ALT + F2, but in the console only [12 ~
Or
Under a simple user, I enter chvt 2:

[[email protected] ~]$ chvt 2
Couldn't get a file descriptor referring to the console

If under root, then the command is executed and that's it
[[email protected] user]# chvt 2
[[email protected] user]#

What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
J
jcmvbkbc, 2019-06-17
@MaxRAF

I go to the console via SSH through Putty. I want to switch to TTY2 for example. I press CTRL+ALT+F2, but the console only shows [12~
What am I doing wrong?

ctrl-alt-f2 is the keyboard shortcut for the virtual terminal driver. Accordingly, it only works when entered through a virtual terminal.
Under a simple user, I enter chvt 2:
If under root, then the command is executed and that's it.
What am I doing wrong?

Are you typing in the graphical console? With strace, it's easy to understand what's going on:
from a simple user:
$ strace -iv chvt 2
...
[00007f96b99d56f0] open("/proc/self/fd/0", O_RDWR) = 3
[00007f96b99da80a] ioctl(3, TCGETS, {c_iflags=0x5500, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
[00007f96b99db017] ioctl(3, KDGKBTYPE, 0x7fff06db6d67) = -1 ENOTTY (Inappropriate ioctl for device)
[00007f96b99d5f30] close(3)             = 0
[00007f96b99d56f0] open("/dev/tty", O_RDWR) = 3
[00007f96b99da80a] ioctl(3, TCGETS, {c_iflags=0x5500, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
[00007f96b99db017] ioctl(3, KDGKBTYPE, 0x7fff06db6d67) = -1 ENOTTY (Inappropriate ioctl for device)
[00007f96b99d5f30] close(3)             = 0
[00007f96b99d56f0] open("/dev/tty0", O_RDWR) = -1 EACCES (Permission denied)
...

Those. stdin and /dev/tty don't support ioctl switching terminal (or rather, it doesn't even reach it) because your console is a pseudo-terminal and you don't have enough privileges to open /dev/tty0.
And from root:
$ sudo strace chvt 2
...
[00007f591848c6f0] open("/proc/self/fd/0", O_RDWR) = 3
[00007f591849180a] ioctl(3, TCGETS, {c_iflags=0x5500, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
[00007f5918492017] ioctl(3, KDGKBTYPE, 0x7fffe5e72d17) = -1 ENOTTY (Inappropriate ioctl for device)
[00007f591848cf30] close(3)             = 0
[00007f591848c6f0] open("/dev/tty", O_RDWR) = 3
[00007f591849180a] ioctl(3, TCGETS, {c_iflags=0x5500, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
[00007f5918492017] ioctl(3, KDGKBTYPE, 0x7fffe5e72d17) = -1 ENOTTY (Inappropriate ioctl for device)
[00007f591848cf30] close(3)             = 0
[00007f591848c6f0] open("/dev/tty0", O_RDWR) = 3
[00007f591849180a] ioctl(3, TCGETS, {c_iflags=0x5, c_oflags=0, c_cflags=0xbf, c_lflags=0, c_line=0, c_cc[VMIN]=1, c_cc[VTIME]=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
[00007f5918492017] ioctl(3, KDGKBTYPE, 0x7fffe5e72d17) = 0
[00007f5918492017] ioctl(3, VT_ACTIVATE, 0x2) = 0
[00007f5918492017] ioctl(3, VT_WAITACTIVE, 0x2) = 0
...

Those. stdin and /dev/tty are the same, but /dev/tty0 is opened and ioctl VT_ACTIVATE passes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question