LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-16-2010, 12:12 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 37
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

Last edited by pinga123; 09-16-2010 at 12:27 AM.
 
Old 09-16-2010, 12:27 AM   #2
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: RHEL/Ubuntu/Debian/Fedora/Centos/K3OS
Posts: 1,159
Blog Entries: 4

Rep: Reputation: 149Reputation: 149
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
 
Old 09-16-2010, 12:41 AM   #3
pinga123
Member
 
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by prayag_pjs View Post
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?
 
Old 09-16-2010, 12:46 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Have you looked at either "away" or "vlock"?

Cheers,

Evo2.
 
Old 09-16-2010, 12:50 AM   #5
pinga123
Member
 
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by evo2 View Post
Have you looked at either "away" or "vlock"?

Cheers,

Evo2.
What are they ?
Both the commands not working on the servers.
 
Old 09-16-2010, 12:56 AM   #6
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by pinga123 View Post
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
 
1 members found this post helpful.
Old 09-16-2010, 01:08 AM   #7
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

Quote:
Originally Posted by pinga123 View Post
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.
 
Old 09-16-2010, 01:12 AM   #8
pinga123
Member
 
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by EricTRA View Post
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 ?
 
Old 09-16-2010, 01:18 AM   #9
pinga123
Member
 
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by EricTRA View Post
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.

Last edited by pinga123; 09-16-2010 at 01:33 AM.
 
Old 09-16-2010, 01:40 AM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
1 members found this post helpful.
Old 09-16-2010, 01:49 AM   #11
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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
 
Old 09-16-2010, 01:53 AM   #12
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by Tinkster View Post
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

Kind regards,

Eric
 
Old 09-16-2010, 02:05 AM   #13
pinga123
Member
 
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
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.
 
Old 09-16-2010, 02:13 AM   #14
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by pinga123 View Post
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Console/X Lock. SticklerThe1st Linux - Hardware 4 07-05-2010 10:50 AM
Wireless network goes comatose after fifteen minutes of inactivity. pappy_mcfae Linux - Wireless Networking 4 07-29-2007 04:58 AM
Centos - console hangs after inactivity period yuri_d Red Hat 3 09-15-2006 07:52 PM
Failed to lock file /var/spool/cron/root after 5 minutes teeno Linux - Software 0 09-24-2003 02:49 AM
Lock console? KaktusKnight Linux - General 30 12-20-2002 03:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration