Open In App

Auto Logout in Linux Shell Using TMOUT Shell Variable

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

TMOUT is a Linux-Unix shell variable that provides the user security for their login session in the system. It provides the “Auto Logout Functionality” for the login shell in case of no activity for a specified time.

Generally when the user leaves the Linux system idle (situation when a user doesn’t perform any administrative task by running a command or using GUI ( Graphical User Interface )) after the login as a root privilege, that time if anyone got physical access to the system via malicious attack that he has the full power as you and can execute any script that causes you a great loss. 

So, It is a good idea to have the feature like auto-logout after a definite idle time.

All process is given the following stepwise and to follow the process run the following commands.

Step 1: Enable this globally (system-wide for all users), set the TMOUT variable in the /etc/profile shell initialization file.

$ sudo nano /etc/profile 

TMOUT Auto Logout Linux Shell When There Isn’t Any Activity

Step 2: insert the given line 

TMOUT=300 

Note: Here 300 representing 300 seconds or 5 minutes.

TMOUT Auto Logout Linux Shell When There Isn’t Any Activity

Step 3: save and exit

Press Ctrl+x followed by "Y"

TMOUT Auto Logout Linux Shell When There Isn’t Any Activity

From now the user will automatically log out from the login session if there is no activity for a specific time (here that time is 5 minutes (300 seconds)).

 

Last Updated : 07 Mar, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads