Monday, April 29, 2024
95
rated 0 times [  95] [ 0]  / answers: 1 / hits: 202235  / 2 Years ago, sat, july 2, 2022, 11:47:21

My Ubuntu headless server is about to lose both hard drives(raid1). I already saved the most important stuff. Now I'm sitting in front of a Mac OS X client with the terminal open (ssh).



I need to save the whole or at least the most important install commands I wrote. So basically the first 1k commands...



I would like to print that & save it to a file. So I can easily reinstall everything.



By the way, also save some hard researched config files that I don't remember where they are.


More From » command-line

 Answers
1

There is already a hidden file in your home directory called .bash_history which you can print it. One observation here: this file, in a default configuration, doesn't contain the commands used in your current opened terminal session. So, close the terminal before to print it.



But if you want to save the terminal history in another file, then you can use the following command (this new file will contain also and the commands used in your currently opened terminal session):



history > history_for_print.txt


A new file called history_for_print.txt will be created in your currently working directory containing your last used commands (by default HISTSIZE=1000 and HISTFILESIZE=2000, but you can change these values in your ~/.bashrc file).


[#27331] Monday, July 4, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tresein

Total Points: 197
Total Questions: 113
Total Answers: 112

Location: Hungary
Member since Wed, Nov 9, 2022
2 Years ago
tresein questions
Tue, Jun 28, 22, 17:57, 2 Years ago
Sun, Apr 3, 22, 07:11, 2 Years ago
Thu, Feb 3, 22, 18:03, 2 Years ago
Sat, May 13, 23, 13:00, 1 Year ago
;