Save Terminal historyBash history handling with multiple terminalsHow to save live log bash input to a file?Script Not Running Properly On ServerHow to save the command line output to a file IN REALTIMEHow do I save terminal output from multiple commands to one file?Run TTY script every time I open a GUI terminalNano in a while loopCan I run two different awk commands in 1

Is using Swiss Francs (CHF) cheaper than Euros (EUR) in Switzerland?

Did all integrated Commodore PET monitors always use 60 Hz refresh?

How can I encourage a fellow player to develop a character a bit more?

Finding the time domain equation corresponding to a given DFT

Longest Prime Sums

What's the greatest number of hands I can have to annoy my mother-in-law with?

Applying field calculator for multiple layers at once

Java 13 Triple-quote Text Block *WITHOUT* newlines

Finding IP return hex address

Students using the same flawed online solution sheet as the grading TA

Is there something as common frequency?

Is there a key for the map icons in game?

Can a human colony survive on a 'hot' world?

Was a four year-old forced to sleep on the floor of Leeds General Infirmary?

I shift the source code, you shift the input!

Command to keep only a portion of JSON data from each line?

What are the earliest instances of a virus causing large-scale mutations?

Why is Trump not being impeached for bribery?

Unable to register mirrored Deployer Capabilities

Confused about Autoregressive AR(1) process

How did 達 (~tachi) come to mean `pluralize` something?

How much of a discount should I seek when prepaying a whole year's rent?

How to calculate my anticipated peak amperage load?

How do I force `sudo` to ask for a password each time when a specific command is used?



Save Terminal history


Bash history handling with multiple terminalsHow to save live log bash input to a file?Script Not Running Properly On ServerHow to save the command line output to a file IN REALTIMEHow do I save terminal output from multiple commands to one file?Run TTY script every time I open a GUI terminalNano in a while loopCan I run two different awk commands in 1






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









2


















I am currently taking a Linux class and working on a project in the command line. I the very last thing I need to do is save all of my work into a log file. The exact phrasing is:
"Create a log file of all the commands you have utilized to this point. Title this file Log_File.txt and download it for submission"
The downnloading part is done through the IDE but I am having a bitch of a time finding the answer to how to make that file that saves everything I did in the project.
Anything would help.
-Thanks










share|improve this question

























  • Which shell are you using? Most (if not all) shell keep a history of the commands used, reviewing your shell’s manual will tell you which commands to use to obtain them.

    – dessert
    Sep 30 at 16:38











  • i am using bash? I believe.

    – Corey Lewis
    Sep 30 at 16:41






  • 1





    The script command will save all screen output (and keyboard input) to a file named typescript.

    – FedonKadifeli
    Sep 30 at 19:48











  • SInce command history ("$HISTFILE" default value $HOME/.history) is overwritten when you login again, see askubuntu.com/questions/80371/… my answer.

    – waltinator
    Sep 30 at 22:55











  • @waltinator In bash the default value of $HISTFILE is ~/.bash_history and its lines are dropped in order to stay inside the $HISTFILESIZE limit of by default 2000 lines – why would it be overwritten on login?

    – dessert
    Oct 2 at 6:01

















2


















I am currently taking a Linux class and working on a project in the command line. I the very last thing I need to do is save all of my work into a log file. The exact phrasing is:
"Create a log file of all the commands you have utilized to this point. Title this file Log_File.txt and download it for submission"
The downnloading part is done through the IDE but I am having a bitch of a time finding the answer to how to make that file that saves everything I did in the project.
Anything would help.
-Thanks










share|improve this question

























  • Which shell are you using? Most (if not all) shell keep a history of the commands used, reviewing your shell’s manual will tell you which commands to use to obtain them.

    – dessert
    Sep 30 at 16:38











  • i am using bash? I believe.

    – Corey Lewis
    Sep 30 at 16:41






  • 1





    The script command will save all screen output (and keyboard input) to a file named typescript.

    – FedonKadifeli
    Sep 30 at 19:48











  • SInce command history ("$HISTFILE" default value $HOME/.history) is overwritten when you login again, see askubuntu.com/questions/80371/… my answer.

    – waltinator
    Sep 30 at 22:55











  • @waltinator In bash the default value of $HISTFILE is ~/.bash_history and its lines are dropped in order to stay inside the $HISTFILESIZE limit of by default 2000 lines – why would it be overwritten on login?

    – dessert
    Oct 2 at 6:01













2













2









2








I am currently taking a Linux class and working on a project in the command line. I the very last thing I need to do is save all of my work into a log file. The exact phrasing is:
"Create a log file of all the commands you have utilized to this point. Title this file Log_File.txt and download it for submission"
The downnloading part is done through the IDE but I am having a bitch of a time finding the answer to how to make that file that saves everything I did in the project.
Anything would help.
-Thanks










share|improve this question














I am currently taking a Linux class and working on a project in the command line. I the very last thing I need to do is save all of my work into a log file. The exact phrasing is:
"Create a log file of all the commands you have utilized to this point. Title this file Log_File.txt and download it for submission"
The downnloading part is done through the IDE but I am having a bitch of a time finding the answer to how to make that file that saves everything I did in the project.
Anything would help.
-Thanks







command-line






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 30 at 16:35









Corey LewisCorey Lewis

211 bronze badge




211 bronze badge















  • Which shell are you using? Most (if not all) shell keep a history of the commands used, reviewing your shell’s manual will tell you which commands to use to obtain them.

    – dessert
    Sep 30 at 16:38











  • i am using bash? I believe.

    – Corey Lewis
    Sep 30 at 16:41






  • 1





    The script command will save all screen output (and keyboard input) to a file named typescript.

    – FedonKadifeli
    Sep 30 at 19:48











  • SInce command history ("$HISTFILE" default value $HOME/.history) is overwritten when you login again, see askubuntu.com/questions/80371/… my answer.

    – waltinator
    Sep 30 at 22:55











  • @waltinator In bash the default value of $HISTFILE is ~/.bash_history and its lines are dropped in order to stay inside the $HISTFILESIZE limit of by default 2000 lines – why would it be overwritten on login?

    – dessert
    Oct 2 at 6:01

















  • Which shell are you using? Most (if not all) shell keep a history of the commands used, reviewing your shell’s manual will tell you which commands to use to obtain them.

    – dessert
    Sep 30 at 16:38











  • i am using bash? I believe.

    – Corey Lewis
    Sep 30 at 16:41






  • 1





    The script command will save all screen output (and keyboard input) to a file named typescript.

    – FedonKadifeli
    Sep 30 at 19:48











  • SInce command history ("$HISTFILE" default value $HOME/.history) is overwritten when you login again, see askubuntu.com/questions/80371/… my answer.

    – waltinator
    Sep 30 at 22:55











  • @waltinator In bash the default value of $HISTFILE is ~/.bash_history and its lines are dropped in order to stay inside the $HISTFILESIZE limit of by default 2000 lines – why would it be overwritten on login?

    – dessert
    Oct 2 at 6:01
















Which shell are you using? Most (if not all) shell keep a history of the commands used, reviewing your shell’s manual will tell you which commands to use to obtain them.

– dessert
Sep 30 at 16:38





Which shell are you using? Most (if not all) shell keep a history of the commands used, reviewing your shell’s manual will tell you which commands to use to obtain them.

– dessert
Sep 30 at 16:38













i am using bash? I believe.

– Corey Lewis
Sep 30 at 16:41





i am using bash? I believe.

– Corey Lewis
Sep 30 at 16:41




1




1





The script command will save all screen output (and keyboard input) to a file named typescript.

– FedonKadifeli
Sep 30 at 19:48





The script command will save all screen output (and keyboard input) to a file named typescript.

– FedonKadifeli
Sep 30 at 19:48













SInce command history ("$HISTFILE" default value $HOME/.history) is overwritten when you login again, see askubuntu.com/questions/80371/… my answer.

– waltinator
Sep 30 at 22:55





SInce command history ("$HISTFILE" default value $HOME/.history) is overwritten when you login again, see askubuntu.com/questions/80371/… my answer.

– waltinator
Sep 30 at 22:55













@waltinator In bash the default value of $HISTFILE is ~/.bash_history and its lines are dropped in order to stay inside the $HISTFILESIZE limit of by default 2000 lines – why would it be overwritten on login?

– dessert
Oct 2 at 6:01





@waltinator In bash the default value of $HISTFILE is ~/.bash_history and its lines are dropped in order to stay inside the $HISTFILESIZE limit of by default 2000 lines – why would it be overwritten on login?

– dessert
Oct 2 at 6:01










2 Answers
2






active

oldest

votes


















3



















I suppose you just need to run:



history > filename.txt





share|improve this answer


































    0



















    To manage the session history of a bash shell there’s the history command. Let’s have a look at the relevant parts of help history:




    $ help history
    history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
    Display or manipulate the history list.

    Display the history list with line numbers, prefixing each modified
    entry with a `*'. An argument of N lists only the last N entries.

    Options:
    -a append history lines from this session to the history file
    -w write the current history to the history file

    If FILENAME is given, it is used as the history file. Otherwise,
    if HISTFILE has a value, that is used, else ~/.bash_history.



    When a bash shell is started it reads the last (by default 1000) lines from the user’s history file (by default ~/.bash_history) and builts a session history in the RAM. When you now execute a command line it saves this line to the session history and drops the first line instead – the session history once reached the limit of the 1000 lines doesn’t exceed this limit.



    Following this, in order to save only the session history i.e. the command lines you executed in this particular terminal window in a file ~/session_history, it’s:



    history -a ~/session_history


    If you however want to save the 1000 lines of history the session currently holds in memory, i.e. commands from older sessions and the current one, it’s:



    history -w ~/session+old_history


    If you want to save the whole history of all sessions closed so far, limited to 2000 lines by default, you just need to copy your default history file:



    cp ~/.bash_history ~/closed-sessions_history


    If you want to manually save a session’s history to this file without closing the session, do:



    history -a


    If you did that in every open terminal, your history file is up to date with all the command lines you used to this point, copying it now gives you a full history of closed and open sessions:



    cp ~/.bash_history ~/all-sessions_history





    share|improve this answer


























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "89"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );














      draft saved

      draft discarded
















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1177720%2fsave-terminal-history%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown


























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3



















      I suppose you just need to run:



      history > filename.txt





      share|improve this answer































        3



















        I suppose you just need to run:



        history > filename.txt





        share|improve this answer





























          3















          3











          3









          I suppose you just need to run:



          history > filename.txt





          share|improve this answer
















          I suppose you just need to run:



          history > filename.txt






          share|improve this answer















          share|improve this answer




          share|improve this answer








          edited Oct 1 at 17:11









          user3140225

          2,7104 gold badges12 silver badges24 bronze badges




          2,7104 gold badges12 silver badges24 bronze badges










          answered Oct 1 at 16:35









          joahimjoahim

          412 bronze badges




          412 bronze badges


























              0



















              To manage the session history of a bash shell there’s the history command. Let’s have a look at the relevant parts of help history:




              $ help history
              history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
              Display or manipulate the history list.

              Display the history list with line numbers, prefixing each modified
              entry with a `*'. An argument of N lists only the last N entries.

              Options:
              -a append history lines from this session to the history file
              -w write the current history to the history file

              If FILENAME is given, it is used as the history file. Otherwise,
              if HISTFILE has a value, that is used, else ~/.bash_history.



              When a bash shell is started it reads the last (by default 1000) lines from the user’s history file (by default ~/.bash_history) and builts a session history in the RAM. When you now execute a command line it saves this line to the session history and drops the first line instead – the session history once reached the limit of the 1000 lines doesn’t exceed this limit.



              Following this, in order to save only the session history i.e. the command lines you executed in this particular terminal window in a file ~/session_history, it’s:



              history -a ~/session_history


              If you however want to save the 1000 lines of history the session currently holds in memory, i.e. commands from older sessions and the current one, it’s:



              history -w ~/session+old_history


              If you want to save the whole history of all sessions closed so far, limited to 2000 lines by default, you just need to copy your default history file:



              cp ~/.bash_history ~/closed-sessions_history


              If you want to manually save a session’s history to this file without closing the session, do:



              history -a


              If you did that in every open terminal, your history file is up to date with all the command lines you used to this point, copying it now gives you a full history of closed and open sessions:



              cp ~/.bash_history ~/all-sessions_history





              share|improve this answer





























                0



















                To manage the session history of a bash shell there’s the history command. Let’s have a look at the relevant parts of help history:




                $ help history
                history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
                Display or manipulate the history list.

                Display the history list with line numbers, prefixing each modified
                entry with a `*'. An argument of N lists only the last N entries.

                Options:
                -a append history lines from this session to the history file
                -w write the current history to the history file

                If FILENAME is given, it is used as the history file. Otherwise,
                if HISTFILE has a value, that is used, else ~/.bash_history.



                When a bash shell is started it reads the last (by default 1000) lines from the user’s history file (by default ~/.bash_history) and builts a session history in the RAM. When you now execute a command line it saves this line to the session history and drops the first line instead – the session history once reached the limit of the 1000 lines doesn’t exceed this limit.



                Following this, in order to save only the session history i.e. the command lines you executed in this particular terminal window in a file ~/session_history, it’s:



                history -a ~/session_history


                If you however want to save the 1000 lines of history the session currently holds in memory, i.e. commands from older sessions and the current one, it’s:



                history -w ~/session+old_history


                If you want to save the whole history of all sessions closed so far, limited to 2000 lines by default, you just need to copy your default history file:



                cp ~/.bash_history ~/closed-sessions_history


                If you want to manually save a session’s history to this file without closing the session, do:



                history -a


                If you did that in every open terminal, your history file is up to date with all the command lines you used to this point, copying it now gives you a full history of closed and open sessions:



                cp ~/.bash_history ~/all-sessions_history





                share|improve this answer



























                  0















                  0











                  0









                  To manage the session history of a bash shell there’s the history command. Let’s have a look at the relevant parts of help history:




                  $ help history
                  history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
                  Display or manipulate the history list.

                  Display the history list with line numbers, prefixing each modified
                  entry with a `*'. An argument of N lists only the last N entries.

                  Options:
                  -a append history lines from this session to the history file
                  -w write the current history to the history file

                  If FILENAME is given, it is used as the history file. Otherwise,
                  if HISTFILE has a value, that is used, else ~/.bash_history.



                  When a bash shell is started it reads the last (by default 1000) lines from the user’s history file (by default ~/.bash_history) and builts a session history in the RAM. When you now execute a command line it saves this line to the session history and drops the first line instead – the session history once reached the limit of the 1000 lines doesn’t exceed this limit.



                  Following this, in order to save only the session history i.e. the command lines you executed in this particular terminal window in a file ~/session_history, it’s:



                  history -a ~/session_history


                  If you however want to save the 1000 lines of history the session currently holds in memory, i.e. commands from older sessions and the current one, it’s:



                  history -w ~/session+old_history


                  If you want to save the whole history of all sessions closed so far, limited to 2000 lines by default, you just need to copy your default history file:



                  cp ~/.bash_history ~/closed-sessions_history


                  If you want to manually save a session’s history to this file without closing the session, do:



                  history -a


                  If you did that in every open terminal, your history file is up to date with all the command lines you used to this point, copying it now gives you a full history of closed and open sessions:



                  cp ~/.bash_history ~/all-sessions_history





                  share|improve this answer














                  To manage the session history of a bash shell there’s the history command. Let’s have a look at the relevant parts of help history:




                  $ help history
                  history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
                  Display or manipulate the history list.

                  Display the history list with line numbers, prefixing each modified
                  entry with a `*'. An argument of N lists only the last N entries.

                  Options:
                  -a append history lines from this session to the history file
                  -w write the current history to the history file

                  If FILENAME is given, it is used as the history file. Otherwise,
                  if HISTFILE has a value, that is used, else ~/.bash_history.



                  When a bash shell is started it reads the last (by default 1000) lines from the user’s history file (by default ~/.bash_history) and builts a session history in the RAM. When you now execute a command line it saves this line to the session history and drops the first line instead – the session history once reached the limit of the 1000 lines doesn’t exceed this limit.



                  Following this, in order to save only the session history i.e. the command lines you executed in this particular terminal window in a file ~/session_history, it’s:



                  history -a ~/session_history


                  If you however want to save the 1000 lines of history the session currently holds in memory, i.e. commands from older sessions and the current one, it’s:



                  history -w ~/session+old_history


                  If you want to save the whole history of all sessions closed so far, limited to 2000 lines by default, you just need to copy your default history file:



                  cp ~/.bash_history ~/closed-sessions_history


                  If you want to manually save a session’s history to this file without closing the session, do:



                  history -a


                  If you did that in every open terminal, your history file is up to date with all the command lines you used to this point, copying it now gives you a full history of closed and open sessions:



                  cp ~/.bash_history ~/all-sessions_history






                  share|improve this answer













                  share|improve this answer




                  share|improve this answer










                  answered Oct 2 at 5:47









                  dessertdessert

                  30.5k7 gold badges89 silver badges124 bronze badges




                  30.5k7 gold badges89 silver badges124 bronze badges































                      draft saved

                      draft discarded















































                      Thanks for contributing an answer to Ask Ubuntu!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1177720%2fsave-terminal-history%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown









                      Popular posts from this blog

                      Tamil (spriik) Luke uk diar | Nawigatjuun

                      Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                      Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?