Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.