In git, as long as you have a hash code, you have everything. At any time, You can reset it to any historical state you want, no matter when the history is, maybe it's history relative to the current location, or maybe it's the future, you can all go, so you 'd better write your hash code on paper, which is the safest way.
For this reason, I expect to record all my operations and terminal outputs on the terminal so that they can be restored when git is used. I searched the internet and found that only this script is the most useful!
The following content is searched on the Internet. If you haven't sorted it out, you can check it out. I only use simple script commands to implement the functions I want.
Many System Administrators know the importance of retaining an activity log containing various tasks and configuration changes. For some organizations, it is sufficient to keep simple logs of "I did this" or "John did that", but other organizations need to record all the changes.
Copying and pasting terminal output may be boring. We use a little-known program called script to solve this problem. It is part of the util-Linux software package of most Linux products.
Script records all the content of a session: the content you input and the content you see. It even records the color. Therefore, if your command prompt or program output contains the color, the script records it.
To use a script, run the following command:
By default, it writes content to the typescript file in the current directory. Then, everything you input is recorded in that file. To record logs in another file, you only need to use the script/path/to/file command.
After the record is completed, enter exit to exit. This command will close the script session and save the file. Now you can use cat or any other program to check log files.
The disadvantage of using a script is that it records all special characters, so your input file will be filled with control characters and ANSI escape sequences. You can use a very simple shell in the script to solve this problem:
$ Shell =/bin/sh PS1 = "$" script
When using scripts, do not use interactive programs or programs that process windows, such as vior top. They will destroy the output result of the session. In addition, the log file records any command line program you use and the steps you take to complete a task. If you need to edit a file in the script, consider exiting the script session, then use script-A (which adds a new session after the old session) to edit the file, and then restart the session.
I used SSH to manage a Linux server in the company. Because I have more than one account, I want to find a software that can record terminal sessions. Finally, I found
Start recording session:
Script-T 2> demo. Timing-a demo. Session
-T indicates the output time data of the recording.
-Option A outputs the recorded file (additional)
Note: When using scripts, do not use interactive programs or programs that process windows, such as vior top. They will destroy the output result of the session.
You can even record the editing process of vim.
In addition, the log file records any command line program you use and the steps you take to complete a task. If you need to edit a file in the script, consider exiting the script session, then use script-A (which adds a new session after the old session) to edit the file, and then restart the session.
End recording session:
Playing a recording session:
Scriptreplay demo. Timing demo. Session
Note: The preceding two commands are part of the Linux util-Linux software package.
Some Linux distributions have script commands but do not have scriptreplay commands, the scriptreplay command is actually a Perl script (this means that the recorded content can also be played in Windows (as long as it is a terminal that supports ANSI control code can be reproduced, and there are some garbled characters in cmd), good) you can find the source code package of util-Linux software package, decompress the package, and search for scriptreplay to find the script.