1

On Ubuntu, /dev/tty7 is the virtual console for desktop GUI.

Is the only way to access /dev/tty7 to use chvt 7 or Ctrl+Alt+F7?

Besides that, is /dev/tty7 not directly accessible to Ubuntu users, but indirectly via other emulations of terminals built upon /dev/tty7? For example, typing this in a xterm window doesn't give any output:

echo hello > /dev/tty7

but this will

echo hee > /dev/pts/n
  • 1
    You don't usually see the text terminal on tty7 since it has a display server running. If you kill the display server you should see an output. – Torin Nov 30 '18 at 13:54
  • Since 17.10 (?) tty1 is a login screen, tty2 is the desktop GUI and 3-6 are text consoles. Don't know what tty7 is for. Previously 1-6 were text and 7 was the GUI. – PerlDuck Nov 30 '18 at 13:57
  • Why would emulated terminals be “built upon /dev/tty7”? – Stephen Kitt Nov 30 '18 at 13:59
  • @StephenKitt look at how /dev/pts/2 is built upon /dev/tty7 in "the chain of interaction" at unix.stackexchange.com/a/229598/674. I am not sure what you think is correct. – Tim Nov 30 '18 at 14:05
  • 1
    X doesn’t communicate with a text terminal, but yes, I mean X doesn’t interact with the user via /dev/tty7 (or any other terminal device) but by managing the input and output devices directly. – Stephen Kitt Nov 30 '18 at 14:55
0

In Ubuntu releases before 17.10 Ubuntu has 6 virtual consoles tty1-tty6 which are accessed by the keyboard combinations Ctrl+Alt+F1 to Ctrl+Alt+F6. To access the GUI from any virtual console press the keyboard combination Ctrl+Alt+F7.

Starting with Ubuntu 17.10, which allowed the user to select either Xorg or Wayland when logging in, the virtual consoles are accessed by the keyboard combinations Ctrl+Alt+F3 to Ctrl+Alt+F6. To access the GUI from any virtual console press the keyboard combination Ctrl+Alt+F2.

/dev/tty is the controlling tty of the current process, for any process that actually opens this special file. It isn't necessarily a virtual console. For example running the command echo hello > /dev/tty in the terminal returns hello, but running sudo echo hello > /dev/tty0 to sudo echo hello > /dev/tty7 returns an error message similar to bash: /dev/tty0: Permission denied

getty, short for "get tty", is a Unix program running on a host computer that manages physical or virtual terminals (TTYs). When it detects a connection, it prompts for a username and runs the 'login' program to authenticate the user.Wikipedia  On most Debian systems tty7 is used by the X Window System, so if you want to add more getty's go ahead, but skip tty7 if you run X.

  • 1
    I think the reason sudo echo hello > /dev/tty0 fails is not what you think it is. Also, Debian 9 and later behave like Ubuntu, with the login session on VC 1, and GUIs on VCs 2 and up. – Stephen Kitt Nov 30 '18 at 16:22
  • I remember to run echo hello > /dev/tty0, you have to first sudo su. sudo isn't enough, although I don't know why and also want to know why. – Tim Nov 30 '18 at 16:27
  • 1
    See this unix.stackexchange.com/a/60649/674 "Login as root" – Tim Nov 30 '18 at 16:38
  • Just sudo isn't enough because the redirection is done by the shell before starting sudo, so it's done with the user's permissions only. – stolenmoment Dec 1 '18 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.