Temporarily suspend bash_history on a given shell?Methods for avoiding bash history logging?Is there a “SHELL IN PRIVATE” mode for bash?Installing git “sudo: apt-get: command not found”How to print password protected pdf with cups from command line?What are the cases where the command you typed are lost from the history?Connecting to WPA2 from command line, without editing a configuration fileIs there a way to make the history when pressing up in bash shared between shells?How to remove a single line from history?bash_history: comment out dangerous commands: `#`Is it possible to track bash commands in real time?How to prevent .bash_history from being used to rebuild historyCan we change how bash_history gets updated?How do I open a terminal window and execute a command after the shell has opened?Is there a “SHELL IN PRIVATE” mode for bash?How do I call current “.bash_history” from a script?how to avoid writing failed bash commands to bash_history

Why are electrically insulating heatsinks so rare? Is it just cost?

Infinite Abelian subgroup of infinite non Abelian group example

How much of data wrangling is a data scientist's job?

What exploit are these user agents trying to use?

Python: return float 1.0 as int 1 but float 1.5 as float 1.5

How could indestructible materials be used in power generation?

Is there a hemisphere-neutral way of specifying a season?

In Romance of the Three Kingdoms why do people still use bamboo sticks when papers are already invented?

How can I make my BBEG immortal short of making them a Lich or Vampire?

Can a virus destroy the BIOS of a modern computer?

Emailing HOD to enhance faculty application

Can I ask the recruiters in my resume to put the reason why I am rejected?

Is it possible to create light that imparts a greater proportion of its energy as momentum rather than heat?

How to model explosives?

What to put in ESTA if staying in US for a few days before going on to Canada

Watching something be written to a file live with tail

Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?

Did Shadowfax go to Valinor?

What mechanic is there to disable a threat instead of killing it?

What reasons are there for a Capitalist to oppose a 100% inheritance tax?

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

What does it mean to describe someone as a butt steak?

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

Famous Pre Reformation Christian Pastors (Non Catholic and Non Orthodox)



Temporarily suspend bash_history on a given shell?


Methods for avoiding bash history logging?Is there a “SHELL IN PRIVATE” mode for bash?Installing git “sudo: apt-get: command not found”How to print password protected pdf with cups from command line?What are the cases where the command you typed are lost from the history?Connecting to WPA2 from command line, without editing a configuration fileIs there a way to make the history when pressing up in bash shared between shells?How to remove a single line from history?bash_history: comment out dangerous commands: `#`Is it possible to track bash commands in real time?How to prevent .bash_history from being used to rebuild historyCan we change how bash_history gets updated?How do I open a terminal window and execute a command after the shell has opened?Is there a “SHELL IN PRIVATE” mode for bash?How do I call current “.bash_history” from a script?how to avoid writing failed bash commands to bash_history






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








96















Is there a way to temporarily suspend history tracking in bash, so as to enter a sort of "incognito" mode? I'm entering stuff into my terminal that I don't want recorded, sensitive financial info.










share|improve this question






























    96















    Is there a way to temporarily suspend history tracking in bash, so as to enter a sort of "incognito" mode? I'm entering stuff into my terminal that I don't want recorded, sensitive financial info.










    share|improve this question


























      96












      96








      96


      42






      Is there a way to temporarily suspend history tracking in bash, so as to enter a sort of "incognito" mode? I'm entering stuff into my terminal that I don't want recorded, sensitive financial info.










      share|improve this question
















      Is there a way to temporarily suspend history tracking in bash, so as to enter a sort of "incognito" mode? I'm entering stuff into my terminal that I don't want recorded, sensitive financial info.







      bash command-history






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 8 '11 at 20:09









      Gilles

      546k12911091623




      546k12911091623










      asked Apr 8 '11 at 19:51









      Naftuli KayNaftuli Kay

      12.7k56165257




      12.7k56165257




















          6 Answers
          6






          active

          oldest

          votes


















          134














          This should be what you're looking for:



          unset HISTFILE


          From man bash




          If HISTFILE is unset, or if the history file is unwritable, the history is not saved.




          Alternatively, if you want to toggle it off and then back on again, it may be easier to use set:



          Turn Off



          set +o history


          Turn on



          set -o history





          share|improve this answer




















          • 11





            The value of HISTFILE is only checked when bash exits, so the first method doesn't work as is (if you restore the value, the command will be saved). set +o history does work as directed.

            – Gilles
            Apr 8 '11 at 20:10






          • 5





            Thanks, excellent. I'll use set +o history and set -o history to toggle back and forth when I'm doing secret stuff ;)

            – Naftuli Kay
            Apr 8 '11 at 23:38






          • 1





            unset HISTFILE does not work. set -/+o history works like a charm! thanks

            – kholofelo Maloma
            Oct 28 '15 at 13:10







          • 4





            As a tip if you put a space before command (start the command with a space) it will not be recorded in your history, and up/down arrow keys will not show it either.

            – Mahdi
            Jul 3 '17 at 16:21






          • 1





            Only unsetting HISTFILE does not erase the command list in memory (try history to see it). If additionally you do HISTSIZE=0 the list gets erased and no command could be stored to file (as no command is remembered).

            – Isaac
            Aug 28 '18 at 23:36


















          29














          Using bash, set HISTCONTROL="ignorespace" and precede with space any command you do not wish to be recorded in history. In case you forgot to take any measures, there is also history -d <number> for deleting a specific entry or history -c for clearing the entire command history.






          share|improve this answer
































            22














            Make sure that HISTCONTROL contains ignorespace. You'll probably want to add HISTCONTROL=ignorespace (or HISTCONTROL=ignoredups:ignorespace or something) to your ~/.bashrc. Then any command line that begins with a space is omitted from the history.



            Another possibility is to start a new bash session that doesn't save its history.



            $ bash
            $ unset HISTFILE
            $ sooper-sekret-command
            $ exit
            $ #back in the parent shell





            share|improve this answer






























              3














              There is one simple way to turn off the history, so commands won't be stored in the .bash_history file.



              You have to put the whitespace or tab space in front of any command, so that command won't be stored in the history. For example:



              $ ls 
              print the list of file
              $ history
              ls
              history

              $ pwd
              print the current working directory
              $ history
              ls
              history


              The pwd command will not get store in the history, because it has whitespace in the front.






              share|improve this answer

























              • This does not work; Bash complains that '-' or '-history', or other hyphenated commands cannot be found.

                – Samuel A. Falvo II
                Nov 12 '15 at 21:52






              • 2





                This wont work unless HISTCONTROL="ignorespace" is set as in forcefsck's response

                – DeveloperChris
                Mar 21 '16 at 23:37


















              3














              If you need to avoid storing several commands and you still want to use up arrow to access previous commands, use:



              $ bash # open a new session.
              $ unset HISTFILE # avoid recording commands to file.
              $ commands not recorded
              .
              .
              $ exit
              $



              There are four ways (levels) to control how commands are stored.




              1. The first and simplest is to use ignorespace (or ignoreboth):



                $ HISTCONTROL="ignorespace$HISTCONTROL:+:$HISTCONTROL"


                That will allow to use an space before the commands that you want to avoid being recorded in the memory list of history. And, in consequence, as there is no command recorded in memory that could be sent to file, will also avoid one command to be sent to the file listed in $HISFILE.




              2. Avoid recording commands to the file in $HISTFILE:



                $ unset HISTFILE



                If unset, the command history is not saved when a shell exits.




                Null HISTFILE='' and/or set to HISTFILE=/dev/null works to the same effect.
                Understand that commands are still being recorded to the memory list , try the history command, or the up arrow.



                Warning: if HISTFILE is reset before the shell exists, all what has been recorded in memory could be written to the file anyway.




              3. Avoid recording new commands to the history list in memory.
                And, as not being in memory, can not be recorded to file.



                $ shopt -ou history # or set +o history


                Re-enable with shopt -os history (or set -o history)




              4. Remove all commands from to the history list in memory:



                $ HISTSIZE=0


                All commands get erased (from memory) and therefore nothing could be stored to file, of course, until the variable is set again to some valid numeric value.







              share|improve this answer

























              • // , This covers all the answers except the answer from @Ambrose in one convenient page. Way to go, @Isaac. Would you be willing to add a link or two to the docs for this? Pretty sure man history isn't going to cut it for most of us.

                – Nathan Basanese
                Oct 15 '18 at 22:46






              • 1





                @NathanBasanese Expanded. Better?

                – Isaac
                Oct 17 '18 at 15:58











              • // , Yes! Would I be correct in assuming that these come from the Bash Variables and Shopt Built-in docs?

                – Nathan Basanese
                Oct 17 '18 at 16:52












              • // , Also, while I was reading the Bash Variables documentation, I came across HISTIGNORE, which subsumes the function of HISTCONTROL.

                – Nathan Basanese
                Oct 17 '18 at 16:55











              • (Assuming you are using linux): What happens if you execute the command LESS=+'/^ *HISTI' man bash (isn't that the "manual pages"?). @NathanBasanese

                – Isaac
                Oct 17 '18 at 21:38



















              1














              export HISTFILE=/dev/null 


              That is my goto way. Just in case the unset HISTORY/HISTFILE/HISTCONTROL, etc... doesn't work, exporting it to /dev/null has always worked for me.






              share|improve this answer























              • For temporarily suspending history? This didn't work for me as a regular command. Subsequent commands were logged to history. Are you calling this in .bash_profile or a script? GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)

                – Mat Gessel
                Mar 3 at 22:26











              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "106"
              ;
              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: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              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/3.0/"u003ecc by-sa 3.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%2funix.stackexchange.com%2fquestions%2f10922%2ftemporarily-suspend-bash-history-on-a-given-shell%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              6 Answers
              6






              active

              oldest

              votes








              6 Answers
              6






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              134














              This should be what you're looking for:



              unset HISTFILE


              From man bash




              If HISTFILE is unset, or if the history file is unwritable, the history is not saved.




              Alternatively, if you want to toggle it off and then back on again, it may be easier to use set:



              Turn Off



              set +o history


              Turn on



              set -o history





              share|improve this answer




















              • 11





                The value of HISTFILE is only checked when bash exits, so the first method doesn't work as is (if you restore the value, the command will be saved). set +o history does work as directed.

                – Gilles
                Apr 8 '11 at 20:10






              • 5





                Thanks, excellent. I'll use set +o history and set -o history to toggle back and forth when I'm doing secret stuff ;)

                – Naftuli Kay
                Apr 8 '11 at 23:38






              • 1





                unset HISTFILE does not work. set -/+o history works like a charm! thanks

                – kholofelo Maloma
                Oct 28 '15 at 13:10







              • 4





                As a tip if you put a space before command (start the command with a space) it will not be recorded in your history, and up/down arrow keys will not show it either.

                – Mahdi
                Jul 3 '17 at 16:21






              • 1





                Only unsetting HISTFILE does not erase the command list in memory (try history to see it). If additionally you do HISTSIZE=0 the list gets erased and no command could be stored to file (as no command is remembered).

                – Isaac
                Aug 28 '18 at 23:36















              134














              This should be what you're looking for:



              unset HISTFILE


              From man bash




              If HISTFILE is unset, or if the history file is unwritable, the history is not saved.




              Alternatively, if you want to toggle it off and then back on again, it may be easier to use set:



              Turn Off



              set +o history


              Turn on



              set -o history





              share|improve this answer




















              • 11





                The value of HISTFILE is only checked when bash exits, so the first method doesn't work as is (if you restore the value, the command will be saved). set +o history does work as directed.

                – Gilles
                Apr 8 '11 at 20:10






              • 5





                Thanks, excellent. I'll use set +o history and set -o history to toggle back and forth when I'm doing secret stuff ;)

                – Naftuli Kay
                Apr 8 '11 at 23:38






              • 1





                unset HISTFILE does not work. set -/+o history works like a charm! thanks

                – kholofelo Maloma
                Oct 28 '15 at 13:10







              • 4





                As a tip if you put a space before command (start the command with a space) it will not be recorded in your history, and up/down arrow keys will not show it either.

                – Mahdi
                Jul 3 '17 at 16:21






              • 1





                Only unsetting HISTFILE does not erase the command list in memory (try history to see it). If additionally you do HISTSIZE=0 the list gets erased and no command could be stored to file (as no command is remembered).

                – Isaac
                Aug 28 '18 at 23:36













              134












              134








              134







              This should be what you're looking for:



              unset HISTFILE


              From man bash




              If HISTFILE is unset, or if the history file is unwritable, the history is not saved.




              Alternatively, if you want to toggle it off and then back on again, it may be easier to use set:



              Turn Off



              set +o history


              Turn on



              set -o history





              share|improve this answer















              This should be what you're looking for:



              unset HISTFILE


              From man bash




              If HISTFILE is unset, or if the history file is unwritable, the history is not saved.




              Alternatively, if you want to toggle it off and then back on again, it may be easier to use set:



              Turn Off



              set +o history


              Turn on



              set -o history






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Aug 1 '18 at 8:25









              Ploni

              1094




              1094










              answered Apr 8 '11 at 19:53









              SiegeXSiegeX

              5,54112723




              5,54112723







              • 11





                The value of HISTFILE is only checked when bash exits, so the first method doesn't work as is (if you restore the value, the command will be saved). set +o history does work as directed.

                – Gilles
                Apr 8 '11 at 20:10






              • 5





                Thanks, excellent. I'll use set +o history and set -o history to toggle back and forth when I'm doing secret stuff ;)

                – Naftuli Kay
                Apr 8 '11 at 23:38






              • 1





                unset HISTFILE does not work. set -/+o history works like a charm! thanks

                – kholofelo Maloma
                Oct 28 '15 at 13:10







              • 4





                As a tip if you put a space before command (start the command with a space) it will not be recorded in your history, and up/down arrow keys will not show it either.

                – Mahdi
                Jul 3 '17 at 16:21






              • 1





                Only unsetting HISTFILE does not erase the command list in memory (try history to see it). If additionally you do HISTSIZE=0 the list gets erased and no command could be stored to file (as no command is remembered).

                – Isaac
                Aug 28 '18 at 23:36












              • 11





                The value of HISTFILE is only checked when bash exits, so the first method doesn't work as is (if you restore the value, the command will be saved). set +o history does work as directed.

                – Gilles
                Apr 8 '11 at 20:10






              • 5





                Thanks, excellent. I'll use set +o history and set -o history to toggle back and forth when I'm doing secret stuff ;)

                – Naftuli Kay
                Apr 8 '11 at 23:38






              • 1





                unset HISTFILE does not work. set -/+o history works like a charm! thanks

                – kholofelo Maloma
                Oct 28 '15 at 13:10







              • 4





                As a tip if you put a space before command (start the command with a space) it will not be recorded in your history, and up/down arrow keys will not show it either.

                – Mahdi
                Jul 3 '17 at 16:21






              • 1





                Only unsetting HISTFILE does not erase the command list in memory (try history to see it). If additionally you do HISTSIZE=0 the list gets erased and no command could be stored to file (as no command is remembered).

                – Isaac
                Aug 28 '18 at 23:36







              11




              11





              The value of HISTFILE is only checked when bash exits, so the first method doesn't work as is (if you restore the value, the command will be saved). set +o history does work as directed.

              – Gilles
              Apr 8 '11 at 20:10





              The value of HISTFILE is only checked when bash exits, so the first method doesn't work as is (if you restore the value, the command will be saved). set +o history does work as directed.

              – Gilles
              Apr 8 '11 at 20:10




              5




              5





              Thanks, excellent. I'll use set +o history and set -o history to toggle back and forth when I'm doing secret stuff ;)

              – Naftuli Kay
              Apr 8 '11 at 23:38





              Thanks, excellent. I'll use set +o history and set -o history to toggle back and forth when I'm doing secret stuff ;)

              – Naftuli Kay
              Apr 8 '11 at 23:38




              1




              1





              unset HISTFILE does not work. set -/+o history works like a charm! thanks

              – kholofelo Maloma
              Oct 28 '15 at 13:10






              unset HISTFILE does not work. set -/+o history works like a charm! thanks

              – kholofelo Maloma
              Oct 28 '15 at 13:10





              4




              4





              As a tip if you put a space before command (start the command with a space) it will not be recorded in your history, and up/down arrow keys will not show it either.

              – Mahdi
              Jul 3 '17 at 16:21





              As a tip if you put a space before command (start the command with a space) it will not be recorded in your history, and up/down arrow keys will not show it either.

              – Mahdi
              Jul 3 '17 at 16:21




              1




              1





              Only unsetting HISTFILE does not erase the command list in memory (try history to see it). If additionally you do HISTSIZE=0 the list gets erased and no command could be stored to file (as no command is remembered).

              – Isaac
              Aug 28 '18 at 23:36





              Only unsetting HISTFILE does not erase the command list in memory (try history to see it). If additionally you do HISTSIZE=0 the list gets erased and no command could be stored to file (as no command is remembered).

              – Isaac
              Aug 28 '18 at 23:36













              29














              Using bash, set HISTCONTROL="ignorespace" and precede with space any command you do not wish to be recorded in history. In case you forgot to take any measures, there is also history -d <number> for deleting a specific entry or history -c for clearing the entire command history.






              share|improve this answer





























                29














                Using bash, set HISTCONTROL="ignorespace" and precede with space any command you do not wish to be recorded in history. In case you forgot to take any measures, there is also history -d <number> for deleting a specific entry or history -c for clearing the entire command history.






                share|improve this answer



























                  29












                  29








                  29







                  Using bash, set HISTCONTROL="ignorespace" and precede with space any command you do not wish to be recorded in history. In case you forgot to take any measures, there is also history -d <number> for deleting a specific entry or history -c for clearing the entire command history.






                  share|improve this answer















                  Using bash, set HISTCONTROL="ignorespace" and precede with space any command you do not wish to be recorded in history. In case you forgot to take any measures, there is also history -d <number> for deleting a specific entry or history -c for clearing the entire command history.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 8 '11 at 21:24

























                  answered Apr 8 '11 at 19:59









                  forcefsckforcefsck

                  5,7962131




                  5,7962131





















                      22














                      Make sure that HISTCONTROL contains ignorespace. You'll probably want to add HISTCONTROL=ignorespace (or HISTCONTROL=ignoredups:ignorespace or something) to your ~/.bashrc. Then any command line that begins with a space is omitted from the history.



                      Another possibility is to start a new bash session that doesn't save its history.



                      $ bash
                      $ unset HISTFILE
                      $ sooper-sekret-command
                      $ exit
                      $ #back in the parent shell





                      share|improve this answer



























                        22














                        Make sure that HISTCONTROL contains ignorespace. You'll probably want to add HISTCONTROL=ignorespace (or HISTCONTROL=ignoredups:ignorespace or something) to your ~/.bashrc. Then any command line that begins with a space is omitted from the history.



                        Another possibility is to start a new bash session that doesn't save its history.



                        $ bash
                        $ unset HISTFILE
                        $ sooper-sekret-command
                        $ exit
                        $ #back in the parent shell





                        share|improve this answer

























                          22












                          22








                          22







                          Make sure that HISTCONTROL contains ignorespace. You'll probably want to add HISTCONTROL=ignorespace (or HISTCONTROL=ignoredups:ignorespace or something) to your ~/.bashrc. Then any command line that begins with a space is omitted from the history.



                          Another possibility is to start a new bash session that doesn't save its history.



                          $ bash
                          $ unset HISTFILE
                          $ sooper-sekret-command
                          $ exit
                          $ #back in the parent shell





                          share|improve this answer













                          Make sure that HISTCONTROL contains ignorespace. You'll probably want to add HISTCONTROL=ignorespace (or HISTCONTROL=ignoredups:ignorespace or something) to your ~/.bashrc. Then any command line that begins with a space is omitted from the history.



                          Another possibility is to start a new bash session that doesn't save its history.



                          $ bash
                          $ unset HISTFILE
                          $ sooper-sekret-command
                          $ exit
                          $ #back in the parent shell






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Apr 8 '11 at 20:05









                          GillesGilles

                          546k12911091623




                          546k12911091623





















                              3














                              There is one simple way to turn off the history, so commands won't be stored in the .bash_history file.



                              You have to put the whitespace or tab space in front of any command, so that command won't be stored in the history. For example:



                              $ ls 
                              print the list of file
                              $ history
                              ls
                              history

                              $ pwd
                              print the current working directory
                              $ history
                              ls
                              history


                              The pwd command will not get store in the history, because it has whitespace in the front.






                              share|improve this answer

























                              • This does not work; Bash complains that '-' or '-history', or other hyphenated commands cannot be found.

                                – Samuel A. Falvo II
                                Nov 12 '15 at 21:52






                              • 2





                                This wont work unless HISTCONTROL="ignorespace" is set as in forcefsck's response

                                – DeveloperChris
                                Mar 21 '16 at 23:37















                              3














                              There is one simple way to turn off the history, so commands won't be stored in the .bash_history file.



                              You have to put the whitespace or tab space in front of any command, so that command won't be stored in the history. For example:



                              $ ls 
                              print the list of file
                              $ history
                              ls
                              history

                              $ pwd
                              print the current working directory
                              $ history
                              ls
                              history


                              The pwd command will not get store in the history, because it has whitespace in the front.






                              share|improve this answer

























                              • This does not work; Bash complains that '-' or '-history', or other hyphenated commands cannot be found.

                                – Samuel A. Falvo II
                                Nov 12 '15 at 21:52






                              • 2





                                This wont work unless HISTCONTROL="ignorespace" is set as in forcefsck's response

                                – DeveloperChris
                                Mar 21 '16 at 23:37













                              3












                              3








                              3







                              There is one simple way to turn off the history, so commands won't be stored in the .bash_history file.



                              You have to put the whitespace or tab space in front of any command, so that command won't be stored in the history. For example:



                              $ ls 
                              print the list of file
                              $ history
                              ls
                              history

                              $ pwd
                              print the current working directory
                              $ history
                              ls
                              history


                              The pwd command will not get store in the history, because it has whitespace in the front.






                              share|improve this answer















                              There is one simple way to turn off the history, so commands won't be stored in the .bash_history file.



                              You have to put the whitespace or tab space in front of any command, so that command won't be stored in the history. For example:



                              $ ls 
                              print the list of file
                              $ history
                              ls
                              history

                              $ pwd
                              print the current working directory
                              $ history
                              ls
                              history


                              The pwd command will not get store in the history, because it has whitespace in the front.







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Dec 11 '15 at 21:48









                              kenorb

                              9,041374112




                              9,041374112










                              answered May 27 '14 at 8:57









                              Kalanidhi M.Kalanidhi M.

                              1394




                              1394












                              • This does not work; Bash complains that '-' or '-history', or other hyphenated commands cannot be found.

                                – Samuel A. Falvo II
                                Nov 12 '15 at 21:52






                              • 2





                                This wont work unless HISTCONTROL="ignorespace" is set as in forcefsck's response

                                – DeveloperChris
                                Mar 21 '16 at 23:37

















                              • This does not work; Bash complains that '-' or '-history', or other hyphenated commands cannot be found.

                                – Samuel A. Falvo II
                                Nov 12 '15 at 21:52






                              • 2





                                This wont work unless HISTCONTROL="ignorespace" is set as in forcefsck's response

                                – DeveloperChris
                                Mar 21 '16 at 23:37
















                              This does not work; Bash complains that '-' or '-history', or other hyphenated commands cannot be found.

                              – Samuel A. Falvo II
                              Nov 12 '15 at 21:52





                              This does not work; Bash complains that '-' or '-history', or other hyphenated commands cannot be found.

                              – Samuel A. Falvo II
                              Nov 12 '15 at 21:52




                              2




                              2





                              This wont work unless HISTCONTROL="ignorespace" is set as in forcefsck's response

                              – DeveloperChris
                              Mar 21 '16 at 23:37





                              This wont work unless HISTCONTROL="ignorespace" is set as in forcefsck's response

                              – DeveloperChris
                              Mar 21 '16 at 23:37











                              3














                              If you need to avoid storing several commands and you still want to use up arrow to access previous commands, use:



                              $ bash # open a new session.
                              $ unset HISTFILE # avoid recording commands to file.
                              $ commands not recorded
                              .
                              .
                              $ exit
                              $



                              There are four ways (levels) to control how commands are stored.




                              1. The first and simplest is to use ignorespace (or ignoreboth):



                                $ HISTCONTROL="ignorespace$HISTCONTROL:+:$HISTCONTROL"


                                That will allow to use an space before the commands that you want to avoid being recorded in the memory list of history. And, in consequence, as there is no command recorded in memory that could be sent to file, will also avoid one command to be sent to the file listed in $HISFILE.




                              2. Avoid recording commands to the file in $HISTFILE:



                                $ unset HISTFILE



                                If unset, the command history is not saved when a shell exits.




                                Null HISTFILE='' and/or set to HISTFILE=/dev/null works to the same effect.
                                Understand that commands are still being recorded to the memory list , try the history command, or the up arrow.



                                Warning: if HISTFILE is reset before the shell exists, all what has been recorded in memory could be written to the file anyway.




                              3. Avoid recording new commands to the history list in memory.
                                And, as not being in memory, can not be recorded to file.



                                $ shopt -ou history # or set +o history


                                Re-enable with shopt -os history (or set -o history)




                              4. Remove all commands from to the history list in memory:



                                $ HISTSIZE=0


                                All commands get erased (from memory) and therefore nothing could be stored to file, of course, until the variable is set again to some valid numeric value.







                              share|improve this answer

























                              • // , This covers all the answers except the answer from @Ambrose in one convenient page. Way to go, @Isaac. Would you be willing to add a link or two to the docs for this? Pretty sure man history isn't going to cut it for most of us.

                                – Nathan Basanese
                                Oct 15 '18 at 22:46






                              • 1





                                @NathanBasanese Expanded. Better?

                                – Isaac
                                Oct 17 '18 at 15:58











                              • // , Yes! Would I be correct in assuming that these come from the Bash Variables and Shopt Built-in docs?

                                – Nathan Basanese
                                Oct 17 '18 at 16:52












                              • // , Also, while I was reading the Bash Variables documentation, I came across HISTIGNORE, which subsumes the function of HISTCONTROL.

                                – Nathan Basanese
                                Oct 17 '18 at 16:55











                              • (Assuming you are using linux): What happens if you execute the command LESS=+'/^ *HISTI' man bash (isn't that the "manual pages"?). @NathanBasanese

                                – Isaac
                                Oct 17 '18 at 21:38
















                              3














                              If you need to avoid storing several commands and you still want to use up arrow to access previous commands, use:



                              $ bash # open a new session.
                              $ unset HISTFILE # avoid recording commands to file.
                              $ commands not recorded
                              .
                              .
                              $ exit
                              $



                              There are four ways (levels) to control how commands are stored.




                              1. The first and simplest is to use ignorespace (or ignoreboth):



                                $ HISTCONTROL="ignorespace$HISTCONTROL:+:$HISTCONTROL"


                                That will allow to use an space before the commands that you want to avoid being recorded in the memory list of history. And, in consequence, as there is no command recorded in memory that could be sent to file, will also avoid one command to be sent to the file listed in $HISFILE.




                              2. Avoid recording commands to the file in $HISTFILE:



                                $ unset HISTFILE



                                If unset, the command history is not saved when a shell exits.




                                Null HISTFILE='' and/or set to HISTFILE=/dev/null works to the same effect.
                                Understand that commands are still being recorded to the memory list , try the history command, or the up arrow.



                                Warning: if HISTFILE is reset before the shell exists, all what has been recorded in memory could be written to the file anyway.




                              3. Avoid recording new commands to the history list in memory.
                                And, as not being in memory, can not be recorded to file.



                                $ shopt -ou history # or set +o history


                                Re-enable with shopt -os history (or set -o history)




                              4. Remove all commands from to the history list in memory:



                                $ HISTSIZE=0


                                All commands get erased (from memory) and therefore nothing could be stored to file, of course, until the variable is set again to some valid numeric value.







                              share|improve this answer

























                              • // , This covers all the answers except the answer from @Ambrose in one convenient page. Way to go, @Isaac. Would you be willing to add a link or two to the docs for this? Pretty sure man history isn't going to cut it for most of us.

                                – Nathan Basanese
                                Oct 15 '18 at 22:46






                              • 1





                                @NathanBasanese Expanded. Better?

                                – Isaac
                                Oct 17 '18 at 15:58











                              • // , Yes! Would I be correct in assuming that these come from the Bash Variables and Shopt Built-in docs?

                                – Nathan Basanese
                                Oct 17 '18 at 16:52












                              • // , Also, while I was reading the Bash Variables documentation, I came across HISTIGNORE, which subsumes the function of HISTCONTROL.

                                – Nathan Basanese
                                Oct 17 '18 at 16:55











                              • (Assuming you are using linux): What happens if you execute the command LESS=+'/^ *HISTI' man bash (isn't that the "manual pages"?). @NathanBasanese

                                – Isaac
                                Oct 17 '18 at 21:38














                              3












                              3








                              3







                              If you need to avoid storing several commands and you still want to use up arrow to access previous commands, use:



                              $ bash # open a new session.
                              $ unset HISTFILE # avoid recording commands to file.
                              $ commands not recorded
                              .
                              .
                              $ exit
                              $



                              There are four ways (levels) to control how commands are stored.




                              1. The first and simplest is to use ignorespace (or ignoreboth):



                                $ HISTCONTROL="ignorespace$HISTCONTROL:+:$HISTCONTROL"


                                That will allow to use an space before the commands that you want to avoid being recorded in the memory list of history. And, in consequence, as there is no command recorded in memory that could be sent to file, will also avoid one command to be sent to the file listed in $HISFILE.




                              2. Avoid recording commands to the file in $HISTFILE:



                                $ unset HISTFILE



                                If unset, the command history is not saved when a shell exits.




                                Null HISTFILE='' and/or set to HISTFILE=/dev/null works to the same effect.
                                Understand that commands are still being recorded to the memory list , try the history command, or the up arrow.



                                Warning: if HISTFILE is reset before the shell exists, all what has been recorded in memory could be written to the file anyway.




                              3. Avoid recording new commands to the history list in memory.
                                And, as not being in memory, can not be recorded to file.



                                $ shopt -ou history # or set +o history


                                Re-enable with shopt -os history (or set -o history)




                              4. Remove all commands from to the history list in memory:



                                $ HISTSIZE=0


                                All commands get erased (from memory) and therefore nothing could be stored to file, of course, until the variable is set again to some valid numeric value.







                              share|improve this answer















                              If you need to avoid storing several commands and you still want to use up arrow to access previous commands, use:



                              $ bash # open a new session.
                              $ unset HISTFILE # avoid recording commands to file.
                              $ commands not recorded
                              .
                              .
                              $ exit
                              $



                              There are four ways (levels) to control how commands are stored.




                              1. The first and simplest is to use ignorespace (or ignoreboth):



                                $ HISTCONTROL="ignorespace$HISTCONTROL:+:$HISTCONTROL"


                                That will allow to use an space before the commands that you want to avoid being recorded in the memory list of history. And, in consequence, as there is no command recorded in memory that could be sent to file, will also avoid one command to be sent to the file listed in $HISFILE.




                              2. Avoid recording commands to the file in $HISTFILE:



                                $ unset HISTFILE



                                If unset, the command history is not saved when a shell exits.




                                Null HISTFILE='' and/or set to HISTFILE=/dev/null works to the same effect.
                                Understand that commands are still being recorded to the memory list , try the history command, or the up arrow.



                                Warning: if HISTFILE is reset before the shell exists, all what has been recorded in memory could be written to the file anyway.




                              3. Avoid recording new commands to the history list in memory.
                                And, as not being in memory, can not be recorded to file.



                                $ shopt -ou history # or set +o history


                                Re-enable with shopt -os history (or set -o history)




                              4. Remove all commands from to the history list in memory:



                                $ HISTSIZE=0


                                All commands get erased (from memory) and therefore nothing could be stored to file, of course, until the variable is set again to some valid numeric value.








                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Oct 17 '18 at 15:58

























                              answered Aug 29 '18 at 0:11









                              IsaacIsaac

                              12.2k11954




                              12.2k11954












                              • // , This covers all the answers except the answer from @Ambrose in one convenient page. Way to go, @Isaac. Would you be willing to add a link or two to the docs for this? Pretty sure man history isn't going to cut it for most of us.

                                – Nathan Basanese
                                Oct 15 '18 at 22:46






                              • 1





                                @NathanBasanese Expanded. Better?

                                – Isaac
                                Oct 17 '18 at 15:58











                              • // , Yes! Would I be correct in assuming that these come from the Bash Variables and Shopt Built-in docs?

                                – Nathan Basanese
                                Oct 17 '18 at 16:52












                              • // , Also, while I was reading the Bash Variables documentation, I came across HISTIGNORE, which subsumes the function of HISTCONTROL.

                                – Nathan Basanese
                                Oct 17 '18 at 16:55











                              • (Assuming you are using linux): What happens if you execute the command LESS=+'/^ *HISTI' man bash (isn't that the "manual pages"?). @NathanBasanese

                                – Isaac
                                Oct 17 '18 at 21:38


















                              • // , This covers all the answers except the answer from @Ambrose in one convenient page. Way to go, @Isaac. Would you be willing to add a link or two to the docs for this? Pretty sure man history isn't going to cut it for most of us.

                                – Nathan Basanese
                                Oct 15 '18 at 22:46






                              • 1





                                @NathanBasanese Expanded. Better?

                                – Isaac
                                Oct 17 '18 at 15:58











                              • // , Yes! Would I be correct in assuming that these come from the Bash Variables and Shopt Built-in docs?

                                – Nathan Basanese
                                Oct 17 '18 at 16:52












                              • // , Also, while I was reading the Bash Variables documentation, I came across HISTIGNORE, which subsumes the function of HISTCONTROL.

                                – Nathan Basanese
                                Oct 17 '18 at 16:55











                              • (Assuming you are using linux): What happens if you execute the command LESS=+'/^ *HISTI' man bash (isn't that the "manual pages"?). @NathanBasanese

                                – Isaac
                                Oct 17 '18 at 21:38

















                              // , This covers all the answers except the answer from @Ambrose in one convenient page. Way to go, @Isaac. Would you be willing to add a link or two to the docs for this? Pretty sure man history isn't going to cut it for most of us.

                              – Nathan Basanese
                              Oct 15 '18 at 22:46





                              // , This covers all the answers except the answer from @Ambrose in one convenient page. Way to go, @Isaac. Would you be willing to add a link or two to the docs for this? Pretty sure man history isn't going to cut it for most of us.

                              – Nathan Basanese
                              Oct 15 '18 at 22:46




                              1




                              1





                              @NathanBasanese Expanded. Better?

                              – Isaac
                              Oct 17 '18 at 15:58





                              @NathanBasanese Expanded. Better?

                              – Isaac
                              Oct 17 '18 at 15:58













                              // , Yes! Would I be correct in assuming that these come from the Bash Variables and Shopt Built-in docs?

                              – Nathan Basanese
                              Oct 17 '18 at 16:52






                              // , Yes! Would I be correct in assuming that these come from the Bash Variables and Shopt Built-in docs?

                              – Nathan Basanese
                              Oct 17 '18 at 16:52














                              // , Also, while I was reading the Bash Variables documentation, I came across HISTIGNORE, which subsumes the function of HISTCONTROL.

                              – Nathan Basanese
                              Oct 17 '18 at 16:55





                              // , Also, while I was reading the Bash Variables documentation, I came across HISTIGNORE, which subsumes the function of HISTCONTROL.

                              – Nathan Basanese
                              Oct 17 '18 at 16:55













                              (Assuming you are using linux): What happens if you execute the command LESS=+'/^ *HISTI' man bash (isn't that the "manual pages"?). @NathanBasanese

                              – Isaac
                              Oct 17 '18 at 21:38






                              (Assuming you are using linux): What happens if you execute the command LESS=+'/^ *HISTI' man bash (isn't that the "manual pages"?). @NathanBasanese

                              – Isaac
                              Oct 17 '18 at 21:38












                              1














                              export HISTFILE=/dev/null 


                              That is my goto way. Just in case the unset HISTORY/HISTFILE/HISTCONTROL, etc... doesn't work, exporting it to /dev/null has always worked for me.






                              share|improve this answer























                              • For temporarily suspending history? This didn't work for me as a regular command. Subsequent commands were logged to history. Are you calling this in .bash_profile or a script? GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)

                                – Mat Gessel
                                Mar 3 at 22:26















                              1














                              export HISTFILE=/dev/null 


                              That is my goto way. Just in case the unset HISTORY/HISTFILE/HISTCONTROL, etc... doesn't work, exporting it to /dev/null has always worked for me.






                              share|improve this answer























                              • For temporarily suspending history? This didn't work for me as a regular command. Subsequent commands were logged to history. Are you calling this in .bash_profile or a script? GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)

                                – Mat Gessel
                                Mar 3 at 22:26













                              1












                              1








                              1







                              export HISTFILE=/dev/null 


                              That is my goto way. Just in case the unset HISTORY/HISTFILE/HISTCONTROL, etc... doesn't work, exporting it to /dev/null has always worked for me.






                              share|improve this answer













                              export HISTFILE=/dev/null 


                              That is my goto way. Just in case the unset HISTORY/HISTFILE/HISTCONTROL, etc... doesn't work, exporting it to /dev/null has always worked for me.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Aug 28 '18 at 18:31









                              AmbroseAmbrose

                              111




                              111












                              • For temporarily suspending history? This didn't work for me as a regular command. Subsequent commands were logged to history. Are you calling this in .bash_profile or a script? GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)

                                – Mat Gessel
                                Mar 3 at 22:26

















                              • For temporarily suspending history? This didn't work for me as a regular command. Subsequent commands were logged to history. Are you calling this in .bash_profile or a script? GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)

                                – Mat Gessel
                                Mar 3 at 22:26
















                              For temporarily suspending history? This didn't work for me as a regular command. Subsequent commands were logged to history. Are you calling this in .bash_profile or a script? GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)

                              – Mat Gessel
                              Mar 3 at 22:26





                              For temporarily suspending history? This didn't work for me as a regular command. Subsequent commands were logged to history. Are you calling this in .bash_profile or a script? GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)

                              – Mat Gessel
                              Mar 3 at 22:26

















                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Unix & Linux Stack Exchange!


                              • 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%2funix.stackexchange.com%2fquestions%2f10922%2ftemporarily-suspend-bash-history-on-a-given-shell%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

                              getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

                              Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

                              Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.