LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   How do I automatically logout after a period of inactivity? (https://www.linuxquestions.org/questions/linux-security-4/how-do-i-automatically-logout-after-a-period-of-inactivity-271831/)

AshleyK 12-30-2004 05:07 AM

How do I automatically logout after a period of inactivity?
 
After a few years of being the only person using my RH8 & Gnome based workstation, I am now sharing it. I have gotten into the habit of not logging out (relying on the screen saver or simply locking the machine when I leave it.) Now I am sharing it and frustrating my partner who cannot logon to do her thing when I'm logged on :-(

Does anyone know of a utility or method by which I can have the machine logout of my account and back to the logon prompt after a period of inactivity preferably without pausing to tell me that certain windows do not support 'save setup'? Ideally I'd like the period of inactivity to be longer than that for the screen saver.

TIA
Ashley

masand 12-30-2004 06:42 AM

hi there

have a look at my project site

masand.sourceforge.net

i am currently on a project whcih deals something lke this

regards

xxx_anuj_xxx 12-30-2004 06:51 AM

automatically logout from the shell
 
"For automatically logout from the shell after a period of inactivity".
To do that, you must set the special variable of Linux named "TMOUT" to the time in seconds.
Edit your profile file "vi /etc/profile" and add the following line somewhere after the line that read
"HISTFILESIZE="
TMOUT=3600
The value we enter for the variable "TMOUT=" is in second and represent 1 hours (60 * 60 =
3600 seconds). If you put this line in your "/etc/profile" file, then the automatic logout after one hour of inactivity will apply for all users on the system. You can set this variable in user's individual ".bashrc " file to automatically logout them after a certain time.
After this parameter has been set on your system, you must logout and login again (as root) for the change to take effect.


There are few kool options also available if you want to make ur room partner feel like a hell.....

logout file

$HOME/.bash_logout
user-specific instruction file, found in each user's home directory. Upon exit from a login (Bash) shell, the commands in this file execute.
"think what command you want to give lol:p.


cheers

AshleyK 12-31-2004 05:06 AM

Thanks, I tried your suggestion and entered following into /etc/profile:

HISTSIZE=1000
TMOUT=1800

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC TMOUT

Note, I added TMOUT to the export line as well. I've logged on and off as root and back again as my normal user nad it does not auto logout. Do I need to reboot?

Regards
Ashley

xxx_anuj_xxx 12-31-2004 10:47 PM

Greetings and happy new year to you and everyone else!

Edit your $HOME/.bashrc file
it looks like:-

# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

_________________________


now:-


# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
TMOUT=100

#this will cause ur shell to automatically logout after an inactivity of 100 seconds,
________________________________________

HISTSIZE
Bash's history saves several hundred of your most recent commands in a file, by default called .bash_history. You can change the size of this by setting HISTSIZE to whatever you need.


Logout or reboot ur machine, it will work!:)

cheers


All times are GMT -5. The time now is 11:05 PM.