Linux Terminal: How to Capture or Watch Other Terminal Session

Linux Terminal: how to capture or watch other terminal session

If the other person is using the Linux console, you can use conspy.

Dump terminal session to file?

If you want the whole contents of the terminal history:

In the gnome-terminal menu, Edit > Select All and then Edit > Copy. (Or use your favorite keyboard shortcut for the copy.)

Then paste anywhere.

If you want just part of the history, select with your mouse and then copy.

Where is linux terminal's session history stored?

Add these lines to your ~/.bashrc, and every single command from any session gets written to ~/.bash_history.

shopt -s histappend
export PROMPT_COMMAND='history -a'

... also saves you from sessions overwriting each others history.

Record actions on a terminal

Firstly, I'm assuming that with "actions that a user performs on a terminal" you mean keyboard input. This then matches the output which you also want to capture. This does not include e.g. the removal of a file when the user runs rm!

Now, there is a misconception showing in your question. The terminal only provides input (from keyboard) and output (to the display). The input (apart from things it interprets itself) is then forwarded to a program, often a shell like e.g. zsh or fish while output from that program is forwarded to the display. This happens via the three standard streams stdin, stdout and stderr. What you basically need is a program that sits in between the terminal and the shell. This program marshals data between the terminal and the shell and at the same time records that data (or at least the output) to a file. This is e.g. what script does.

Note that your requirement that SSH sessions are recorded is fulfilled as well. In the normal SSH session, the above chain with two elements (terminal, shell) is extended with the SSH client and remotely with an according SSH server process and another program (usually another shell). When you execute echo foo on the remote machine, the shell there outputs it to the SSH server process which then passes it to the SSH client, the local shell and finally the terminal for display. Input into the terminal takes the opposite path.



Related Topics



Leave a reply



Submit