There are various ways by which you can store terminal the output to a file. To write the command output into a file then follow the below methods.
Contents
command > file.txt
The standard output stream will only be diverted to the file and will not be seen in the terminal. If the file exists previously, it is overwritten.
command > output_file.txt
command >> file.txt
The standard output stream will only be diverted to the file and will not be seen in the terminal. If the file already exists, the new information will be appended to the end.
command >> output_file.txt
Also you can use the below commands to write for standard error streams:
command 2> file.txt
command 2>> file.txt
Also read:
[Solved] The following packages have been kept back