LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   lock the console after 5 minutes of inactivity. (https://www.linuxquestions.org/questions/linux-newbie-8/lock-the-console-after-5-minutes-of-inactivity-832453/)

pinga123 09-16-2010 12:12 AM

lock the console after 5 minutes of inactivity.
 
How would i force The server console to be locked automatically after 5 minutes ?

I want it to happen for X as well as terminal session of the machine.

My Linux distribution details.


Code:

LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: OracleVMserver
Description:    Oracle VM server release 2.2.0
Release:        2.2.0
Codename:      n/a


prayag_pjs 09-16-2010 12:27 AM

In Fedora13,you can do it using GUI through System-->Preferences--->ScreenSaver---->Lock Screen After (5mins)....

let u know how to do change timimg from command promt

pinga123 09-16-2010 12:41 AM

Quote:

Originally Posted by prayag_pjs (Post 4099006)
In Fedora13,you can do it using GUI through System-->Preferences--->ScreenSaver---->Lock Screen After (5mins)....

let u know how to do change timimg from command promt

What can be done for linux system.
Server mentioned above dont have GUI console How can this be implemented for terminal sessions?

evo2 09-16-2010 12:46 AM

Have you looked at either "away" or "vlock"?

Cheers,

Evo2.

pinga123 09-16-2010 12:50 AM

Quote:

Originally Posted by evo2 (Post 4099017)
Have you looked at either "away" or "vlock"?

Cheers,

Evo2.

What are they ?
Both the commands not working on the servers.

EricTRA 09-16-2010 12:56 AM

Quote:

Originally Posted by pinga123 (Post 4099014)
What can be done for linux system.
Server mentioned above dont have GUI console How can this be implemented for terminal sessions?

Hi,

Without installing anything you can use the TMOUT variable (works in Korn and Bash, not sure for others). Just set in either profile or .bashrc:
Code:

export TMOUT=300
Logout and back in again. When inactive for 5 minutes your session will close.

Kind regards,

Eric

evo2 09-16-2010 01:08 AM

Hi,

Quote:

Originally Posted by pinga123 (Post 4099021)
What are they ?

Terminal locking programs like you asked for.

Quote:

Although,
Both the commands not working on the servers.
What error messages did you get?

... or do you mean they are not installed?

Evo2.

pinga123 09-16-2010 01:12 AM

Quote:

Originally Posted by EricTRA (Post 4099023)
Hi,

Without installing anything you can use the TMOUT variable (works in Korn and Bash, not sure for others). Just set in either profile or .bashrc:
Code:

export TMOUT=300
Logout and back in again. When inactive for 5 minutes your session will close.

Kind regards,

Eric

What difference will it make by saving in profile or .bashrc?

It seems i will have to manually do this for every user created on the system.
Will it work , if a default shell of user is not bash ?

pinga123 09-16-2010 01:18 AM

Quote:

Originally Posted by EricTRA (Post 4099023)
Hi,

Without installing anything you can use the TMOUT variable (works in Korn and Bash, not sure for others). Just set in either profile or .bashrc:
Code:

export TMOUT=300
Logout and back in again. When inactive for 5 minutes your session will close.

Kind regards,

Eric

What difference will it make by saving in profile or .bashrc?

It seems i will have to manually do this for every user created on the system.
Will it work , if a default shell of user is not bash ?

Can't it be done by analyzing output of w command.
I know i will have to write a script and scheduled it using crontab.
Is there any other alternative for the same.

Tinkster 09-16-2010 01:40 AM

Depending on the system in use you could just put
that time-out into a system wide file, e.g.:
/etc/profile


Something like
readonly TMOUT=300



That way users can't override it from their own
initialisation files.


Cheers,
Tink

EricTRA 09-16-2010 01:49 AM

Hi,

From the bash man page:
Quote:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands
from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that
order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is
started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the file ~/.bash_logout, if it exists.
So if you want to apply the TMOUT variable to all users on your server, you put it in profile. If you only want to apply it to specific users you put it in their .bashrc file.

As indicated I only know it works in Bash and Korn, you'll have to try for yourself if you use other shells.

Quote:

Can't it be done by analyzing output of w command.
I know i will have to write a script and scheduled it using crontab.
Is there any other alternative for the same.
I don't know what you mean by analywing output? What output do you want to analyze? To what are you referring with this statement?

What script do you think you have to write? One to activate the timeout? That's completely unnecessary because it's applied on EVERY login if you put it in the /etc/profile file, so no need for a script nor crontab reference.

Alternatives have been pointed out by evo2.

Kind regards,

Eric

EricTRA 09-16-2010 01:53 AM

Quote:

Originally Posted by Tinkster (Post 4099090)
Depending on the system in use you could just put
that time-out into a system wide file, e.g.:
/etc/profile


Something like
readonly TMOUT=300



That way users can't override it from their own
initialisation files.


Cheers,
Tink

Thanks for pointing that out Tink, forgot all about the readonly part :o

Kind regards,

Eric

pinga123 09-16-2010 02:05 AM

Thanks all for your helpful input.

This is what i m going to do.

1) edit /etc/profile file with readonly TMOUT=300 value.

This will ensure that every user get logout if they keep their terminal inactive for 5 minute.
This also ensures that they can't override the parameter as readonly option is used instead of simple export TMOUT=300.

Correct me if i m wrong.

EricTRA 09-16-2010 02:13 AM

Quote:

Originally Posted by pinga123 (Post 4099103)
Thanks all for your helpful input.

This is what i m going to do.

1) edit /etc/profile file with readonly TMOUT=300 value.

This will ensure that every user get logout if they keep their terminal inactive for 5 minute.
This also ensures that they can't override the parameter as readonly option is used instead of simple export TMOUT=300.

Correct me if i m wrong.

Hi,

Looks OK to me, but again, if you're using another shell than Bash or Korn, test it.

Kind regards,

Eric


All times are GMT -5. The time now is 02:53 PM.