How to copy complete content on terminal to a text file using commands .

  • I unserstand you want to copy the output of previous commands right? Not the output of yet to be run commands. – kos Apr 24 '16 at 18:55
  • Are you working inside screen or tmux (maybe using byobu)? – JanC Apr 24 '16 at 19:14

You can use screendump.

As in the man page:

 screendump - dump the contents of a virtual console to stdout

You'll need root privileges to run screendump, so use sudo.


As far as terminal emulators go ( GUI ) you can select the text with mouse and switch to text editor ( be it gedit or anything else ) and press Ctrl + Button 2 ( Scroll wheel on mouse and Right+Left click on touchpad )

With TTY you could use cat /dev/vcs1 to dump contents of TTY1.

Best approaches , however, should use terminal multiplexers such as screen , tmux, byobu or use script command to record the whole session to file.


When you execute the command in terminal, for example: lspci Just add the > or >> symbols and file_name. For example:

lspci > log_file.txt ... create/overwrite log_file.txt

lspci >> log_file.txt ... append to the file

The output will be saved in given file. Of course, if you want to save it in some other directory than present directory you just add path to the log_file.txt in front of filename.

  • The question said: Not for one output but everything on terminal – WAKR Oct 1 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.