How to access different tty session

Posted on

Problem :

I wanted to know if there is any possibility of login to other tty sessions. Someone has mistakenly changed the root su password. One of the session is already logged in as root. So any possibility for me to login to that session and change root password. My OS is RHEL 6

Thanks

Solution :

In BSD, you can use watch which snoops a given tty, e.g.

watch /dev/pts/0

-W Allow write access to observed tty.

However in Linux, watch command is different, and it won’t be possible if the process wasn’t run under multiplexer before such as screen or tmux. See also: Reptyr: Attach a Running Process to a New Terminal

It seems the only way is to debug the process (e.g. strace, dtrace/dtruss, gdb, lldb, etc.).

See also: How to view the output of a running process in another bash session?

If the root password has been changed, I really recommend you to investigate who and why. Perhaps there is a malware installed or the system has been hijacked. Then, I suggest to boot from a CD or USB stick like SystemRescueCD, where you can change the root password.

Leave a Reply

Your email address will not be published. Required fields are marked *