Friday, April 26, 2024
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 413  / 1 Year ago, thu, may 11, 2023, 2:32:14

I looking for the terminal history. Not only the command history that is showed by typing history but terminal processes within a command. That is, I want to record the output displayed by the commands in the terminal.



For example, One wanna install a package and types sudo apt-get install xxxx then is when terminal is telling you what is doing, it asks for confirmation, for installing additional packages, etc. –


More From » command-line

 Answers
5

The shell keeps a history of the commands that you type, that's what the history command gives you. There is no automatic history of the output from the commands that you run in the terminal. Once you close the terminal, the output is lost unless you saved it somewhere.



You can save a complete transcript of a terminal session by running the script command. If you run the command script, you get a new shell prompt; all the commands that you type from that point, as well as their output, are entered in the log. The log file is closed when you exit the script subsession (which returns you to the parent shell — entering exit or pressing Ctrl+D a second time exits the parent shell).



The default history file name is typescript (in the current directory). If there is already a file by that name, it is overwritten. You can specify a different file name by passing it as an argument to script, e.g. script hello.txt.



If you want to keep the history after closing a terminal, but don't mind losing the history when you switch off your computer, you can run screen or tmux.


[#26012] Saturday, May 13, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eeperant

Total Points: 39
Total Questions: 106
Total Answers: 117

Location: Finland
Member since Sat, Dec 5, 2020
3 Years ago
;