Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Automatically close idle root terminals

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
Hallvor
Global Moderator
Global Moderator
Posts: 2042
Joined: 2009-04-16 18:35
Location: Kristiansand, Norway
Has thanked: 149 times
Been thanked: 212 times

Automatically close idle root terminals

#1 Post by Hallvor »

Keeping your root terminal open when other people have physical access to your computer, makes your computer as secure as your normal user account. And if a remote attacker gains access to your normal user account, they also get access to your (in theory) open root terminal. Turning the root terminal off when not in use is basic security practice.

If you still keep forgetting to log out, it can be done automatically. These commands will make the root terminal log out automatically after a given number of seconds:

As root:

Code: Select all

# echo "[ $USER = root ] && export TMOUT=300" >> /etc/profile
As you can see, the time limit is five minutes (300 seconds). Replace 300 with whatever number of seconds you want.

Load the new settings:

Code: Select all

# source /etc/profile
Your open root terminals will now automatically log off as root within the given number of seconds.


Credits: http://linuxg.net/quick-tip-automatical ... nactivity/
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Automatically close idle root terminals

#2 Post by dasein »

Very cool. :cool:

Thanks, Hallvor .

josephg
Posts: 82
Joined: 2009-01-03 14:01
Location: surrey england

Re: Automatically close idle root terminals

#3 Post by josephg »

you ask to change /etc/profile. i have a /root/.profile too. which one?

User avatar
Hallvor
Global Moderator
Global Moderator
Posts: 2042
Joined: 2009-04-16 18:35
Location: Kristiansand, Norway
Has thanked: 149 times
Been thanked: 212 times

Re: Automatically close idle root terminals

#4 Post by Hallvor »

josephg wrote:you ask to change /etc/profile. i have a /root/.profile too. which one?
/etc/profile is for system wide shell variables. It is the file you should edit.
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD

josephg
Posts: 82
Joined: 2009-01-03 14:01
Location: surrey england

Re: Automatically close idle root terminals

#5 Post by josephg »

Hallvor wrote:
josephg wrote:you ask to change /etc/profile. i have a /root/.profile too. which one?
/etc/profile is for system wide shell variables. It is the file you should edit.
if this is only for the root user, why should we change system wide settings for all users? thanks

Post Reply