Automatically sign out root account

I typically walk away from my computer and get side tracked doing something else. I have more then once came back just to see a terminal window open still signed in as root. To make matters worse I use a plasma widget called plasmacon that embeds a terminal window in to my desktop. There is a very easy solution to this problem.

In the root home directory (/root/) create a file called (.bashrc) and enter the following line in to that file.


N = The number of seconds to wait before timing out the account.

Now when you walk away from your computer with the root account signed in it will automatically log out after the number of seconds you chose. This can also be used for other users as well. Just do the same procedure in the home directory of the user you would like to automatically be signed out. This will only work on bash sessions, it will not sign you out of an X session.

Edit: 2/11/2012

One good point that I left out is if you set this timeout to low you might leave the root account inaccessible. The way to fix this if it happens is with this command.

With nano:

su root -c 'nano ~/.bashrc'

With VI:

su root -c 'vi ~/.bashrc'

This will allow you to edit the .bashrc file without login in to the root account.


Add comment

Comments do not require an account. Anyone is welcome and encouraged to leave a comment.

However, If you are a spammer all comments require admin approval so your wasting your time and mine.
No one will ever see it. Please stop posting spam.


Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.