[Solved] ttys consoles and their peculiarities...if any

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
mazda1
Posts: 75
Joined: 2023-04-09 21:29
Has thanked: 10 times
Been thanked: 1 time

[Solved] ttys consoles and their peculiarities...if any

#1 Post by mazda1 »

Hello,

While preparing an upgrade, I read the relevant chapter in the Debian Wiki. Here's what it says:
Obtain a text shell.

On desktop machines, switch to console tty via Ctrl+Alt+F3 (the upgrade should be done on a text console, because your desktop environment could freeze during post-install/service restarts,
leaving the system in a broken state.)
Up to now, I've always used the terminal (tty7) to perform an upgrade, but from now on, I'll follow the Debian Wiki's recommendation. Nevertheless, I don't understand this: why tty3, why not tty1? or tty2...6?
Is there a particular use for each one? If so, where can I find information on these 6 consoles and their uses?
Last edited by mazda1 on 2025-01-11 04:29, edited 1 time in total.
Debian 12 / Xfce

lindi
Debian Developer
Debian Developer
Posts: 626
Joined: 2022-07-12 14:10
Has thanked: 2 times
Been thanked: 127 times

Re: Tty consoles and their peculiarities...if any

#2 Post by lindi »

Tty1 and tty2 are used for desktop in the default debian 12 installation with gnome.

mazda1
Posts: 75
Joined: 2023-04-09 21:29
Has thanked: 10 times
Been thanked: 1 time

Re: Tty consoles and their peculiarities...if any

#3 Post by mazda1 »

lindi wrote: 2025-01-10 12:47 Tty1 and tty2 are used for desktop in the default debian 12 installation with gnome.
Sorry, but that doesn't tell me much, so I'll rephrase my question: why would tty3 be better than tty1 or tty5, for example?

This is important to me because I had to use one of these consoles when the display manager failed, and I didn't know which one to choose, so I used the first on the list: tty1. But after reading the Debian Wiki commentary I think tty3 would have been a better choice: but why?
Debian 12 / Xfce

arzgi
Posts: 1713
Joined: 2008-02-21 17:03
Location: Finland
Has thanked: 1 time
Been thanked: 98 times

Re: Tty consoles and their peculiarities...if any

#4 Post by arzgi »

All the ttys are the same. 3 is usually the first free, I think that's why it was mentioned.
I use XFCE, and it reservers only one, in my case tty1.
I have in my profile

Code: Select all

[ "$(tty)" = "/dev/tty1" ] && exec startx
no need for lightdm or any login manager.

CwF
Global Moderator
Global Moderator
Posts: 3204
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 67 times
Been thanked: 282 times

Re: Tty consoles and their peculiarities...if any

#5 Post by CwF »

arzgi wrote: 2025-01-10 14:36 All the ttys are the same. 3 is usually the first free, I think that's why it was mentioned.
About right. tty1 is default w/o anything to say otherwise, tty2 is often used by a login manager, tty4 can be error post when there is no other, essentially the 2>&1 destination for the system. tty5 is like tty3, if there is a tty5 and 6 declared. tty7+ are usually a graphic terminal and used by a login manager.

This has been discussed before and I usually say a tty upgrade (w/ aptitude in my case) will be faster since there will be less iteration needed for running processes. Most mature DE's should be able to do any upgrade in the gui. I've used synaptic under Xfce for everything since ~10 and have done some 1000+ pkg upgrades without issue. Something with zero out of repo packages and sources will do so just fine.
Mottainai

Aki
Global Moderator
Global Moderator
Posts: 4190
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 123 times
Been thanked: 565 times

Re: Tty consoles and their peculiarities...if any

#6 Post by Aki »

Hello,

If you are in doubt, you can use the following command to check which virtual consoles are in use (and, consequently, which are unused and you could switch to them to open a terminal on them):

Code: Select all

$ ps ax | grep tty
In this example, a tty1 is running a bash shell, tty2 and tty3 are running a login prompt, tty7 is running the X server:

Code: Select all

$ ps ax | grep tty
    774 tty1     Ss     0:00 /bin/login -p --
    796 tty7     Rsl+   0:44 /usr/lib/xorg/Xorg :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
   8274 tty1     S+     0:00 -bash
   8455 tty2     Ss+    0:00 /sbin/agetty -o -p -- \u --noclear - linux
   9258 tty3     Ss+    0:00 /sbin/agetty -o -p -- \u --noclear - linux
   9339 pts/0    S+     0:00 grep tty
Hope this helps.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

mazda1
Posts: 75
Joined: 2023-04-09 21:29
Has thanked: 10 times
Been thanked: 1 time

Re: Tty consoles and their peculiarities...if any

#7 Post by mazda1 »

arzgi wrote: 2025-01-10 14:36 All the ttys are the same. 3 is usually the first free, I think that's why it was mentioned.
I use XFCE, and it reservers only one, in my case tty1.
I have in my profile

Code: Select all

[ "$(tty)" = "/dev/tty1" ] && exec startx
no need for lightdm or any login manager.
Hello,

As I don't need a D.M I first followed this topic: Auto login and `startx` without display manager (systemd), because of the “autologin” part: it didn't work, maybe I made a mistake. Then I tried your very simple method: it worked on the 1st try. Thank you for sharing your experience.

Has anything changed since 2015-07 that might explain why the autologin part of the first subject is no longer required for autologin to work?
Debian 12 / Xfce

CwF
Global Moderator
Global Moderator
Posts: 3204
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 67 times
Been thanked: 282 times

Re: [Solved] ttys consoles and their peculiarities...if any

#8 Post by CwF »

mazda1 wrote: 2025-01-14 14:16 Has anything changed since 2015-07
It does still work. There are some variations deeper into that original thread.

There are two parts, combine the two components for login-by-tty as I call it.

Systemd autogin uses the service units, and can be different user per tty.

Auto startx declared in ~/.profile works once the user logs in, if on the matching tty.

I only use autologin plus autostartx on tty1 for virtual machines that are never bare metal.

For bare metal I leave tty1 alone and use tty2 for the same user used in vms. That desktop, and user, is configured to be think its confined to a vm. The other tty's can be configured each for a different user. All can run simultaneously. I may manually use tty1, tty2 when the image is in maintenance, and you may be assigned 3, 5, or 6 if you were allowed to touch the computer! It's all adjustable for case. We can redefine tty's above 6 for more if we want to. Works well for kids or coworkers on a common computer in a trusted environment.

The method has survived all upgrades since stretch.
Mottainai

DebianFox
Posts: 199
Joined: 2024-05-05 14:11
Has thanked: 25 times
Been thanked: 15 times

Re: [Solved] ttys consoles and their peculiarities...if any

#9 Post by DebianFox »

@Best_Threads

Post Reply