A typical Linux system has a fixed number of virtual terminals/consoles (VCs), which are assigned devices /dev/tty1
, /dev/tty2
, etc. These are used for console login shells and can be accessed using the keystrokes Ctrl-Alt-F1, Ctrl-Alt-F2, etc.
In addition there are pseudo terminals (PTYs), which have names like /dev/pts/19
. These are used for terminal emulators like Xterm, for SSH sessions, Screen windows, and so on.
You can find out which kind your shell is running on like this:
$ echo $TTY
/dev/pts/19
For reasons I'm not very clear about, full-screen graphics software like Xorg needs to be associated with a virtual console. Since X can't run unless it has permissions to write to the VC device (e.g. /dev/tty7
), it probably starts by opening this device and using it to send certain requests to the kernel. I imagine that these requests would not be understood by a PTY device.
Below, you can see the permissions of two VC devices. In the first one, /dev/tty1
, I'm logged in as myusername
and you can see that the program which logged me in has changed the device to be owned by me. The second line, /dev/tty2
, is owned by root
because it is still showing the login prompt:
$ ls -al /dev/tty{1,2}
crw------- 1 myusername tty 4, 1 Dec 9 05:47 /dev/tty1
crw--w---- 1 root tty 4, 2 Dec 9 05:11 /dev/tty2
If you would like to run startx
on a specified VC, but you don't have access to it directly (for example if you are logged in via SSH, or talking to a Screen window), then you can use systemd-run
as described here. That method requires sudo
privileges, but in the end you'll be running startx
as a normal user as if you had logged in to the specified VC.
ssh
is not involved. I am running Slackware on my laptop.