I connected to Linux (in the case here, I used Ubuntu 1604) by serial console.

Now, the serial console is closed (terminated), but, when I connect back to the serial port again I saw all the sessions are left there.

How can I configure Linux to detect my serial console is terminated and logout me automatically?

I expect the application which monitor the serial port should send SIGHUP to bash or someone else and kill/stop all processes and close my session.



1 Answer 1


You are not guaranteed to have means to figure out whether the serial console is in use or not.

Because of that, your next-closest answer is to use your shells builtin features to auto logout when the shell is not in use (based on inactivity).

$ export TMOUT=600

On most system that means you want to edit your .bashrc and add that line there.

That would logoff serial console users if they stay idle for more than 600 seconds (10 minutes) - likely the case when they unplug their serial console - but not preventing unauthorized access should someone else plugin theirs meanwhile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.