Page 1 of 1

help me understand tty numbers

Posted: Sun Nov 06, 2011 5:47 am
by StewArt
What controls what number the graphical system will be on? I was working along and it was on F7, then I went to go back to it and it was F9.

Also, do the 1-6 ttys ever log you out after x minutes of inactivity? Is that something that can be set?

Re: help me understand tty numbers

Posted: Sun Nov 06, 2011 8:20 am
by proxima_centauri
StewArt wrote:do the 1-6 ttys ever log you out after x minutes of inactivity? Is that something that can be set?
No, they should not log you out after any minutes of inactivity.

I won't comment on MInt's TTY levels as I am not running it.

Re: help me understand tty numbers

Posted: Sun Nov 06, 2011 8:59 am
by Anakinholland
StewArt wrote:What controls what number the graphical system will be on? I was working along and it was on F7, then I went to go back to it and it was F9.
Very odd, no explanation for that. Should not be so unless something manually was changed.
StewArt wrote:Also, do the 1-6 ttys ever log you out after x minutes of inactivity? Is that something that can be set?
Not by default, but yes it can be changed, source.

If you want to do it per user, create a file ".bashrc" in that users home-directory.
If you want to do it system-wide, edit the file "/etc/bash.bashrc".

Code: Select all

TMOUT=300
readonly TMOUT
export TMOUT
first line will set the variable, second line will render it so users cannot alter it in their session, the third line will render it so it will be persistent in recursive shells.

The second line is only useful if you do it system-wide, or if you change access-rights to the file in the home-directory. Otherwise the user can just edit the file and remove it.
The third line is there because when you do no use it, a user can just log in, type "bash --norc" (this bypasses the bash.bashrc and ~/.bashrc) to get a child-process where the variable TMOUT isn't "active" anymore, and have infinite time again.

Cheers,

Anakin

Re: help me understand tty numbers

Posted: Wed Nov 09, 2011 1:08 pm
by StewArt
Anakin, thanks for the great info on TMOUT. I learned a lot about variables and other features of the shell by playing around with that. One thing I noticed is that when it automatically logs me out of (for example) tty#2 while I'm doing something in the graphical one, it interrupts the screen briefly and shows me tty#1, then goes back to what I was doing. Is that expected behavior? (I tried it again today, and it's faster - flashes so fast you can't read anything, but still there.)

I've also noticed that if I've just Ctrl+Alt+F7'ed to go back to graphical, and I immediately press Ctrl+Alt+F# to go back to the same or to another text tty, it'll reject the keystroke. The screen flashes when I hit Ctrl+Alt+F#, but it stays in the graphical. Is there an explanation for this?
Should not be so unless something manually was changed.
No, I didn't manually change anything. It's back to F7 right now, but it was F7, F9, and F8 all in one day without changing a thing.

Re: help me understand tty numbers

Posted: Wed Nov 09, 2011 1:28 pm
by Anakinholland
StewArt wrote:Anakin, thanks for the great info on TMOUT. I learned a lot about variables and other features of the shell by playing around with that. One thing I noticed is that when it automatically logs me out of (for example) tty#2 while I'm doing something in the graphical one, it interrupts the screen briefly and shows me tty#1, then goes back to what I was doing. Is that expected behavior? (I tried it again today, and it's faster - flashes so fast you can't read anything, but still there.)
You're very welcome, and I am really glad I didn't type it all for naught :)

I have not experienced that myself, but there could be numerous reasons for that. Thinking about different hardware, different window manager maybe, and the fact that I hardly ever use TTY for my command line, I work mostly in Terminal inside graphical session.

That being said, the reason that this happens is probably the fact that a log off is not only that. A log off basically is a kill of that TTY-process. As the TTY-process is started at boot with a parameter called "respawn", it will also automatically start again when killed. That restart is probably the "flash" you see, as it needs to connect to X/graphics again?
StewArt wrote:I've also noticed that if I've just Ctrl+Alt+F7'ed to go back to graphical, and I immediately press Ctrl+Alt+F# to go back to the same or to another text tty, it'll reject the keystroke. The screen flashes when I hit Ctrl+Alt+F#, but it stays in the graphical. Is there an explanation for this?
I think that has to do with the Xserver, the process that actually registers all Input/Output. On this laptop, when switching from TTY2 to graphics (RHEL uses Ctrl+Alt+F1 for that), I cannot switch away from graphics until I release Ctrl+Alt and press them again. It just does not registers the keypress.
StewArt wrote:
Should not be so unless something manually was changed.
No, I didn't manually change anything. It's back to F7 right now, but it was F7, F9, and F8 all in one day without changing a thing.
Odd, I really have not idea how that could happen.

Regards,

Anakin

Re: help me understand tty numbers

Posted: Thu Nov 10, 2011 4:47 am
by randomizer
The only time I've seen X running on a different tty is if I explicitly start it from another tty.

Re: help me understand tty numbers

Posted: Tue Nov 15, 2011 11:48 pm
by StewArt
Okay, I don't know exactly what caused previous times, but I've found one way that I can reproduce the graphical tty switching from Ctrl+Alt+F7 to Ctrl+Alt+F8.
Step 1: Open Nautilus, and pick some folder (e.g. /usr/). Right-click it and select "Open as administrator". Enter your password when prompted.
Step 2: Close all your windows and attempt to shutdown.
You will be presented with the following prompt:
System policy prevents stopping the system when other users are logged in
An application is attempting to perform an action that requires privileges. Authentication is required to perform this action.
Password: ___________________
Details
Action: org.freedesktop.consolekit.system.stop-multiple-users
Vendor:
[Cancel]..........[Authenticate]
If I click "Cancel", it will bring me to a log-in screen. It is after pressing Cancel that the graphical display is now on F8 instead of F7.

Re: help me understand tty numbers

Posted: Wed Nov 16, 2011 2:02 am
by StewArt
^^ It's simpler than that.
Okay, while what I just wrote above is an interesting quirk that should probably be fixed, the number switching is much easier for me to reproduce.
Start the machine: X is on F7.
Log out: X is on F8.
Log in and out again: X is on F9.
I think it goes back and forth between F8 and F9 then, but doesn't go to F7 until a restart.

Can you confirm whether or not this is standard behavior? If so, why? If not, why me?