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
Convert a Time Span in Seconds to Formatted Time in Shell
Bluetooth Low Energy in C - Using Bluez to Create a Gatt Server
Determine Tsc Frequency on Linux
Linking Boost Library in Linux
Arm Linux Atags VS Device Tree
Error: Ld.So: Object 'Libgtk3-Nocsd.So.0' from Ld_Preload Cannot Be Preloaded
How to Check If Find Command Didn't Find Anything
Compressing the Core Files During Core Generation
Extract Date from a File Name in Unix Using Shell Scripting
Stack Resident Buffer Overflow on 64-Bit
How to Make Awk Use the Variable Created in Bash Script
X86_64 Linux Syscall Arguments
Apache Pig: Load a File That Shows Fine Using Hadoop Fs -Text
Which Perf Events Can Use Pebs
Extract List of File Names in a Zip Archive When 'Unzip -L'
Get the Characters After the Last Index of a Substring from a String