Ubuntu – TTY[1-6]: Lock screen after delay (like a screensaver)

command lineconsoletty

When using the virtual terminals on TTY 1-6 [*], it's sometimes easy to forget to log out: The screen goes blank after a while, but I'm still logged in – no password required, anyone can use my account. (Or I switch to another TTY, and forget the other one…)

I'd like to have screensaver-like functionality that locks the terminal after 3 minutes, and then requires a password. How do I set this up?

[*] With TTY 1-6, I mean CTRLALTF1CTRLALTF6 (no X Server)

Best Answer

I know this is old, but I found you on google searching for the same question.

If you’re using bash, it’s no problem. Just use the environment-variable 'TMOUT' which is used by bash for a auto-logout (logout! not lock) in the given seconds.

You can just type ''TMOUT=5'' into any bash an see, what happens.

For configuration in my bashrc I’m using

# autologout on tty1-6 after 30 minutes
if [[ $(tty) =~ /dev\/tty[1-6] ]]; then TMOUT=1800; fi

so I don’t get logged out on a terminal-emulator which is normally on /dev/pty/# and already get locked by my screensaver as part of my desktop

Related Question